Added curly brackets to if statements in form.server.routes.test.js
This commit is contained in:
parent
b494b50ed5
commit
014c1c578c
|
@ -1,15 +1,12 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var should = require('should'),
|
var should = require('should'),
|
||||||
lodash = require('lodash'),
|
|
||||||
app = require('../../server'),
|
app = require('../../server'),
|
||||||
request = require('supertest'),
|
|
||||||
Session = require('supertest-session'),
|
Session = require('supertest-session'),
|
||||||
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'),
|
Field = mongoose.model('Field');
|
||||||
FormSubmission = mongoose.model('FormSubmission');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Globals
|
* Globals
|
||||||
|
@ -70,8 +67,10 @@ describe('Form Routes Unit tests', function() {
|
||||||
.end(function(signinErr, signinRes) {
|
.end(function(signinErr, signinRes) {
|
||||||
|
|
||||||
// Handle signin error
|
// Handle signin error
|
||||||
if (signinErr) return done(signinErr);
|
if (signinErr) {
|
||||||
|
return done(signinErr);
|
||||||
|
}
|
||||||
|
|
||||||
var user = signinRes.body;
|
var user = signinRes.body;
|
||||||
var userId = user._id;
|
var userId = user._id;
|
||||||
|
|
||||||
|
@ -82,16 +81,20 @@ describe('Form Routes Unit tests', function() {
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.end(function(FormSaveErr, FormSaveRes) {
|
.end(function(FormSaveErr, FormSaveRes) {
|
||||||
// Handle Form save error
|
// Handle Form save error
|
||||||
if (FormSaveErr) return done(FormSaveErr);
|
if (FormSaveErr) {
|
||||||
|
return done(FormSaveErr);
|
||||||
|
}
|
||||||
|
|
||||||
// Get a list of Forms
|
// Get a list of Forms
|
||||||
userSession.get('/forms')
|
userSession.get('/forms')
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.end(function(FormsGetErr, FormsGetRes) {
|
.end(function(FormsGetErr, FormsGetRes) {
|
||||||
// Handle Form save error
|
// Handle Form save error
|
||||||
if (FormsGetErr) return done(FormsGetErr);
|
if (FormsGetErr) {
|
||||||
|
return done(FormsGetErr);
|
||||||
|
}
|
||||||
|
|
||||||
// Get Forms list
|
// Get Forms list
|
||||||
var Forms = FormsGetRes.body;
|
var Forms = FormsGetRes.body;
|
||||||
|
|
||||||
|
@ -158,8 +161,10 @@ describe('Form Routes Unit tests', function() {
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.end(function(signinErr, signinRes) {
|
.end(function(signinErr, signinRes) {
|
||||||
// Handle signin error
|
// Handle signin error
|
||||||
if (signinErr) return done(signinErr);
|
if (signinErr) {
|
||||||
|
return done(signinErr);
|
||||||
|
}
|
||||||
|
|
||||||
// Save a new Form
|
// Save a new Form
|
||||||
userSession.post('/forms')
|
userSession.post('/forms')
|
||||||
.send({form: myForm})
|
.send({form: myForm})
|
||||||
|
@ -179,8 +184,10 @@ describe('Form Routes Unit tests', function() {
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.end(function(FormUpdateErr, FormUpdateRes) {
|
.end(function(FormUpdateErr, FormUpdateRes) {
|
||||||
// Handle Form update error
|
// Handle Form update error
|
||||||
if (FormUpdateErr) done(FormUpdateErr);
|
if (FormUpdateErr) {
|
||||||
|
done(FormUpdateErr);
|
||||||
|
}
|
||||||
|
|
||||||
// Set assertions
|
// Set assertions
|
||||||
(FormUpdateRes.body._id).should.equal(FormSaveRes.body._id);
|
(FormUpdateRes.body._id).should.equal(FormSaveRes.body._id);
|
||||||
(FormUpdateRes.body.title).should.match('WHY YOU GOTTA BE SO MEAN?');
|
(FormUpdateRes.body.title).should.match('WHY YOU GOTTA BE SO MEAN?');
|
||||||
|
@ -204,8 +211,10 @@ describe('Form Routes Unit tests', function() {
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.end(function(err, res) {
|
.end(function(err, res) {
|
||||||
if(err) return done(err)
|
if(err) {
|
||||||
|
return done(err)
|
||||||
|
}
|
||||||
|
|
||||||
// Set assertion
|
// Set assertion
|
||||||
(res.body).should.be.an.Object.with.property('title', myForm.title);
|
(res.body).should.be.an.Object.with.property('title', myForm.title);
|
||||||
|
|
||||||
|
@ -223,8 +232,10 @@ describe('Form Routes Unit tests', function() {
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.end(function(signinErr, signinRes) {
|
.end(function(signinErr, signinRes) {
|
||||||
// Handle signin error
|
// Handle signin error
|
||||||
if (signinErr) return done(signinErr);
|
if (signinErr) {
|
||||||
|
return done(signinErr);
|
||||||
|
}
|
||||||
|
|
||||||
// Save a new Form
|
// Save a new Form
|
||||||
userSession.post('/forms')
|
userSession.post('/forms')
|
||||||
.send({form: myForm})
|
.send({form: myForm})
|
||||||
|
@ -232,8 +243,10 @@ describe('Form Routes Unit tests', function() {
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.end(function(FormSaveErr, FormSaveRes) {
|
.end(function(FormSaveErr, FormSaveRes) {
|
||||||
// Handle Form save error
|
// Handle Form save error
|
||||||
if (FormSaveErr) return done(FormSaveErr);
|
if (FormSaveErr) {
|
||||||
|
return done(FormSaveErr);
|
||||||
|
}
|
||||||
|
|
||||||
// Delete an existing Form
|
// Delete an existing Form
|
||||||
userSession.delete('/forms/' + FormSaveRes.body._id)
|
userSession.delete('/forms/' + FormSaveRes.body._id)
|
||||||
.send(myForm)
|
.send(myForm)
|
||||||
|
@ -268,7 +281,6 @@ describe('Form Routes Unit tests', function() {
|
||||||
userSession.delete('/forms/' + FormObj._id)
|
userSession.delete('/forms/' + FormObj._id)
|
||||||
.expect(401)
|
.expect(401)
|
||||||
.end(function(FormDeleteErr, FormDeleteRes) {
|
.end(function(FormDeleteErr, FormDeleteRes) {
|
||||||
|
|
||||||
// Handle Form error error
|
// Handle Form error error
|
||||||
done(FormDeleteErr);
|
done(FormDeleteErr);
|
||||||
});
|
});
|
||||||
|
@ -287,7 +299,9 @@ describe('Form Routes Unit tests', function() {
|
||||||
.end(function(signinErr, signinRes) {
|
.end(function(signinErr, signinRes) {
|
||||||
|
|
||||||
// Handle signin error
|
// Handle signin error
|
||||||
if (signinErr) return done(signinErr);
|
if (signinErr) {
|
||||||
|
return done(signinErr);
|
||||||
|
}
|
||||||
|
|
||||||
_user = signinRes.body;
|
_user = signinRes.body;
|
||||||
// Save a new Form
|
// Save a new Form
|
||||||
|
@ -297,7 +311,10 @@ describe('Form Routes Unit tests', function() {
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.end(function(FormSaveErr, FormSaveRes) {
|
.end(function(FormSaveErr, FormSaveRes) {
|
||||||
// Handle Form save error
|
// Handle Form save error
|
||||||
if (FormSaveErr) return done(FormSaveErr);
|
if (FormSaveErr) {
|
||||||
|
return done(FormSaveErr);
|
||||||
|
}
|
||||||
|
|
||||||
_form = FormSaveRes.body;
|
_form = FormSaveRes.body;
|
||||||
|
|
||||||
// Get a list of Forms
|
// Get a list of Forms
|
||||||
|
@ -306,7 +323,9 @@ describe('Form Routes Unit tests', function() {
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.end(function(FormsGetErr, FormsGetRes) {
|
.end(function(FormsGetErr, FormsGetRes) {
|
||||||
// Handle Form save error
|
// Handle Form save error
|
||||||
if (FormsGetErr) return done(FormsGetErr);
|
if (FormsGetErr) {
|
||||||
|
return done(FormsGetErr);
|
||||||
|
}
|
||||||
|
|
||||||
var fetchedForm = FormsGetRes.body;
|
var fetchedForm = FormsGetRes.body;
|
||||||
// Set assertions
|
// Set assertions
|
||||||
|
@ -323,20 +342,22 @@ describe('Form Routes Unit tests', function() {
|
||||||
userSession.get('/auth/signout')
|
userSession.get('/auth/signout')
|
||||||
.end(function(signoutErr, signoutRes) {
|
.end(function(signoutErr, signoutRes) {
|
||||||
|
|
||||||
// Handle signout error
|
// Handle signout error
|
||||||
if (signoutErr) return done(signoutErr);
|
if (signoutErr) {
|
||||||
|
return done(signoutErr);
|
||||||
|
}
|
||||||
_userSession.destroy();
|
_userSession.destroy();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function(done) {
|
afterEach(function(done) {
|
||||||
Form.remove({}).exec(function() {
|
Form.remove({}).exec(function() {
|
||||||
User.remove({}).exec(function() {
|
User.remove({}).exec(function() {
|
||||||
userSession.destroy();
|
userSession.destroy();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue