Refactored form.server.model.test.js

This commit is contained in:
David Baldwynn 2017-04-22 19:56:47 -07:00 committed by GitHub
parent efb6fa6d7f
commit 367e2df0ad

View file

@ -6,16 +6,12 @@
var should = require('should'), var should = require('should'),
mongoose = require('mongoose'), mongoose = require('mongoose'),
User = mongoose.model('User'), User = mongoose.model('User'),
Form = mongoose.model('Form'), Form = mongoose.model('Form');
Field = mongoose.model('Field'),
_ = require('lodash'),
config = require('../../config/config'),
FormSubmission = mongoose.model('FormSubmission');
/** /**
* Globals * Globals
*/ */
var user, myForm, mySubmission; var user, myForm;
/** /**
* Unit tests * Unit tests
@ -34,8 +30,7 @@ describe('Form Model Unit Tests:', function() {
user.save(function(err) { user.save(function(err) {
if(err) { if(err) {
done(err); return done(err);
return;
} }
myForm = new Form({ myForm = new Form({
title: 'Form Title', title: 'Form Title',
@ -75,12 +70,11 @@ describe('Form Model Unit Tests:', function() {
describe('Method Find', function(){ describe('Method Find', function(){
beforeEach(function(done){ beforeEach(function(done){
myForm.save(function(err) { myForm.save(function(err) {
if(err) return done(err); return done(err);
done();
}); });
}); });
it('should be able to findOne my form without problems', function(done) { it('should be able to findOne my form without problems', function(done) {
Form.findOne({title: myForm.title}).exec(function(err,form) { Form.findOne({title: myForm.title}).exec(function(err, form) {
should.not.exist(err); should.not.exist(err);
should.exist(form); should.exist(form);