got serverside tests to run
This commit is contained in:
parent
06e6780cd1
commit
8c4129380b
|
@ -62,86 +62,86 @@ describe('Form Routes Unit tests', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// describe(' > Login and Save a new Form >', function() {
|
describe(' > Login and Save a new Form >', function() {
|
||||||
// var lodashuser, lodashform;
|
var lodashuser, lodashform;
|
||||||
// before(function(done){
|
before(function(done){
|
||||||
// userSession.post('/auth/signin')
|
userSession.post('/auth/signin')
|
||||||
// .send(credentials)
|
.send(credentials)
|
||||||
// .expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
// .expect(200, 'Could not login user')
|
.expect(200, 'Could not login user')
|
||||||
// .end(function(signinErr, signinRes) {
|
.end(function(signinErr, signinRes) {
|
||||||
|
|
||||||
// // Handle signin error
|
// Handle signin error
|
||||||
// if (signinErr) return done(signinErr);
|
if (signinErr) return done(signinErr);
|
||||||
|
|
||||||
// lodashuser = signinRes.body;
|
lodashuser = signinRes.body;
|
||||||
// done();
|
done();
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// it(' > should be able to save a Form as a user', function(done){
|
it(' > should be able to save a Form as a user', function(done){
|
||||||
// // Save a new Form
|
// Save a new Form
|
||||||
// userSession.post('/forms')
|
userSession.post('/forms')
|
||||||
// .send({form: myForm})
|
.send({form: myForm})
|
||||||
// .expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
// .expect(200, 'Could not save new Form')
|
.expect(200, 'Could not save new Form')
|
||||||
// .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);
|
||||||
// lodashform = FormSaveRes.body;
|
lodashform = FormSaveRes.body;
|
||||||
// done();
|
done();
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// it(' > should be able to fetch newly created form', function(done){
|
it(' > should be able to fetch newly created form', function(done){
|
||||||
|
|
||||||
// // Get a list of Forms
|
// Get a list of Forms
|
||||||
// userSession.get('/forms/'+lodashform.lodashid)
|
userSession.get('/forms/'+lodashform.lodashid)
|
||||||
// .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);
|
||||||
|
|
||||||
// var fetchedForm = FormsGetRes.body;
|
var fetchedForm = FormsGetRes.body;
|
||||||
// // Set assertions
|
// Set assertions
|
||||||
// (fetchedForm.admin).should.equal(lodashuser.lodashid);
|
(fetchedForm.admin).should.equal(lodashuser.lodashid);
|
||||||
// (fetchedForm.title).should.match(lodashform.title);
|
(fetchedForm.title).should.match(lodashform.title);
|
||||||
|
|
||||||
// // Call the assertion callback
|
// Call the assertion callback
|
||||||
// done();
|
done();
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// after(function(done){
|
after(function(done){
|
||||||
// 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();
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
// it(' > should not be able to create a Form if not logged in', function(done) {
|
it(' > should not be able to create a Form if not logged in', function(done) {
|
||||||
// agent.post('/forms')
|
agent.post('/forms')
|
||||||
// .send({form: myForm})
|
.send({form: myForm})
|
||||||
// .expect(401)
|
.expect(401)
|
||||||
// .end(function(FormSaveErr, FormSaveRes) {
|
.end(function(FormSaveErr, FormSaveRes) {
|
||||||
// (FormSaveRes.body.message).should.equal('User is not logged in');
|
(FormSaveRes.body.message).should.equal('User is not logged in');
|
||||||
// // Call the assertion callback
|
// Call the assertion callback
|
||||||
// done(FormSaveErr);
|
done(FormSaveErr);
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
// it(' > should not be able to get list of users\' Forms if not logged in', function(done) {
|
it(' > should not be able to get list of users\' Forms if not logged in', function(done) {
|
||||||
// agent.get('/forms')
|
agent.get('/forms')
|
||||||
// .expect(401)
|
.expect(401)
|
||||||
// .end(function(FormSaveErr, FormSaveRes) {
|
.end(function(FormSaveErr, FormSaveRes) {
|
||||||
// (FormSaveRes.body.message).should.equal('User is not logged in');
|
(FormSaveRes.body.message).should.equal('User is not logged in');
|
||||||
// // Call the assertion callback
|
// Call the assertion callback
|
||||||
// done(FormSaveErr);
|
done(FormSaveErr);
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
it(' > should not be able to save a Form if no title is provided', function(done) {
|
it(' > should not be able to save a Form if no title is provided', function(done) {
|
||||||
// Set Form with a invalid title field
|
// Set Form with a invalid title field
|
||||||
|
@ -173,178 +173,178 @@ describe('Form Routes Unit tests', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// it(' > should be able to update a Form if signed in', function(done) {
|
it(' > should be able to update a Form if signed in', function(done) {
|
||||||
// userSession.post('/auth/signin')
|
userSession.post('/auth/signin')
|
||||||
// .send(credentials)
|
.send(credentials)
|
||||||
// .expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
// .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})
|
||||||
// .expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
// .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);
|
||||||
|
|
||||||
// // Update Form title
|
// Update Form title
|
||||||
// myForm.title = 'WHY YOU GOTTA BE SO MEAN?';
|
myForm.title = 'WHY YOU GOTTA BE SO MEAN?';
|
||||||
|
|
||||||
// // Update an existing Form
|
// Update an existing Form
|
||||||
// userSession.put('/forms/' + FormSaveRes.body.lodashid)
|
userSession.put('/forms/' + FormSaveRes.body.lodashid)
|
||||||
// .send({form: myForm})
|
.send({form: myForm})
|
||||||
// .expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
// .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.lodashid).should.equal(FormSaveRes.body.lodashid);
|
(FormUpdateRes.body.lodashid).should.equal(FormSaveRes.body.lodashid);
|
||||||
// (FormUpdateRes.body.title).should.match('WHY YOU GOTTA BE SO MEAN?');
|
(FormUpdateRes.body.title).should.match('WHY YOU GOTTA BE SO MEAN?');
|
||||||
|
|
||||||
// // Call the assertion callback
|
// Call the assertion callback
|
||||||
// done();
|
done();
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
// it(' > should be able to read/get a Form if not signed in', function(done) {
|
it(' > should be able to read/get a Form if not signed in', function(done) {
|
||||||
// // Create new Form model instance
|
// Create new Form model instance
|
||||||
// var FormObj = new Form(myForm);
|
var FormObj = new Form(myForm);
|
||||||
|
|
||||||
// // Save the Form
|
// Save the Form
|
||||||
// FormObj.save(function(err, form) {
|
FormObj.save(function(err, form) {
|
||||||
// if(err) return done(err);
|
if(err) return done(err);
|
||||||
|
|
||||||
// agent.get('/forms/' + form.lodashid)
|
agent.get('/forms/' + form.lodashid)
|
||||||
// .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);
|
||||||
|
|
||||||
// // Call the assertion callback
|
// Call the assertion callback
|
||||||
// done();
|
done();
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
// it(' > should be able to delete a Form if signed in', function(done) {
|
it(' > should be able to delete a Form if signed in', function(done) {
|
||||||
|
|
||||||
// userSession.post('/auth/signin')
|
userSession.post('/auth/signin')
|
||||||
// .send(credentials)
|
.send(credentials)
|
||||||
// .expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
// .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})
|
||||||
// .expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
// .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.lodashid)
|
userSession.delete('/forms/' + FormSaveRes.body.lodashid)
|
||||||
// .send(myForm)
|
.send(myForm)
|
||||||
// .expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
// .expect(200)
|
.expect(200)
|
||||||
// .end(function(FormDeleteErr, FormDeleteRes) {
|
.end(function(FormDeleteErr, FormDeleteRes) {
|
||||||
// // Handle Form error error
|
// Handle Form error error
|
||||||
// if (FormDeleteErr) return done(FormDeleteErr);
|
if (FormDeleteErr) return done(FormDeleteErr);
|
||||||
|
|
||||||
// // Set assertions
|
// Set assertions
|
||||||
// (FormDeleteRes.body).should.exist();
|
(FormDeleteRes.body).should.exist();
|
||||||
// // (FormDeleteRes.body.lodashid).should.equal(FormSaveRes.body.lodashid);
|
// (FormDeleteRes.body.lodashid).should.equal(FormSaveRes.body.lodashid);
|
||||||
|
|
||||||
// // Call the assertion callback
|
// Call the assertion callback
|
||||||
// done();
|
done();
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
// it(' > should not be able to delete an Form if not signed in', function(done) {
|
it(' > should not be able to delete an Form if not signed in', function(done) {
|
||||||
// // Set Form user
|
// Set Form user
|
||||||
// myForm.admin = user;
|
myForm.admin = user;
|
||||||
|
|
||||||
// // Create new Form model instance
|
// Create new Form model instance
|
||||||
// var FormObj = new Form(myForm);
|
var FormObj = new Form(myForm);
|
||||||
|
|
||||||
// // Save the Form
|
// Save the Form
|
||||||
// FormObj.save(function() {
|
FormObj.save(function() {
|
||||||
// // Try deleting Form
|
// Try deleting Form
|
||||||
// agent.delete('/forms/' + FormObj.lodashid)
|
agent.delete('/forms/' + FormObj.lodashid)
|
||||||
// .expect(401)
|
.expect(401)
|
||||||
// .end(function(FormDeleteErr, FormDeleteRes) {
|
.end(function(FormDeleteErr, FormDeleteRes) {
|
||||||
// // Set message assertion
|
// Set message assertion
|
||||||
// (FormDeleteRes.body.message).should.match('User is not logged in');
|
(FormDeleteRes.body.message).should.match('User is not logged in');
|
||||||
|
|
||||||
// // Handle Form error error
|
// Handle Form error error
|
||||||
// done(FormDeleteErr);
|
done(FormDeleteErr);
|
||||||
// });
|
});
|
||||||
|
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
// it(' > should be able to upload a PDF an Form if logged in', function(done) {
|
it(' > should be able to upload a PDF an Form if logged in', function(done) {
|
||||||
// userSession.post('/auth/signin')
|
userSession.post('/auth/signin')
|
||||||
// .send(credentials)
|
.send(credentials)
|
||||||
// .expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
// .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);
|
||||||
|
|
||||||
// var user = signinRes.body;
|
var user = signinRes.body;
|
||||||
// var userId = user.lodashid;
|
var userId = user.lodashid;
|
||||||
|
|
||||||
// // Save a new Form
|
// Save a new Form
|
||||||
// userSession.post('/forms')
|
userSession.post('/forms')
|
||||||
// .send({form: myForm})
|
.send({form: myForm})
|
||||||
// .expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
// .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;
|
||||||
|
|
||||||
// // Set assertions
|
// Set assertions
|
||||||
// (Forms[0].admin).should.equal(userId);
|
(Forms[0].admin).should.equal(userId);
|
||||||
// (Forms[0].title).should.match('Form Title');
|
(Forms[0].title).should.match('Form Title');
|
||||||
|
|
||||||
// // Call the assertion callback
|
// Call the assertion callback
|
||||||
// done();
|
done();
|
||||||
// });
|
});
|
||||||
|
|
||||||
// });
|
});
|
||||||
|
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
afterEach(function(done) {
|
afterEach(function(done) {
|
||||||
Form.remove({}).exec(function() {
|
Form.remove({}).exec(function() {
|
||||||
|
|
|
@ -1,314 +1,314 @@
|
||||||
// 'use strict';
|
'use strict';
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Module dependencies.
|
* Module dependencies.
|
||||||
// */
|
*/
|
||||||
// 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'),
|
Field = mongoose.model('Field'),
|
||||||
// _ = require('lodash'),
|
_ = require('lodash'),
|
||||||
// async = require('async'),
|
async = require('async'),
|
||||||
// soap = require('soap'),
|
soap = require('soap'),
|
||||||
// config = require('../../config/config'),
|
config = require('../../config/config'),
|
||||||
// OscarSecurity = require('../../scripts/oscarhost/OscarSecurity'),
|
OscarSecurity = require('../../scripts/oscarhost/OscarSecurity'),
|
||||||
// FormSubmission = mongoose.model('FormSubmission');
|
FormSubmission = mongoose.model('FormSubmission');
|
||||||
|
|
||||||
// var exampleDemo = {
|
var exampleDemo = {
|
||||||
// address: '880-9650 Velit. St.',
|
address: '880-9650 Velit. St.',
|
||||||
// city: '',
|
city: '',
|
||||||
// dateOfBirth: '10',
|
dateOfBirth: '10',
|
||||||
// displayName: 'Test User',
|
displayName: 'Test User',
|
||||||
// email: 'polydaic@gmail.com',
|
email: 'polydaic@gmail.com',
|
||||||
// firstName: 'Test User',
|
firstName: 'Test User',
|
||||||
// hin: '',
|
hin: '',
|
||||||
// lastName: 'AddDemographic',
|
lastName: 'AddDemographic',
|
||||||
// lastUpdateDate: '2014-10-01 00:00:00',
|
lastUpdateDate: '2014-10-01 00:00:00',
|
||||||
// monthOfBirth: '05',
|
monthOfBirth: '05',
|
||||||
// officialLanguage: 'English',
|
officialLanguage: 'English',
|
||||||
// phone: '250-222-2222',
|
phone: '250-222-2222',
|
||||||
// phone2: '',
|
phone2: '',
|
||||||
// postal: 'S4M 7T8',
|
postal: 'S4M 7T8',
|
||||||
// province: 'BC',
|
province: 'BC',
|
||||||
// sex: 'F',
|
sex: 'F',
|
||||||
// sexDesc: 'Female',
|
sexDesc: 'Female',
|
||||||
// sin: '',
|
sin: '',
|
||||||
// spokenLanguage: 'English',
|
spokenLanguage: 'English',
|
||||||
// title: 'MS.',
|
title: 'MS.',
|
||||||
// yearOfBirth: '2015'
|
yearOfBirth: '2015'
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var sampleFormFields = [
|
||||||
|
{'fieldType':'textfield', 'title':'What\'s your first name', 'fieldValue': ''},
|
||||||
|
{'fieldType':'textfield', 'title':'And your last name', 'fieldValue': ''},
|
||||||
|
{'fieldType':'radio', 'title':'And your sex', 'fieldOptions': [{ 'option_id': 0, 'option_title': 'Male', 'option_value': 'M' }, { 'option_id': 1, 'option_title': 'Female', 'option_value': 'F' }], 'fieldValue': ''},
|
||||||
|
{'fieldType':'date', 'title':'When were you born?', 'fieldValue': ''},
|
||||||
|
{'fieldType':'number', 'title':'What\'s your phone #?', 'fieldValue': ''}
|
||||||
|
];
|
||||||
|
|
||||||
|
var sampleSubmission = [
|
||||||
|
{'fieldType':'textfield', 'title':'What\'s your first name', 'fieldValue': 'David'},
|
||||||
|
{'fieldType':'textfield', 'title':'And your last name', 'fieldValue': 'Baldwynn'},
|
||||||
|
{'fieldType':'radio', 'title':'And your sex', 'fieldValue': 'M', 'fieldOptions': [{ 'option_id': 0, 'option_title': 'Male', 'option_value': 'M' }, { 'option_id': 1, 'option_title': 'Female', 'option_value': 'F' }]},
|
||||||
|
{'fieldType':'date', 'title':'When were you born?', 'fieldValue': 'Tue Oct 06 2015 15:17:48 GMT-0700 (PDT)'},
|
||||||
|
{'fieldType':'number', 'title':'What\'s your phone #?', 'fieldValue': '6043158008'}
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Globals
|
||||||
|
*/
|
||||||
|
var user, myForm, mySubmission;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit tests
|
||||||
|
*/
|
||||||
|
describe('FormSubmission Model Unit Tests:', function() {
|
||||||
|
this.timeout(15000);
|
||||||
|
beforeEach(function(done) {
|
||||||
|
user = new User({
|
||||||
|
firstName: 'Full',
|
||||||
|
lastName: 'Name',
|
||||||
|
displayName: 'Full Name',
|
||||||
|
email: 'test1@test.com'+Date.now(),
|
||||||
|
username: 'test1@test.com'+Date.now(),
|
||||||
|
password: 'password',
|
||||||
|
provider: 'local'
|
||||||
|
});
|
||||||
|
|
||||||
|
user.save(function(err) {
|
||||||
|
if(err){
|
||||||
|
console.log(err.errors);
|
||||||
|
done(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
myForm = new Form({
|
||||||
|
title: 'Form Title1',
|
||||||
|
admin: user._id,
|
||||||
|
language: 'english',
|
||||||
|
form_fields: [
|
||||||
|
{'fieldType':'textfield', 'title':'What\'s your first name', 'fieldValue': ''},
|
||||||
|
{'fieldType':'textfield', 'title':'And your last name', 'fieldValue': ''},
|
||||||
|
{'fieldType':'radio', 'title':'And your sex', 'fieldOptions': [{ 'option_id': 0, 'option_title': 'Male', 'option_value': 'M' }, { 'option_id': 1, 'option_title': 'Female', 'option_value': 'F' }], 'fieldValue': ''},
|
||||||
|
{'fieldType':'date', 'title':'When were you born?', 'fieldValue': ''},
|
||||||
|
{'fieldType':'number', 'title':'What\'s your phone #?', 'fieldValue': ''},
|
||||||
|
],
|
||||||
|
plugins: {
|
||||||
|
oscarhost: {
|
||||||
|
baseUrl: config.oscarhost.baseUrl,
|
||||||
|
settings: {
|
||||||
|
updateType: 'force_add',
|
||||||
|
},
|
||||||
|
auth: config.oscarhost.auth,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
myForm.save(function(err, form){
|
||||||
|
if(err){
|
||||||
|
console.log(err.errors);
|
||||||
|
done(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var submissionFields = _.clone(myForm.form_fields);
|
||||||
|
for(var z=0; z<submissionFields.length; z++){
|
||||||
|
submissionFields[z] = _.extend(myForm.form_fields[z], sampleSubmission[z]);
|
||||||
|
}
|
||||||
|
|
||||||
|
mySubmission = new FormSubmission({
|
||||||
|
admin: user._id,
|
||||||
|
form: myForm._id,
|
||||||
|
timeElapsed: 17.55,
|
||||||
|
form_fields: submissionFields
|
||||||
|
});
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Method Save', function() {
|
||||||
|
this.timeout(15000);
|
||||||
|
var oscar_demo_num;
|
||||||
|
|
||||||
|
beforeEach(function(done){
|
||||||
|
|
||||||
|
var myFieldMap = {};
|
||||||
|
myFieldMap[myForm.form_fields[0]._id+''] = 'firstName';
|
||||||
|
myFieldMap[myForm.form_fields[1]._id+''] = 'lastName';
|
||||||
|
myFieldMap[myForm.form_fields[2]._id+''] = 'sex';
|
||||||
|
myFieldMap[myForm.form_fields[3]._id+''] = 'DOB';
|
||||||
|
myFieldMap[myForm.form_fields[4]._id+''] = 'phone';
|
||||||
|
|
||||||
|
myForm.plugins.oscarhost.settings.fieldMap = myFieldMap;
|
||||||
|
|
||||||
|
myForm.save(function(err, form){
|
||||||
|
if(err) done(err);
|
||||||
|
else done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be able to save a FormSubmission without problems', function(done) {
|
||||||
|
return mySubmission.save(function(err, submission) {
|
||||||
|
should.not.exist(err);
|
||||||
|
should.exist(submission);
|
||||||
|
// should.exist(submission.oscarDemoNum);
|
||||||
|
// oscar_demo_num = submission.oscarDemoNum;
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// it('should add Patient to OscarHost EMR after save', function(done){
|
||||||
|
// var url_login = myForm.plugins.oscarhost.baseUrl+'/LoginService?wsdl',
|
||||||
|
// url_demo = myForm.plugins.oscarhost.baseUrl+'/DemographicService?wsdl',
|
||||||
|
// args_login = {arg0: config.oscarhost.auth.user, arg1: config.oscarhost.auth.pass};
|
||||||
|
|
||||||
|
// var options = {
|
||||||
|
// ignoredNamespaces: {
|
||||||
|
// namespaces: ['targetNamespace', 'typedNamespace'],
|
||||||
|
// override: true
|
||||||
|
// }
|
||||||
// };
|
// };
|
||||||
|
|
||||||
|
// async.waterfall([
|
||||||
// var sampleFormFields = [
|
// function (callback) {
|
||||||
// {'fieldType':'textfield', 'title':'What\'s your first name', 'fieldValue': ''},
|
// //Authenticate with API
|
||||||
// {'fieldType':'textfield', 'title':'And your last name', 'fieldValue': ''},
|
// soap.createClient(url_login, options, function(err, client) {
|
||||||
// {'fieldType':'radio', 'title':'And your sex', 'fieldOptions': [{ 'option_id': 0, 'option_title': 'Male', 'option_value': 'M' }, { 'option_id': 1, 'option_title': 'Female', 'option_value': 'F' }], 'fieldValue': ''},
|
// client.login(args_login, function (err, result) {
|
||||||
// {'fieldType':'date', 'title':'When were you born?', 'fieldValue': ''},
|
// if(err) callback(err);
|
||||||
// {'fieldType':'number', 'title':'What\'s your phone #?', 'fieldValue': ''}
|
// callback(null, result.return);
|
||||||
// ];
|
// });
|
||||||
|
|
||||||
// var sampleSubmission = [
|
|
||||||
// {'fieldType':'textfield', 'title':'What\'s your first name', 'fieldValue': 'David'},
|
|
||||||
// {'fieldType':'textfield', 'title':'And your last name', 'fieldValue': 'Baldwynn'},
|
|
||||||
// {'fieldType':'radio', 'title':'And your sex', 'fieldValue': 'M', 'fieldOptions': [{ 'option_id': 0, 'option_title': 'Male', 'option_value': 'M' }, { 'option_id': 1, 'option_title': 'Female', 'option_value': 'F' }]},
|
|
||||||
// {'fieldType':'date', 'title':'When were you born?', 'fieldValue': 'Tue Oct 06 2015 15:17:48 GMT-0700 (PDT)'},
|
|
||||||
// {'fieldType':'number', 'title':'What\'s your phone #?', 'fieldValue': '6043158008'}
|
|
||||||
// ];
|
|
||||||
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Globals
|
|
||||||
// */
|
|
||||||
// var user, myForm, mySubmission;
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Unit tests
|
|
||||||
// */
|
|
||||||
// describe('FormSubmission Model Unit Tests:', function() {
|
|
||||||
// this.timeout(15000);
|
|
||||||
// beforeEach(function(done) {
|
|
||||||
// user = new User({
|
|
||||||
// firstName: 'Full',
|
|
||||||
// lastName: 'Name',
|
|
||||||
// displayName: 'Full Name',
|
|
||||||
// email: 'test1@test.com'+Date.now(),
|
|
||||||
// username: 'test1@test.com'+Date.now(),
|
|
||||||
// password: 'password',
|
|
||||||
// provider: 'local'
|
|
||||||
// });
|
// });
|
||||||
|
|
||||||
// user.save(function(err) {
|
|
||||||
// if(err){
|
|
||||||
// console.log(err.errors);
|
|
||||||
// done(err);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// myForm = new Form({
|
|
||||||
// title: 'Form Title1',
|
|
||||||
// admin: user._id,
|
|
||||||
// language: 'english',
|
|
||||||
// form_fields: [
|
|
||||||
// {'fieldType':'textfield', 'title':'What\'s your first name', 'fieldValue': ''},
|
|
||||||
// {'fieldType':'textfield', 'title':'And your last name', 'fieldValue': ''},
|
|
||||||
// {'fieldType':'radio', 'title':'And your sex', 'fieldOptions': [{ 'option_id': 0, 'option_title': 'Male', 'option_value': 'M' }, { 'option_id': 1, 'option_title': 'Female', 'option_value': 'F' }], 'fieldValue': ''},
|
|
||||||
// {'fieldType':'date', 'title':'When were you born?', 'fieldValue': ''},
|
|
||||||
// {'fieldType':'number', 'title':'What\'s your phone #?', 'fieldValue': ''},
|
|
||||||
// ],
|
|
||||||
// plugins: {
|
|
||||||
// oscarhost: {
|
|
||||||
// baseUrl: config.oscarhost.baseUrl,
|
|
||||||
// settings: {
|
|
||||||
// updateType: 'force_add',
|
|
||||||
// },
|
// },
|
||||||
// auth: config.oscarhost.auth,
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
// myForm.save(function(err, form){
|
// function (security_obj, callback) {
|
||||||
// if(err){
|
// soap.createClient(url_demo, options, function(err, client) {
|
||||||
// console.log(err.errors);
|
// client.setSecurity(new OscarSecurity(security_obj.securityId, security_obj.securityTokenKey) );
|
||||||
// done(err);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// var submissionFields = _.clone(myForm.form_fields);
|
// client.getDemographic({ arg0: oscar_demo_num }, function (err, result) {
|
||||||
// for(var z=0; z<submissionFields.length; z++){
|
// if(err) callback(err);
|
||||||
// submissionFields[z] = _.extend(myForm.form_fields[z], sampleSubmission[z]);
|
// callback(null, result);
|
||||||
// }
|
|
||||||
|
|
||||||
// mySubmission = new FormSubmission({
|
|
||||||
// admin: user._id,
|
|
||||||
// form: myForm._id,
|
|
||||||
// timeElapsed: 17.55,
|
|
||||||
// form_fields: submissionFields
|
|
||||||
// });
|
|
||||||
|
|
||||||
// done();
|
|
||||||
// });
|
|
||||||
// });
|
// });
|
||||||
// });
|
// });
|
||||||
|
// },
|
||||||
|
|
||||||
// describe('Method Save', function() {
|
// ], function(err, result) {
|
||||||
// this.timeout(15000);
|
|
||||||
// var oscar_demo_num;
|
|
||||||
|
|
||||||
// beforeEach(function(done){
|
|
||||||
|
|
||||||
// var myFieldMap = {};
|
|
||||||
// myFieldMap[myForm.form_fields[0]._id+''] = 'firstName';
|
|
||||||
// myFieldMap[myForm.form_fields[1]._id+''] = 'lastName';
|
|
||||||
// myFieldMap[myForm.form_fields[2]._id+''] = 'sex';
|
|
||||||
// myFieldMap[myForm.form_fields[3]._id+''] = 'DOB';
|
|
||||||
// myFieldMap[myForm.form_fields[4]._id+''] = 'phone';
|
|
||||||
|
|
||||||
// myForm.plugins.oscarhost.settings.fieldMap = myFieldMap;
|
|
||||||
|
|
||||||
// myForm.save(function(err, form){
|
|
||||||
// if(err) done(err);
|
// if(err) done(err);
|
||||||
// else done();
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should be able to save a FormSubmission without problems', function(done) {
|
// should.exist(result);
|
||||||
// return mySubmission.save(function(err, submission) {
|
// console.log(result.return);
|
||||||
|
|
||||||
|
// done();
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Method Find', function(){
|
||||||
|
beforeEach(function(done){
|
||||||
|
mySubmission.save(function(err) {
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it('should be able to findOne FormSubmission without problems', function(done) {
|
||||||
|
return FormSubmission.findOne({_id: mySubmission._id}).exec(function(err,submission) {
|
||||||
|
should.not.exist(err);
|
||||||
|
should.exist(submission);
|
||||||
|
should.deepEqual(submission.toObject(), mySubmission.toObject());
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be able to find FormSubmission by $elemMatch on form_fields id', function(done){
|
||||||
|
return FormSubmission.findOne({ form: myForm._id, admin: user, form_fields: {$elemMatch: {_id: myForm.form_fields[0]._id} } })
|
||||||
|
.exec(function(err, submission){
|
||||||
|
should.not.exist(err);
|
||||||
|
should.exist(submission);
|
||||||
|
should.deepEqual(submission.toObject(), mySubmission.toObject());
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Test FormField and Submission Logic', function() {
|
||||||
|
var new_form_fields_add1, new_form_fields_del;
|
||||||
|
|
||||||
|
beforeEach(function(done){
|
||||||
|
new_form_fields_add1 = _.clone(myForm.toObject().form_fields);
|
||||||
|
new_form_fields_add1.push(
|
||||||
|
{'fieldType':'textfield', 'title':'Last Name', 'fieldValue': ''}
|
||||||
|
);
|
||||||
|
|
||||||
|
//Create Submission
|
||||||
|
|
||||||
|
mySubmission = new FormSubmission({
|
||||||
|
form_fields: sampleSubmission,
|
||||||
|
admin: user,
|
||||||
|
form: myForm,
|
||||||
|
timeElapsed: 17.55
|
||||||
|
});
|
||||||
|
|
||||||
|
mySubmission.save(function(err){
|
||||||
|
should.not.exist(err);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// it('should preserve deleted form_fields that have submissions without any problems', function(done) {
|
||||||
|
|
||||||
|
// var old_fields = myForm.toObject().form_fields;
|
||||||
|
// var new_form_fields = _.clone(myForm.toObject().form_fields);
|
||||||
|
// new_form_fields.splice(0, 1);
|
||||||
|
|
||||||
|
// myForm.form_fields = new_form_fields;
|
||||||
|
|
||||||
|
// myForm.save(function(err, _form) {
|
||||||
|
|
||||||
// should.not.exist(err);
|
// should.not.exist(err);
|
||||||
// should.exist(submission);
|
// should.exist(_form);
|
||||||
// // should.exist(submission.oscarDemoNum);
|
|
||||||
// // oscar_demo_num = submission.oscarDemoNum;
|
|
||||||
|
|
||||||
|
// // var actual_fields = _.map(_form.toObject().form_fields, function(o){ _.omit(o, '_id')});
|
||||||
|
// // old_fields = _.map(old_fields, function(o){ _.omit(o, '_id')});
|
||||||
|
|
||||||
|
// // console.log(old_fields);
|
||||||
|
// should.deepEqual(JSON.stringify(_form.toObject().form_fields), JSON.stringify(old_fields), 'old form_fields not equal to newly saved form_fields');
|
||||||
// done();
|
// done();
|
||||||
// });
|
// });
|
||||||
// });
|
// });
|
||||||
|
|
||||||
// // it('should add Patient to OscarHost EMR after save', function(done){
|
|
||||||
// // var url_login = myForm.plugins.oscarhost.baseUrl+'/LoginService?wsdl',
|
|
||||||
// // url_demo = myForm.plugins.oscarhost.baseUrl+'/DemographicService?wsdl',
|
|
||||||
// // args_login = {arg0: config.oscarhost.auth.user, arg1: config.oscarhost.auth.pass};
|
|
||||||
|
|
||||||
// // var options = {
|
// it('should delete \'preserved\' form_fields whose submissions have been removed without any problems', function(done) {
|
||||||
// // ignoredNamespaces: {
|
|
||||||
// // namespaces: ['targetNamespace', 'typedNamespace'],
|
|
||||||
// // override: true
|
|
||||||
// // }
|
|
||||||
// // };
|
|
||||||
|
|
||||||
// // async.waterfall([
|
// myForm.form_fields = new_form_fields_del;
|
||||||
// // function (callback) {
|
// myForm.save(function(err, form
|
||||||
// // //Authenticate with API
|
|
||||||
// // soap.createClient(url_login, options, function(err, client) {
|
|
||||||
// // client.login(args_login, function (err, result) {
|
|
||||||
// // if(err) callback(err);
|
|
||||||
// // callback(null, result.return);
|
|
||||||
// // });
|
|
||||||
// // });
|
|
||||||
// // },
|
|
||||||
|
|
||||||
// // function (security_obj, callback) {
|
|
||||||
// // soap.createClient(url_demo, options, function(err, client) {
|
|
||||||
// // client.setSecurity(new OscarSecurity(security_obj.securityId, security_obj.securityTokenKey) );
|
|
||||||
|
|
||||||
// // client.getDemographic({ arg0: oscar_demo_num }, function (err, result) {
|
|
||||||
// // if(err) callback(err);
|
|
||||||
// // callback(null, result);
|
|
||||||
// // });
|
|
||||||
// // });
|
|
||||||
// // },
|
|
||||||
|
|
||||||
// // ], function(err, result) {
|
|
||||||
// // if(err) done(err);
|
|
||||||
|
|
||||||
// // should.exist(result);
|
|
||||||
// // console.log(result.return);
|
|
||||||
|
|
||||||
// // done();
|
|
||||||
// // });
|
|
||||||
// // });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// describe('Method Find', function(){
|
|
||||||
// beforeEach(function(done){
|
|
||||||
// mySubmission.save(function(err) {
|
|
||||||
// done();
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// it('should be able to findOne FormSubmission without problems', function(done) {
|
|
||||||
// return FormSubmission.findOne({_id: mySubmission._id}).exec(function(err,submission) {
|
|
||||||
// should.not.exist(err);
|
// should.not.exist(err);
|
||||||
// should.exist(submission);
|
// (form.form_fields).should.be.eql(old_fields, 'old form_fields not equal to newly saved form_fields');
|
||||||
// should.deepEqual(submission.toObject(), mySubmission.toObject());
|
|
||||||
// done();
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should be able to find FormSubmission by $elemMatch on form_fields id', function(done){
|
// //Remove submission
|
||||||
// return FormSubmission.findOne({ form: myForm._id, admin: user, form_fields: {$elemMatch: {_id: myForm.form_fields[0]._id} } })
|
// mySubmission.remove(function(err){
|
||||||
// .exec(function(err, submission){
|
// myForm.submissions.should.have.length(0);
|
||||||
// should.not.exist(err);
|
// myForm.form_fields.should.not.containDeep(old_fields[0]);
|
||||||
// should.exist(submission);
|
|
||||||
// should.deepEqual(submission.toObject(), mySubmission.toObject());
|
|
||||||
// done();
|
|
||||||
// });
|
// });
|
||||||
// });
|
// });
|
||||||
// });
|
// });
|
||||||
|
|
||||||
// describe('Test FormField and Submission Logic', function() {
|
|
||||||
// var new_form_fields_add1, new_form_fields_del;
|
|
||||||
|
|
||||||
// beforeEach(function(done){
|
afterEach(function(done){
|
||||||
// new_form_fields_add1 = _.clone(myForm.toObject().form_fields);
|
mySubmission.remove(function(){
|
||||||
// new_form_fields_add1.push(
|
done();
|
||||||
// {'fieldType':'textfield', 'title':'Last Name', 'fieldValue': ''}
|
});
|
||||||
// );
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// //Create Submission
|
afterEach(function(done) {
|
||||||
|
Form.remove().exec(function() {
|
||||||
// mySubmission = new FormSubmission({
|
User.remove().exec(function() {
|
||||||
// form_fields: sampleSubmission,
|
FormSubmission.remove().exec(done);
|
||||||
// admin: user,
|
});
|
||||||
// form: myForm,
|
});
|
||||||
// timeElapsed: 17.55
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
// mySubmission.save(function(err){
|
|
||||||
// should.not.exist(err);
|
|
||||||
// done();
|
|
||||||
// });
|
|
||||||
|
|
||||||
// });
|
|
||||||
|
|
||||||
// // it('should preserve deleted form_fields that have submissions without any problems', function(done) {
|
|
||||||
|
|
||||||
// // var old_fields = myForm.toObject().form_fields;
|
|
||||||
// // var new_form_fields = _.clone(myForm.toObject().form_fields);
|
|
||||||
// // new_form_fields.splice(0, 1);
|
|
||||||
|
|
||||||
// // myForm.form_fields = new_form_fields;
|
|
||||||
|
|
||||||
// // myForm.save(function(err, _form) {
|
|
||||||
|
|
||||||
// // should.not.exist(err);
|
|
||||||
// // should.exist(_form);
|
|
||||||
|
|
||||||
// // // var actual_fields = _.map(_form.toObject().form_fields, function(o){ _.omit(o, '_id')});
|
|
||||||
// // // old_fields = _.map(old_fields, function(o){ _.omit(o, '_id')});
|
|
||||||
|
|
||||||
// // // console.log(old_fields);
|
|
||||||
// // should.deepEqual(JSON.stringify(_form.toObject().form_fields), JSON.stringify(old_fields), 'old form_fields not equal to newly saved form_fields');
|
|
||||||
// // done();
|
|
||||||
// // });
|
|
||||||
// // });
|
|
||||||
|
|
||||||
|
|
||||||
// // it('should delete \'preserved\' form_fields whose submissions have been removed without any problems', function(done) {
|
|
||||||
|
|
||||||
// // myForm.form_fields = new_form_fields_del;
|
|
||||||
// // myForm.save(function(err, form
|
|
||||||
// // should.not.exist(err);
|
|
||||||
// // (form.form_fields).should.be.eql(old_fields, 'old form_fields not equal to newly saved form_fields');
|
|
||||||
|
|
||||||
// // //Remove submission
|
|
||||||
// // mySubmission.remove(function(err){
|
|
||||||
// // myForm.submissions.should.have.length(0);
|
|
||||||
// // myForm.form_fields.should.not.containDeep(old_fields[0]);
|
|
||||||
// // });
|
|
||||||
// // });
|
|
||||||
// // });
|
|
||||||
|
|
||||||
|
|
||||||
// afterEach(function(done){
|
|
||||||
// mySubmission.remove(function(){
|
|
||||||
// done();
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// afterEach(function(done) {
|
|
||||||
// Form.remove().exec(function() {
|
|
||||||
// User.remove().exec(function() {
|
|
||||||
// FormSubmission.remove().exec(done);
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
|
@ -1,219 +1,217 @@
|
||||||
// 'use strict';
|
'use strict';
|
||||||
|
|
||||||
// var should = require('should'),
|
var should = require('should'),
|
||||||
// _ = require('lodash'),
|
_ = require('lodash'),
|
||||||
// app = require('../../server'),
|
app = require('../../server'),
|
||||||
// request = require('supertest'),
|
request = require('supertest'),
|
||||||
// Session = require('supertest-session')({
|
Session = require('supertest-session'),
|
||||||
// app: app
|
mongoose = require('mongoose'),
|
||||||
// }),
|
User = mongoose.model('User'),
|
||||||
// mongoose = require('mongoose'),
|
Form = mongoose.model('Form'),
|
||||||
// User = mongoose.model('User'),
|
Field = mongoose.model('Field'),
|
||||||
// Form = mongoose.model('Form'),
|
FormSubmission = mongoose.model('FormSubmission'),
|
||||||
// Field = mongoose.model('Field'),
|
agent = request.agent(app);
|
||||||
// FormSubmission = mongoose.model('FormSubmission'),
|
|
||||||
// agent = request.agent(app);
|
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Globals
|
* Globals
|
||||||
// */
|
*/
|
||||||
// var credentials, user, userSession;
|
var credentials, user, userSession;
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Form routes tests
|
* Form routes tests
|
||||||
// */
|
*/
|
||||||
// describe('Form Routes Unit tests', function() {
|
describe('Form Routes Unit tests', function() {
|
||||||
// var FormObj, _Submission, submissionSession;
|
var FormObj, _Submission, submissionSession;
|
||||||
// beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
|
|
||||||
// //Initialize Session
|
//Initialize Session
|
||||||
// userSession = new Session();
|
userSession = new Session();
|
||||||
|
|
||||||
// // Create user credentials
|
// Create user credentials
|
||||||
// credentials = {
|
credentials = {
|
||||||
// username: 'test@test.com',
|
username: 'test@test.com',
|
||||||
// password: 'password'
|
password: 'password'
|
||||||
// };
|
};
|
||||||
|
|
||||||
// // Create a new user
|
// Create a new user
|
||||||
// user = new User({
|
user = new User({
|
||||||
// firstName: 'Full',
|
firstName: 'Full',
|
||||||
// lastName: 'Name',
|
lastName: 'Name',
|
||||||
// email: 'test@test.com',
|
email: 'test@test.com',
|
||||||
// username: credentials.username,
|
username: credentials.username,
|
||||||
// password: credentials.password,
|
password: credentials.password,
|
||||||
// provider: 'local'
|
provider: 'local'
|
||||||
// });
|
});
|
||||||
|
|
||||||
// // Save a user to the test db and create new Form
|
// Save a user to the test db and create new Form
|
||||||
// user.save(function(err) {
|
user.save(function(err) {
|
||||||
// if(err) return done(err);
|
if(err) return done(err);
|
||||||
// FormObj = {
|
FormObj = {
|
||||||
// title: 'Form Title',
|
title: 'Form Title',
|
||||||
// language: 'english',
|
language: 'english',
|
||||||
// admin: user._id,
|
admin: user._id,
|
||||||
// form_fields: [
|
form_fields: [
|
||||||
// new Field({'fieldType':'textfield', 'title':'First Name', 'fieldValue': ''}),
|
new Field({'fieldType':'textfield', 'title':'First Name', 'fieldValue': ''}),
|
||||||
// new Field({'fieldType':'checkbox', 'title':'nascar', 'fieldValue': ''}),
|
new Field({'fieldType':'checkbox', 'title':'nascar', 'fieldValue': ''}),
|
||||||
// new Field({'fieldType':'checkbox', 'title':'hockey', 'fieldValue': ''})
|
new Field({'fieldType':'checkbox', 'title':'hockey', 'fieldValue': ''})
|
||||||
// ]
|
]
|
||||||
// };
|
};
|
||||||
|
|
||||||
// FormObj.save(function(err, form) {
|
FormObj.save(function(err, form) {
|
||||||
// if (err) done(err);
|
if (err) done(err);
|
||||||
|
|
||||||
// _Submission = {
|
_Submission = {
|
||||||
// form_fields: [
|
form_fields: [
|
||||||
// {'fieldType':'textfield', 'title':'First Name', 'fieldValue': 'David'},
|
{'fieldType':'textfield', 'title':'First Name', 'fieldValue': 'David'},
|
||||||
// {'fieldType':'checkbox', 'title':'nascar', 'fieldValue': true},
|
{'fieldType':'checkbox', 'title':'nascar', 'fieldValue': true},
|
||||||
// {'fieldType':'checkbox', 'title':'hockey', 'fieldValue': false}
|
{'fieldType':'checkbox', 'title':'hockey', 'fieldValue': false}
|
||||||
// ],
|
],
|
||||||
// form: form._id,
|
form: form._id,
|
||||||
// admin: user._id,
|
admin: user._id,
|
||||||
// percentageComplete: 100,
|
percentageComplete: 100,
|
||||||
// timeElapsed: 11.55
|
timeElapsed: 11.55
|
||||||
// };
|
};
|
||||||
|
|
||||||
// FormObj = form;
|
FormObj = form;
|
||||||
|
|
||||||
// //Setup test session
|
//Setup test session
|
||||||
// submissionSession = new Session();
|
submissionSession = new Session();
|
||||||
|
|
||||||
// done();
|
done();
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
|
|
||||||
// it(' > should be able to create a Form Submission without signing in', function(done) {
|
it(' > should be able to create a Form Submission without signing in', function(done) {
|
||||||
|
|
||||||
// //Create Submission
|
//Create Submission
|
||||||
// submissionSession.post('/forms/' + FormObj._id)
|
submissionSession.post('/forms/' + FormObj._id)
|
||||||
// .send(_Submission)
|
.send(_Submission)
|
||||||
// .expect(200)
|
.expect(200)
|
||||||
// .end(function(err, res) {
|
.end(function(err, res) {
|
||||||
|
|
||||||
// should.not.exist(err);
|
should.not.exist(err);
|
||||||
|
|
||||||
// done();
|
done();
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
// it(' > should be able to get Form Submissions if signed in', function(done) {
|
it(' > should be able to get Form Submissions if signed in', function(done) {
|
||||||
// submissionSession.post('/auth/signin')
|
submissionSession.post('/auth/signin')
|
||||||
// .send(credentials)
|
.send(credentials)
|
||||||
// .expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
// .expect(200)
|
.expect(200)
|
||||||
// .end(function(signinErr, signinRes) {
|
.end(function(signinErr, signinRes) {
|
||||||
|
|
||||||
// should.not.exist(signinErr);
|
should.not.exist(signinErr);
|
||||||
|
|
||||||
// //Create Submission
|
//Create Submission
|
||||||
// submissionSession.post('/forms/' + FormObj._id)
|
submissionSession.post('/forms/' + FormObj._id)
|
||||||
// .send(_Submission)
|
.send(_Submission)
|
||||||
// .expect(200)
|
.expect(200)
|
||||||
// .end(function(err, res) {
|
.end(function(err, res) {
|
||||||
|
|
||||||
// should.not.exist(err);
|
should.not.exist(err);
|
||||||
|
|
||||||
// submissionSession.get('/forms/' + FormObj._id + '/submissions')
|
submissionSession.get('/forms/' + FormObj._id + '/submissions')
|
||||||
// .expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
// .expect(200)
|
.expect(200)
|
||||||
// .end(function(err, res) {
|
.end(function(err, res) {
|
||||||
|
|
||||||
// // Set assertion
|
// Set assertion
|
||||||
// should.not.exist(err);
|
should.not.exist(err);
|
||||||
|
|
||||||
// // Call the assertion callback
|
// Call the assertion callback
|
||||||
// done();
|
done();
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
// it(' > should not be able to get Form Submissions if not signed in', function(done) {
|
it(' > should not be able to get Form Submissions if not signed in', function(done) {
|
||||||
// // Attempt to fetch form submissions
|
// Attempt to fetch form submissions
|
||||||
// submissionSession.get('/forms/' + FormObj._id + '/submissions')
|
submissionSession.get('/forms/' + FormObj._id + '/submissions')
|
||||||
// .expect(401)
|
.expect(401)
|
||||||
// .end(function(err, res) {
|
.end(function(err, res) {
|
||||||
|
|
||||||
// // Set assertions
|
// Set assertions
|
||||||
// (res.body.message).should.equal('User is not logged in');
|
(res.body.message).should.equal('User is not logged in');
|
||||||
|
|
||||||
// // Call the assertion callback
|
// Call the assertion callback
|
||||||
// done();
|
done();
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
// it(' > should not be able to delete Form Submission if not signed in', function(done) {
|
it(' > should not be able to delete Form Submission if not signed in', function(done) {
|
||||||
// var SubmissionObj = new FormSubmission(_Submission);
|
var SubmissionObj = new FormSubmission(_Submission);
|
||||||
|
|
||||||
// SubmissionObj.save(function (err, submission) {
|
SubmissionObj.save(function (err, submission) {
|
||||||
// should.not.exist(err);
|
should.not.exist(err);
|
||||||
|
|
||||||
// var submission_ids = _.pluck([submission], '_id');
|
var submission_ids = _.pluck([submission], '_id');
|
||||||
|
|
||||||
// // Attempt to delete form submissions
|
// Attempt to delete form submissions
|
||||||
// submissionSession.delete('/forms/' + FormObj._id + '/submissions')
|
submissionSession.delete('/forms/' + FormObj._id + '/submissions')
|
||||||
// .send({deleted_submissions: submission_ids})
|
.send({deleted_submissions: submission_ids})
|
||||||
// .expect(401)
|
.expect(401)
|
||||||
// .end(function(err, res) {
|
.end(function(err, res) {
|
||||||
|
|
||||||
// // Set assertions
|
// Set assertions
|
||||||
// should.not.exist(err);
|
should.not.exist(err);
|
||||||
// (res.body.message).should.equal('User is not logged in');
|
(res.body.message).should.equal('User is not logged in');
|
||||||
|
|
||||||
// // Call the assertion callback
|
// Call the assertion callback
|
||||||
// done();
|
done();
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
// it(' > should be able to delete Form Submission if signed in', function(done) {
|
it(' > should be able to delete Form Submission if signed in', function(done) {
|
||||||
// // Create new FormSubmission model instance
|
// Create new FormSubmission model instance
|
||||||
// var SubmissionObj = new FormSubmission(_Submission);
|
var SubmissionObj = new FormSubmission(_Submission);
|
||||||
|
|
||||||
// SubmissionObj.save(function (err, submission) {
|
SubmissionObj.save(function (err, submission) {
|
||||||
// should.not.exist(err);
|
should.not.exist(err);
|
||||||
|
|
||||||
// // Signin as user
|
// Signin as user
|
||||||
// submissionSession.post('/auth/signin')
|
submissionSession.post('/auth/signin')
|
||||||
// .send(credentials)
|
.send(credentials)
|
||||||
// .expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
// .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);
|
||||||
|
|
||||||
// var submission_ids = _.pluck([submission], '_id');
|
var submission_ids = _.pluck([submission], '_id');
|
||||||
|
|
||||||
// //Delete form submissions
|
//Delete form submissions
|
||||||
// submissionSession.delete('/forms/' + FormObj._id + '/submissions')
|
submissionSession.delete('/forms/' + FormObj._id + '/submissions')
|
||||||
// .send({deleted_submissions: submission_ids})
|
.send({deleted_submissions: submission_ids})
|
||||||
// .expect(200)
|
.expect(200)
|
||||||
// .end(function(err, res) {
|
.end(function(err, res) {
|
||||||
|
|
||||||
// // Set assertions
|
// Set assertions
|
||||||
// should.not.exist(err);
|
should.not.exist(err);
|
||||||
// (res.text).should.equal('Form submissions successfully deleted');
|
(res.text).should.equal('Form submissions successfully deleted');
|
||||||
|
|
||||||
// // Call the assertion callback
|
// Call the assertion callback
|
||||||
// done();
|
done();
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
// afterEach(function(done) {//logout current user if there is one
|
afterEach(function(done) {//logout current user if there is one
|
||||||
// FormSubmission.remove().exec(function() {
|
FormSubmission.remove().exec(function() {
|
||||||
// Form.remove().exec(function (err) {
|
Form.remove().exec(function (err) {
|
||||||
// User.remove({}).exec(function() {
|
User.remove({}).exec(function() {
|
||||||
// submissionSession.destroy();
|
submissionSession.destroy();
|
||||||
// done();
|
done();
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
|
|
||||||
// });
|
});
|
||||||
|
|
|
@ -1,90 +1,90 @@
|
||||||
// 'use strict';
|
'use strict';
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Module dependencies.
|
* Module dependencies.
|
||||||
// */
|
*/
|
||||||
// var should = require('should'),
|
var should = require('should'),
|
||||||
// mongoose = require('mongoose'),
|
mongoose = require('mongoose'),
|
||||||
// User = mongoose.model('User');
|
User = mongoose.model('User');
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Globals
|
* Globals
|
||||||
// */
|
*/
|
||||||
// var user, user2;
|
var user, user2;
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Unit tests
|
* Unit tests
|
||||||
// */
|
*/
|
||||||
// describe('User Model Unit Tests:', function() {
|
describe('User Model Unit Tests:', function() {
|
||||||
// beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
// user = new User({
|
user = new User({
|
||||||
// firstName: 'Full',
|
firstName: 'Full',
|
||||||
// lastName: 'Name',
|
lastName: 'Name',
|
||||||
// email: 'test@test.com',
|
email: 'test@test.com',
|
||||||
// username: 'test@test.com',
|
username: 'test@test.com',
|
||||||
// password: 'password',
|
password: 'password',
|
||||||
// provider: 'local'
|
provider: 'local'
|
||||||
// });
|
});
|
||||||
// user2 = new User({
|
user2 = new User({
|
||||||
// firstName: 'Full',
|
firstName: 'Full',
|
||||||
// lastName: 'Name',
|
lastName: 'Name',
|
||||||
// email: 'test@test.com',
|
email: 'test@test.com',
|
||||||
// username: 'test@test.com',
|
username: 'test@test.com',
|
||||||
// password: 'password',
|
password: 'password',
|
||||||
// provider: 'local'
|
provider: 'local'
|
||||||
// });
|
});
|
||||||
|
|
||||||
// done();
|
done();
|
||||||
// });
|
});
|
||||||
|
|
||||||
// describe('Method Save', function() {
|
describe('Method Save', function() {
|
||||||
// it('should begin with no users', function(done) {
|
it('should begin with no users', function(done) {
|
||||||
// User.find({}, function(err, users) {
|
User.find({}, function(err, users) {
|
||||||
// users.should.have.length(0);
|
users.should.have.length(0);
|
||||||
// done();
|
done();
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
// it('should be able to save without problems', function(done) {
|
it('should be able to save without problems', function(done) {
|
||||||
// user.save(done);
|
user.save(done);
|
||||||
// });
|
});
|
||||||
|
|
||||||
// it('should fail to save an existing user again', function(done) {
|
it('should fail to save an existing user again', function(done) {
|
||||||
// user.save(function() {
|
user.save(function() {
|
||||||
// user2.save(function(err) {
|
user2.save(function(err) {
|
||||||
// should.exist(err);
|
should.exist(err);
|
||||||
// done();
|
done();
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
// it('should be able to show an error when try to save without first name', function(done) {
|
it('should be able to show an error when try to save without first name', function(done) {
|
||||||
// user.firstName = '';
|
user.firstName = '';
|
||||||
// return user.save(function(err) {
|
return user.save(function(err) {
|
||||||
// should.exist(err);
|
should.exist(err);
|
||||||
// done();
|
done();
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
// describe('Method findUniqueUsername', function() {
|
describe('Method findUniqueUsername', function() {
|
||||||
// beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
// User.find({}, function(err, users) {
|
User.find({}, function(err, users) {
|
||||||
// users.should.have.length(0);
|
users.should.have.length(0);
|
||||||
// user.save(done);
|
user.save(done);
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
// it('should be able to find unique version of existing username without problems', function(done) {
|
it('should be able to find unique version of existing username without problems', function(done) {
|
||||||
// User.findUniqueUsername(user.username, null, function (availableUsername) {
|
User.findUniqueUsername(user.username, null, function (availableUsername) {
|
||||||
// availableUsername.should.not.equal(user.username);
|
availableUsername.should.not.equal(user.username);
|
||||||
// done();
|
done();
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
// });
|
});
|
||||||
|
|
||||||
// afterEach(function(done) {
|
afterEach(function(done) {
|
||||||
// User.remove().exec(done);
|
User.remove().exec(done);
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
|
@ -1,184 +1,182 @@
|
||||||
// 'use strict';
|
'use strict';
|
||||||
|
|
||||||
// var should = require('should'),
|
var should = require('should'),
|
||||||
// _ = require('lodash'),
|
_ = require('lodash'),
|
||||||
// app = require('../../server'),
|
app = require('../../server'),
|
||||||
// request = require('supertest'),
|
request = require('supertest'),
|
||||||
// Session = require('supertest-session')({
|
Session = require('supertest-session'),
|
||||||
// app: app
|
mongoose = require('mongoose'),
|
||||||
// }),
|
User = mongoose.model('User'),
|
||||||
// mongoose = require('mongoose'),
|
config = require('../../config/config'),
|
||||||
// User = mongoose.model('User'),
|
tmpUser = mongoose.model(config.tempUserCollection),
|
||||||
// config = require('../../config/config'),
|
agent = request.agent(app),
|
||||||
// tmpUser = mongoose.model(config.tempUserCollection),
|
url = require('url');
|
||||||
// agent = request.agent(app),
|
|
||||||
// url = require('url');
|
|
||||||
|
|
||||||
// var mailosaur = require('mailosaur')(config.mailosaur.key),
|
var mailosaur = require('mailosaur')(config.mailosaur.key),
|
||||||
// mailbox = new mailosaur.Mailbox(config.mailosaur.mailbox_id);
|
mailbox = new mailosaur.Mailbox(config.mailosaur.mailbox_id);
|
||||||
|
|
||||||
// var mandrill = require('node-mandrill')(config.mailer.options.auth.pass);
|
var mandrill = require('node-mandrill')(config.mailer.options.auth.pass);
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Globals
|
* Globals
|
||||||
// */
|
*/
|
||||||
// var credentials, _User, _Session;
|
var credentials, _User, _Session;
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Form routes tests
|
* Form routes tests
|
||||||
// */
|
*/
|
||||||
// describe('User CRUD tests', function() {
|
describe('User CRUD tests', function() {
|
||||||
// this.timeout(15000);
|
this.timeout(15000);
|
||||||
// var userSession;
|
var userSession;
|
||||||
|
|
||||||
// beforeEach(function() {
|
beforeEach(function() {
|
||||||
// //Initialize Session
|
//Initialize Session
|
||||||
// userSession = new Session();
|
userSession = new Session();
|
||||||
|
|
||||||
// // Create user credentials
|
// Create user credentials
|
||||||
// credentials = {
|
credentials = {
|
||||||
// username: 'be1e58fb@mailosaur.in',
|
username: 'be1e58fb@mailosaur.in',
|
||||||
// password: 'password'
|
password: 'password'
|
||||||
// };
|
};
|
||||||
|
|
||||||
// //Create a new user
|
//Create a new user
|
||||||
// _User = {
|
_User = {
|
||||||
// firstName: 'Full',
|
firstName: 'Full',
|
||||||
// lastName: 'Name',
|
lastName: 'Name',
|
||||||
// email: credentials.username,
|
email: credentials.username,
|
||||||
// username: credentials.username,
|
username: credentials.username,
|
||||||
// password: credentials.password,
|
password: credentials.password,
|
||||||
// provider: 'local'
|
provider: 'local'
|
||||||
// };
|
};
|
||||||
// });
|
});
|
||||||
|
|
||||||
// describe(' > Create, Verify and Activate a User > ', function() {
|
describe(' > Create, Verify and Activate a User > ', function() {
|
||||||
// var username = 'testActiveAccount1.be1e58fb@mailosaur.in';
|
var username = 'testActiveAccount1.be1e58fb@mailosaur.in';
|
||||||
// var link, _tmpUser, activateToken;
|
var link, _tmpUser, activateToken;
|
||||||
// this.timeout(15000);
|
this.timeout(15000);
|
||||||
|
|
||||||
// it('should be able to create a temporary (non-activated) User', function(done) {
|
it('should be able to create a temporary (non-activated) User', function(done) {
|
||||||
// _User.email = _User.username = username;
|
_User.email = _User.username = username;
|
||||||
// userSession.post('/auth/signup')
|
userSession.post('/auth/signup')
|
||||||
// .send(_User)
|
.send(_User)
|
||||||
// .expect(200, 'An email has been sent to you. Please check it to verify your account.')
|
.expect(200, 'An email has been sent to you. Please check it to verify your account.')
|
||||||
// .end(function(FormSaveErr, FormSaveRes) {
|
.end(function(FormSaveErr, FormSaveRes) {
|
||||||
// // Handle error
|
// Handle error
|
||||||
// if (FormSaveErr) return done(FormSaveErr);
|
if (FormSaveErr) return done(FormSaveErr);
|
||||||
|
|
||||||
// tmpUser.findOne({username: _User.username}, function (err, user) {
|
tmpUser.findOne({username: _User.username}, function (err, user) {
|
||||||
// should.not.exist(err);
|
should.not.exist(err);
|
||||||
// should.exist(user);
|
should.exist(user);
|
||||||
// _tmpUser = user;
|
_tmpUser = user;
|
||||||
|
|
||||||
// _User.username.should.equal(user.username);
|
_User.username.should.equal(user.username);
|
||||||
// _User.firstName.should.equal(user.firstName);
|
_User.firstName.should.equal(user.firstName);
|
||||||
// _User.lastName.should.equal(user.lastName);
|
_User.lastName.should.equal(user.lastName);
|
||||||
// activateToken = user.GENERATED_VERIFYING_URL;
|
activateToken = user.GENERATED_VERIFYING_URL;
|
||||||
|
|
||||||
// done();
|
done();
|
||||||
// });
|
});
|
||||||
|
|
||||||
// // // mandrill('/messages/search', {
|
// // mandrill('/messages/search', {
|
||||||
// // // query: "subject:Confirm",
|
// // query: "subject:Confirm",
|
||||||
// // // senders: [
|
// // senders: [
|
||||||
// // // "test@forms.polydaic.com"
|
// // "test@forms.polydaic.com"
|
||||||
// // // ],
|
// // ],
|
||||||
// // // limit: 1
|
// // limit: 1
|
||||||
// // // }, function(error, emails) {
|
// // }, function(error, emails) {
|
||||||
// // // if (error) console.log( JSON.stringify(error) );
|
// // if (error) console.log( JSON.stringify(error) );
|
||||||
|
|
||||||
// // // var confirmation_email = emails[0];
|
// // var confirmation_email = emails[0];
|
||||||
|
|
||||||
// // // mandrill('/messages/content', {
|
// // mandrill('/messages/content', {
|
||||||
// // // id: confirmation_email._id
|
// // id: confirmation_email._id
|
||||||
// // // }, function(error, email) {
|
// // }, function(error, email) {
|
||||||
// // // if (error) console.log( JSON.stringify(error) );
|
// // if (error) console.log( JSON.stringify(error) );
|
||||||
|
|
||||||
// // // // console.log(email);
|
// // // console.log(email);
|
||||||
// // // var link = _(email.text.split('\n')).reverse().value()[1];
|
// // var link = _(email.text.split('\n')).reverse().value()[1];
|
||||||
// // // console.log(link);
|
// // console.log(link);
|
||||||
// // // activateToken = _(url.parse(link).hash.split('/')).reverse().value()[0];
|
// // activateToken = _(url.parse(link).hash.split('/')).reverse().value()[0];
|
||||||
// // // console.log('actual activateToken: '+ activateToken);
|
// // console.log('actual activateToken: '+ activateToken);
|
||||||
// // // console.log('expected activateToken: ' + user.GENERATED_VERIFYING_URL);
|
// // console.log('expected activateToken: ' + user.GENERATED_VERIFYING_URL);
|
||||||
|
|
||||||
// // // done();
|
// // done();
|
||||||
|
|
||||||
// // // });
|
// // });
|
||||||
// // // });
|
// // });
|
||||||
|
|
||||||
// // // mailbox.getEmails(function(err, _emails) {
|
// // mailbox.getEmails(function(err, _emails) {
|
||||||
// // // if(err) done(err);
|
// // if(err) done(err);
|
||||||
|
|
||||||
// // // var emails = _emails;
|
// // var emails = _emails;
|
||||||
|
|
||||||
// // // console.log('mailbox.getEmails:');
|
// // console.log('mailbox.getEmails:');
|
||||||
// // // console.log(emails[0].text.links);
|
// // console.log(emails[0].text.links);
|
||||||
|
|
||||||
// // // var link = emails[0].text.links[0].href;
|
// // var link = emails[0].text.links[0].href;
|
||||||
// // // activateToken = _(url.parse(link).hash.split('/')).reverse().value()[0];
|
// // activateToken = _(url.parse(link).hash.split('/')).reverse().value()[0];
|
||||||
// // // console.log('actual activateToken: '+ activateToken);
|
// // console.log('actual activateToken: '+ activateToken);
|
||||||
// // // console.log('expected activateToken: ' + user.GENERATED_VERIFYING_URL);
|
// // console.log('expected activateToken: ' + user.GENERATED_VERIFYING_URL);
|
||||||
// // // (activateToken).should.equal(user.GENERATED_VERIFYING_URL);
|
// // (activateToken).should.equal(user.GENERATED_VERIFYING_URL);
|
||||||
|
|
||||||
// // // done();
|
// // done();
|
||||||
// // // });
|
|
||||||
// // });
|
// // });
|
||||||
// });
|
// });
|
||||||
// });
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// it('should be able to verify a User Account', function(done) {
|
it('should be able to verify a User Account', function(done) {
|
||||||
// console.log('activateToken: '+activateToken);
|
console.log('activateToken: '+activateToken);
|
||||||
// userSession.get('/auth/verify/'+activateToken)
|
userSession.get('/auth/verify/'+activateToken)
|
||||||
// .expect(200)
|
.expect(200)
|
||||||
// .end(function(VerifyErr, VerifyRes) {
|
.end(function(VerifyErr, VerifyRes) {
|
||||||
// // Handle error
|
// Handle error
|
||||||
// if (VerifyErr) return done(VerifyErr);
|
if (VerifyErr) return done(VerifyErr);
|
||||||
// (VerifyRes.text).should.equal('User successfully verified');
|
(VerifyRes.text).should.equal('User successfully verified');
|
||||||
// done();
|
done();
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
// it('should be able to login and logout a verified User Account', function(done) {
|
it('should be able to login and logout a verified User Account', function(done) {
|
||||||
// userSession.post('/auth/signin')
|
userSession.post('/auth/signin')
|
||||||
// .send(credentials)
|
.send(credentials)
|
||||||
// .expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
// .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);
|
||||||
|
|
||||||
// var user = signinRes.body;
|
var user = signinRes.body;
|
||||||
// (user.username).should.equal(credentials.username);
|
(user.username).should.equal(credentials.username);
|
||||||
|
|
||||||
// userSession.get('/auth/signout')
|
userSession.get('/auth/signout')
|
||||||
// .expect(200)
|
.expect(200)
|
||||||
// .end(function(signoutErr, signoutRes) {
|
.end(function(signoutErr, signoutRes) {
|
||||||
|
|
||||||
// // Handle signout error
|
// Handle signout error
|
||||||
// if (signoutErr) return done(signoutErr);
|
if (signoutErr) return done(signoutErr);
|
||||||
|
|
||||||
// (signoutRes.text).should.equal('Successfully logged out');
|
(signoutRes.text).should.equal('Successfully logged out');
|
||||||
|
|
||||||
// done();
|
done();
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
// it(' > should be able to reset a User\'s password');
|
it(' > should be able to reset a User\'s password');
|
||||||
|
|
||||||
// it(' > should be able to delete a User account without any problems');
|
it(' > should be able to delete a User account without any problems');
|
||||||
|
|
||||||
// afterEach(function(done) {
|
afterEach(function(done) {
|
||||||
// User.remove().exec(function () {
|
User.remove().exec(function () {
|
||||||
// tmpUser.remove().exec(function(){
|
tmpUser.remove().exec(function(){
|
||||||
// // mailbox.deleteAllEmail(function (err, body) {
|
// mailbox.deleteAllEmail(function (err, body) {
|
||||||
// // if(err) throw err;
|
// if(err) throw err;
|
||||||
// userSession.destroy();
|
userSession.destroy();
|
||||||
// done();
|
done();
|
||||||
// // });
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// });
|
// });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue