got oscarhost API to work
This commit is contained in:
parent
6a9b8ee8a8
commit
e64729851f
@ -18,13 +18,14 @@ var _ = require('lodash'),
|
||||
var smtpTransport = nodemailer.createTransport(config.mailer.options);
|
||||
|
||||
exports.validateVerificationToken = function(req, res, next){
|
||||
|
||||
console.log('validateVerificationToken');
|
||||
console.log('token: '+req.params.token+'\n\n');
|
||||
nev.confirmTempUser(req.params.token, function(user) {
|
||||
if (user){
|
||||
res.status(200).send('User successfully verified');
|
||||
}else {
|
||||
// redirect to resend verification email
|
||||
return res.status(400).send('Verification token is invalid or has expired');
|
||||
res.status(400).send( {message: 'Verification token is invalid or has expired'} );
|
||||
}
|
||||
});
|
||||
};
|
||||
@ -35,7 +36,7 @@ exports.resendVerificationEmail = function(req, res, next){
|
||||
res.status(200).send('Verification email successfully Re-Sent');
|
||||
}else {
|
||||
// user hasn't been found yet
|
||||
return res.status(400).send( {message: 'Error: Verification Email could NOT be sent'} );
|
||||
res.status(400).send( {message: 'Error: Verification Email could NOT be sent'} );
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@ -45,13 +45,6 @@ var ButtonSchema = new Schema({
|
||||
* Form Schema
|
||||
*/
|
||||
var FormSchema = new Schema({
|
||||
// created: {
|
||||
// type: Date,
|
||||
// default: Date.now
|
||||
// },
|
||||
// lastModified: {
|
||||
// type: Date,
|
||||
// },
|
||||
title: {
|
||||
type: String,
|
||||
trim: true,
|
||||
@ -67,10 +60,10 @@ var FormSchema = new Schema({
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
form_fields: [Field],
|
||||
//form_fields: {
|
||||
// type: [FieldSchema],
|
||||
//},
|
||||
// form_fields: [Field],
|
||||
form_fields: {
|
||||
type: [FieldSchema],
|
||||
},
|
||||
|
||||
submissions: [{
|
||||
type: Schema.Types.ObjectId,
|
||||
|
||||
@ -17,33 +17,29 @@ var mongoose = require('mongoose'),
|
||||
FieldSchema = require('./form_field.server.model.js'),
|
||||
OscarSecurity = require('../../scripts/oscarhost/OscarSecurity');
|
||||
|
||||
var newDemoTemplate = {
|
||||
"activeCount": 0,
|
||||
"address": "",
|
||||
"alias": "",
|
||||
"anonymous": "",
|
||||
"chartNo": "",
|
||||
"children":"",
|
||||
"citizenship":"",
|
||||
"city": "",
|
||||
"dateJoined": null,
|
||||
"dateOfBirth": "",
|
||||
"email": "",
|
||||
"firstName": "",
|
||||
"hin": 9146509343,
|
||||
"lastName": "",
|
||||
"lastUpdateDate": null,
|
||||
"monthOfBirth": "",
|
||||
"officialLanguage": "",
|
||||
"phone": "",
|
||||
"phone2": "",
|
||||
"providerNo": 0,
|
||||
"province": "",
|
||||
"sex": "",
|
||||
"spokenLanguage": "",
|
||||
"postal": "",
|
||||
"yearOfBirth": ""
|
||||
};
|
||||
var newDemoTemplate = {
|
||||
address: '880-9650 Velit. St.',
|
||||
city: '',
|
||||
dateOfBirth: '10',
|
||||
displayName: 'LITTLE, URIAH',
|
||||
email: '',
|
||||
firstName: 'Uriah F.',
|
||||
hin: '',
|
||||
lastName: 'Little',
|
||||
lastUpdateDate: Date.now(),
|
||||
monthOfBirth: '05',
|
||||
officialLanguage: 'English',
|
||||
phone: '250-',
|
||||
phone2: '',
|
||||
postal: "S4M 7T8",
|
||||
province: 'BC',
|
||||
sex: 'F',
|
||||
sexDesc: 'Female',
|
||||
sin: '',
|
||||
spokenLanguage: 'English',
|
||||
title: 'MS.',
|
||||
yearOfBirth: '2015'
|
||||
};
|
||||
|
||||
/**
|
||||
* Form Submission Schema
|
||||
@ -107,6 +103,8 @@ FormSubmissionSchema.plugin(mUtilities.timestamp, {
|
||||
useVirtual: false
|
||||
});
|
||||
|
||||
|
||||
|
||||
//Oscarhost API hook
|
||||
FormSubmissionSchema.pre('save', function (next) {
|
||||
|
||||
@ -115,10 +113,10 @@ FormSubmissionSchema.pre('save', function (next) {
|
||||
var form_ids = _.map(_.pluck(_form.form_fields, '_id'), function(id){ return ''+id;}),
|
||||
submission_ids = _.pluck(self.form_fields, '_id');
|
||||
|
||||
console.log('Form form_field ids\n--------');
|
||||
console.log(form_ids);
|
||||
console.log('FormSubmission form_field ids\n--------');
|
||||
console.log(submission_ids);
|
||||
// console.log('Form form_field ids\n--------');
|
||||
// console.log(form_ids);
|
||||
// console.log('FormSubmission [form_field ids]\n--------');
|
||||
// console.log(submission_ids);
|
||||
|
||||
if(err) next(err);
|
||||
// console.log(_form);
|
||||
@ -137,36 +135,41 @@ FormSubmissionSchema.pre('save', function (next) {
|
||||
override: true
|
||||
}
|
||||
};
|
||||
console.log(self.form_fields);
|
||||
|
||||
//Generate demographics from hashmap
|
||||
var generateDemo = function(formFields, conversionMap, demographicsTemplate){
|
||||
var _generatedDemo = {};
|
||||
for(var field in formFields){
|
||||
if(demographicsTemplate.hasOwnProperty(conversionMap[field._id])){
|
||||
var propertyName = conversionMap[field._id];
|
||||
console.log('generating Demo fields');
|
||||
console.log(conversionMap);
|
||||
var _generatedDemo = {}, currField, propertyName;
|
||||
|
||||
if(propertyName === 'unparsedDOB'){
|
||||
var date = Date.parse(field.fieldValue);
|
||||
_generatedDemo['dateOfBirth'] = date.getDate();
|
||||
_generatedDemo['yearOfBirth'] = date.getFullYear();
|
||||
_generatedDemo['monthOfBirth'] = date.getMonth();
|
||||
}else{
|
||||
_generatedDemo[propertyName] = field.fieldValue;
|
||||
}
|
||||
for(var y=0; y<formFields.length; y++){
|
||||
currField = formFields[y];
|
||||
propertyName = conversionMap[currField._id];
|
||||
|
||||
if(demographicsTemplate.hasOwnProperty(conversionMap[currField._id])){
|
||||
_generatedDemo[propertyName] = currField.fieldValue+'';
|
||||
}else if(propertyName === 'unparsedDOB'){
|
||||
var date = new Date(currField.fieldValue);
|
||||
_generatedDemo['dateOfBirth'] = date.getDate()+'';
|
||||
_generatedDemo['yearOfBirth'] = date.getFullYear()+'';
|
||||
_generatedDemo['monthOfBirth'] = date.getMonth()+'';
|
||||
}
|
||||
}
|
||||
_generatedDemo['lastUpdateDate'] = Date.now();
|
||||
return _generatedDemo;
|
||||
};
|
||||
|
||||
|
||||
var submissionDemographic = generateDemo(self.form_fields, _form.plugins.oscarhost.settings.fieldMap, newDemoTemplate);
|
||||
|
||||
console.log(submissionDemographic);
|
||||
async.waterfall([
|
||||
function (callback) {
|
||||
//Authenticate with API
|
||||
soap.createClient(url_login, options, function(err, client) {
|
||||
client.login(args_login, function (err, result) {
|
||||
if(err) callback(err);
|
||||
console.log('SOAP authenticated');
|
||||
callback(null, result.return);
|
||||
});
|
||||
});
|
||||
@ -179,6 +182,8 @@ FormSubmissionSchema.pre('save', function (next) {
|
||||
client.setSecurity(new OscarSecurity(security_obj.securityId, security_obj.securityTokenKey) );
|
||||
|
||||
client.addDemographic({ arg0: submissionDemographic }, function (err, result) {
|
||||
console.log('FORCE ADDING DEMOGRAPHIC \n');
|
||||
// console.log(result.return);
|
||||
if(err) callback(err);
|
||||
callback(null, result);
|
||||
});
|
||||
@ -188,9 +193,9 @@ FormSubmissionSchema.pre('save', function (next) {
|
||||
|
||||
], function(err, result) {
|
||||
if(err) next(err);
|
||||
console.log(result);
|
||||
console.log('hello');
|
||||
this.oscarDemoNum = parseInt(result.return, 10);
|
||||
|
||||
self.oscarDemoNum = parseInt(result.return, 10);
|
||||
console.log('self.oscarDemoNum: '+self.oscarDemoNum);
|
||||
next();
|
||||
});
|
||||
}else{
|
||||
|
||||
@ -83,8 +83,7 @@ describe('Form Model Unit Tests:', function() {
|
||||
{'fieldType':'checkbox', title:'hockey', 'fieldValue': ''}
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -126,140 +125,6 @@ describe('Form Model Unit Tests:', function() {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('Test FormField and Submission Logic', function() {
|
||||
var new_form_fields_add1, new_form_fields_del, submission_fields, old_fields, form;
|
||||
|
||||
before(function(){
|
||||
new_form_fields_add1 = _.clone(myForm.toObject().form_fields);
|
||||
new_form_fields_add1.push(
|
||||
{'fieldType':'textfield', 'title':'Last Name', 'fieldValue': ''}
|
||||
);
|
||||
|
||||
new_form_fields_del = _.clone(myForm.toObject().form_fields);
|
||||
new_form_fields_del.splice(0, 1);
|
||||
|
||||
submission_fields = _.clone(myForm.toObject().form_fields);
|
||||
submission_fields[0].fieldValue = 'David';
|
||||
submission_fields[1].fieldValue = true;
|
||||
submission_fields[2].fieldValue = true;
|
||||
|
||||
mySubmission = new FormSubmission({
|
||||
form_fields: submission_fields,
|
||||
admin: user,
|
||||
form: myForm,
|
||||
timeElapsed: 17.55
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
beforeEach(function(done){
|
||||
myForm.save(function(){
|
||||
mySubmission.save(function(){
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function(done){
|
||||
mySubmission.remove(function(){
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
// it('should preserve deleted form_fields that have submissions without any problems', function(done) {
|
||||
|
||||
// old_fields = myForm.toObject().form_fields;
|
||||
// // console.log(old_fields);
|
||||
|
||||
// // var expected_fields = old_fields.slice(1,3).concat(old_fields.slice(0,1));
|
||||
|
||||
// myForm.form_fields = new_form_fields_del;
|
||||
|
||||
// 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]);
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
});
|
||||
|
||||
describe('Submission of Form should add Patient to OscarHost', function() {
|
||||
var mySubmission;
|
||||
before(function(done){
|
||||
myForm.form_fields = [
|
||||
new Field({'fieldType':'textfield', 'title':'What\'s your first name', 'fieldValue': ''}),
|
||||
new Field({'fieldType':'textfield', 'title':'And your last name', 'fieldValue': ''}),
|
||||
new Field({'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': ''}),
|
||||
new Field({'fieldType':'date', 'title':'When were you born?', 'fieldValue': ''}),
|
||||
new Field({'fieldType':'number', 'title':'What\'s your phone #?', 'fieldValue': ''}),
|
||||
];
|
||||
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] = 'unparsedDOB';
|
||||
myFieldMap[myForm.form_fields[4]._id] = 'phone';
|
||||
|
||||
myForm.plugins.oscarhost = {
|
||||
baseUrl: config.oscarhost.baseUrl,
|
||||
settings: {
|
||||
lookupField: '',
|
||||
updateType: 'force_add',
|
||||
fieldMap: myFieldMap,
|
||||
},
|
||||
auth: config.oscarhost.auth,
|
||||
};
|
||||
|
||||
myForm.save(function(err, form){
|
||||
if(err) done(err);
|
||||
|
||||
var submission_fields = _.clone(myForm.toObject().form_fields);
|
||||
submission_fields[0].fieldValue = 'David';
|
||||
submission_fields[1].fieldValue = 'Baldwynn'+Date.now();
|
||||
submission_fields[2].fieldValue = 'M';
|
||||
submission_fields[3].fieldValue = Date.now();
|
||||
submission_fields[4].fieldValue = 6043158008;
|
||||
|
||||
mySubmission = new FormSubmission({
|
||||
form_fields: submission_fields,
|
||||
admin: form.admin,
|
||||
form: form,
|
||||
timeElapsed: 17.55
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should be able to submit a valid form without problems', function(done) {
|
||||
mySubmission.save(function(err, submission) {
|
||||
should.not.exist(err);
|
||||
should.exist(submission.oscarDemoNum);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
afterEach(function(done) {
|
||||
Form.remove().exec(function() {
|
||||
User.remove().exec(done);
|
||||
|
||||
@ -1,504 +1,501 @@
|
||||
// 'use strict';
|
||||
|
||||
// var should = require('should'),
|
||||
// _ = require('lodash'),
|
||||
// app = require('../../server'),
|
||||
// request = require('supertest'),
|
||||
// Session = require('supertest-session')({
|
||||
// app: app
|
||||
// }),
|
||||
// mongoose = require('mongoose'),
|
||||
// User = mongoose.model('User'),
|
||||
// Form = mongoose.model('Form'),
|
||||
// Field = mongoose.model('Field'),
|
||||
// FormSubmission = mongoose.model('FormSubmission'),
|
||||
// agent = request.agent(app);
|
||||
|
||||
// /**
|
||||
// * Globals
|
||||
// */
|
||||
// var credentials, user, _Form, userSession;
|
||||
|
||||
// /**
|
||||
// * Form routes tests
|
||||
// */
|
||||
// describe('Form CRUD tests', function() {
|
||||
|
||||
// beforeEach(function(done) {
|
||||
|
||||
// //Initialize Session
|
||||
// userSession = new Session();
|
||||
|
||||
// // Create user credentials
|
||||
// credentials = {
|
||||
// username: 'test@test.com',
|
||||
// password: 'password'
|
||||
// };
|
||||
|
||||
// // Create a new user
|
||||
// user = new User({
|
||||
// firstName: 'Full',
|
||||
// lastName: 'Name',
|
||||
// email: 'test@test.com',
|
||||
// username: credentials.username,
|
||||
// password: credentials.password,
|
||||
// provider: 'local'
|
||||
// });
|
||||
|
||||
// // Save a user to the test db and create new Form
|
||||
// user.save(function(err) {
|
||||
// if(err) done(err);
|
||||
// _Form = {
|
||||
// title: 'Form Title',
|
||||
// language: 'english',
|
||||
// admin: user._id,
|
||||
// form_fields: [
|
||||
// new Field({'fieldType':'textfield', 'title':'First Name', 'fieldValue': ''}),
|
||||
// new Field({'fieldType':'checkbox', 'title':'nascar', 'fieldValue': ''}),
|
||||
// new Field({'fieldType':'checkbox', 'title':'hockey', 'fieldValue': ''})
|
||||
// ]
|
||||
// };
|
||||
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
|
||||
// it('should be able to save a Form if logged in', function(done) {
|
||||
// userSession.post('/auth/signin')
|
||||
// .send(credentials)
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200)
|
||||
// .end(function(signinErr, signinRes) {
|
||||
|
||||
// // Handle signin error
|
||||
// if (signinErr) done(signinErr);
|
||||
|
||||
// var user = signinRes.body;
|
||||
// var userId = user._id;
|
||||
|
||||
// // Save a new Form
|
||||
// userSession.post('/forms')
|
||||
// .send({form: _Form})
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200)
|
||||
// .end(function(FormSaveErr, FormSaveRes) {
|
||||
// // Handle Form save error
|
||||
// if (FormSaveErr) done(FormSaveErr);
|
||||
|
||||
// // Get a list of Forms
|
||||
// userSession.get('/forms')
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200)
|
||||
// .end(function(FormsGetErr, FormsGetRes) {
|
||||
// // Handle Form save error
|
||||
// if (FormsGetErr) done(FormsGetErr);
|
||||
|
||||
// // Get Forms list
|
||||
// var Forms = FormsGetRes.body;
|
||||
|
||||
// // Set assertions
|
||||
// (Forms[0].admin).should.equal(userId);
|
||||
// (Forms[0].title).should.match('Form Title');
|
||||
|
||||
// // Call the assertion callback
|
||||
// done();
|
||||
// });
|
||||
|
||||
// });
|
||||
|
||||
|
||||
// });
|
||||
// });
|
||||
|
||||
// it('should not be able to create a Form if not logged in', function(done) {
|
||||
// userSession.post('/forms')
|
||||
// .send({form: _Form})
|
||||
// .expect(401)
|
||||
// .end(function(FormSaveErr, FormSaveRes) {
|
||||
// (FormSaveRes.body.message).should.equal('User is not logged in');
|
||||
// // Call the assertion callback
|
||||
// done(FormSaveErr);
|
||||
// });
|
||||
// });
|
||||
|
||||
// it('should not be able to get list of users\' Forms if not logged in', function(done) {
|
||||
// userSession.get('/forms')
|
||||
// .expect(401)
|
||||
// .end(function(FormSaveErr, FormSaveRes) {
|
||||
// (FormSaveRes.body.message).should.equal('User is not logged in');
|
||||
// // Call the assertion callback
|
||||
// done(FormSaveErr);
|
||||
// });
|
||||
// });
|
||||
|
||||
// it('should not be able to save a Form if no title is provided', function(done) {
|
||||
// // Set Form with a invalid title field
|
||||
// _Form.title = '';
|
||||
|
||||
// userSession.post('/auth/signin')
|
||||
// .send(credentials)
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200)
|
||||
// .end(function(signinErr, signinRes) {
|
||||
// // Handle signin error
|
||||
// if (signinErr) done(signinErr);
|
||||
|
||||
// // Save a new Form
|
||||
// userSession.post('/forms')
|
||||
// .send({form: _Form})
|
||||
// .expect(400)
|
||||
// .end(function(FormSaveErr, FormSaveRes) {
|
||||
// // Set message assertion
|
||||
// (FormSaveRes.body.message).should.equal('Form Title cannot be blank');
|
||||
|
||||
// // Handle Form save error
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
// it('should be able to update a Form if signed in', function(done) {
|
||||
// userSession.post('/auth/signin')
|
||||
// .send(credentials)
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200)
|
||||
// .end(function(signinErr, signinRes) {
|
||||
// // Handle signin error
|
||||
// if (signinErr) done(signinErr);
|
||||
|
||||
// // Save a new Form
|
||||
// userSession.post('/forms')
|
||||
// .send({form: _Form})
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200)
|
||||
// .end(function(FormSaveErr, FormSaveRes) {
|
||||
// // Handle Form save error
|
||||
// if (FormSaveErr) done(FormSaveErr);
|
||||
|
||||
// // Update Form title
|
||||
// _Form.title = 'WHY YOU GOTTA BE SO MEAN?';
|
||||
|
||||
// // Update an existing Form
|
||||
// userSession.put('/forms/' + FormSaveRes.body._id)
|
||||
// .send({form: _Form})
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200)
|
||||
// .end(function(FormUpdateErr, FormUpdateRes) {
|
||||
// // Handle Form update error
|
||||
// if (FormUpdateErr) done(FormUpdateErr);
|
||||
|
||||
// // Set assertions
|
||||
// (FormUpdateRes.body._id).should.equal(FormSaveRes.body._id);
|
||||
// (FormUpdateRes.body.title).should.match('WHY YOU GOTTA BE SO MEAN?');
|
||||
|
||||
// // Call the assertion callback
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
// it('should be able to read/get a Form if not signed in', function(done) {
|
||||
// // Create new Form model instance
|
||||
// var FormObj = new Form(_Form);
|
||||
|
||||
// // Save the Form
|
||||
// FormObj.save(function(err, form) {
|
||||
// if(err) done(err);
|
||||
|
||||
// request(app).get('/forms/' + form._id)
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200)
|
||||
// .end(function(err, res) {
|
||||
// if(err) done(err)
|
||||
|
||||
// // Set assertion
|
||||
// (res.body).should.be.an.Object.with.property('title', _Form.title);
|
||||
|
||||
// // Call the assertion callback
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
// it('should be able to delete a Form if signed in', function(done) {
|
||||
|
||||
// userSession.post('/auth/signin')
|
||||
// .send(credentials)
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200)
|
||||
// .end(function(signinErr, signinRes) {
|
||||
// // Handle signin error
|
||||
// if (signinErr) done(signinErr);
|
||||
|
||||
// done();
|
||||
// // Save a new Form
|
||||
// // userSession.post('/forms')
|
||||
// // .send({form: _Form})
|
||||
// // .expect('Content-Type', /json/)
|
||||
// // .expect(200)
|
||||
// // .end(function(FormSaveErr, FormSaveRes) {
|
||||
// // // Handle Form save error
|
||||
// // if (FormSaveErr) done(FormSaveErr);
|
||||
|
||||
// // // Delete an existing Form
|
||||
// // userSession.delete('/forms/' + FormSaveRes.body._id)
|
||||
// // .send(_Form)
|
||||
// // .expect('Content-Type', /json/)
|
||||
// // .expect(200)
|
||||
// // .end(function(FormDeleteErr, FormDeleteRes) {
|
||||
// // // Handle Form error error
|
||||
// // if (FormDeleteErr) done(FormDeleteErr);
|
||||
|
||||
// // // Set assertions
|
||||
// // (FormDeleteRes.body._id).should.equal(FormSaveRes.body._id);
|
||||
|
||||
// // // Call the assertion callback
|
||||
// // done();
|
||||
// // });
|
||||
// // });
|
||||
|
||||
// });
|
||||
// });
|
||||
|
||||
// it('should not be able to delete an Form if not signed in', function(done) {
|
||||
// // Set Form user
|
||||
// _Form.admin = user;
|
||||
|
||||
// // Create new Form model instance
|
||||
// var FormObj = new Form(_Form);
|
||||
|
||||
// // Save the Form
|
||||
// FormObj.save(function() {
|
||||
// // Try deleting Form
|
||||
// request(app).delete('/forms/' + FormObj._id)
|
||||
// .expect(401)
|
||||
// .end(function(FormDeleteErr, FormDeleteRes) {
|
||||
// // Set message assertion
|
||||
// (FormDeleteRes.body.message).should.match('User is not logged in');
|
||||
|
||||
// // Handle Form error error
|
||||
// done(FormDeleteErr);
|
||||
// });
|
||||
|
||||
// });
|
||||
// });
|
||||
|
||||
|
||||
// it('should be able to upload a PDF an Form if logged in', function(done) {
|
||||
// userSession.post('/auth/signin')
|
||||
// .send(credentials)
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200)
|
||||
// .end(function(signinErr, signinRes) {
|
||||
|
||||
// // Handle signin error
|
||||
// if (signinErr) done(signinErr);
|
||||
|
||||
// var user = signinRes.body;
|
||||
// var userId = user._id;
|
||||
|
||||
// // Save a new Form
|
||||
// userSession.post('/forms')
|
||||
// .send({form: _Form})
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200)
|
||||
// .end(function(FormSaveErr, FormSaveRes) {
|
||||
// // Handle Form save error
|
||||
// if (FormSaveErr) done(FormSaveErr);
|
||||
|
||||
// // Get a list of Forms
|
||||
// userSession.get('/forms')
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200)
|
||||
// .end(function(FormsGetErr, FormsGetRes) {
|
||||
// // Handle Form save error
|
||||
// if (FormsGetErr) done(FormsGetErr);
|
||||
|
||||
// // Get Forms list
|
||||
// var Forms = FormsGetRes.body;
|
||||
|
||||
// // Set assertions
|
||||
// (Forms[0].admin).should.equal(userId);
|
||||
// (Forms[0].title).should.match('Form Title');
|
||||
|
||||
// // Call the assertion callback
|
||||
// done();
|
||||
// });
|
||||
|
||||
// });
|
||||
|
||||
|
||||
// });
|
||||
// });
|
||||
|
||||
// describe('Form Submission tests', function() {
|
||||
// var FormObj, _Submission, submissionSession;
|
||||
|
||||
// beforeEach(function (done) {
|
||||
// _Form.admin = user;
|
||||
// FormObj = new Form(_Form);
|
||||
|
||||
// FormObj.save(function(err, form) {
|
||||
// if (err) done(err);
|
||||
|
||||
// _Submission = {
|
||||
// form_fields: [
|
||||
// {'fieldType':'textfield', 'title':'First Name', 'fieldValue': 'David'},
|
||||
// {'fieldType':'checkbox', 'title':'nascar', 'fieldValue': true},
|
||||
// {'fieldType':'checkbox', 'title':'hockey', 'fieldValue': false}
|
||||
// ],
|
||||
// form: form._id,
|
||||
// admin: user._id,
|
||||
// percentageComplete: 100,
|
||||
// timeElapsed: 11.55
|
||||
// };
|
||||
|
||||
// FormObj = form;
|
||||
|
||||
// //Setup test session
|
||||
// submissionSession = new Session();
|
||||
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
|
||||
// it('should be able to create a Form Submission without signing in', function(done) {
|
||||
|
||||
// //Create Submission
|
||||
// submissionSession.post('/forms/' + FormObj._id)
|
||||
// .send(_Submission)
|
||||
// .expect(200)
|
||||
// .end(function(err, res) {
|
||||
|
||||
// should.not.exist(err);
|
||||
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
|
||||
// it('should be able to get Form Submissions if signed in', function(done) {
|
||||
// submissionSession.post('/auth/signin')
|
||||
// .send(credentials)
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200)
|
||||
// .end(function(signinErr, signinRes) {
|
||||
|
||||
// should.not.exist(signinErr);
|
||||
|
||||
// //Create Submission
|
||||
// submissionSession.post('/forms/' + FormObj._id)
|
||||
// .send(_Submission)
|
||||
// .expect(200)
|
||||
// .end(function(err, res) {
|
||||
|
||||
// should.not.exist(err);
|
||||
|
||||
// submissionSession.get('/forms/' + FormObj._id + '/submissions')
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200)
|
||||
// .end(function(err, res) {
|
||||
|
||||
// // Set assertion
|
||||
// should.not.exist(err);
|
||||
|
||||
// // Call the assertion callback
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
// it('should not be able to get Form Submissions if not signed in', function(done) {
|
||||
// // Attempt to fetch form submissions
|
||||
// submissionSession.get('/forms/' + FormObj._id + '/submissions')
|
||||
// .expect(401)
|
||||
// .end(function(err, res) {
|
||||
'use strict';
|
||||
|
||||
var should = require('should'),
|
||||
_ = require('lodash'),
|
||||
app = require('../../server'),
|
||||
request = require('supertest'),
|
||||
Session = require('supertest-session')({
|
||||
app: app
|
||||
}),
|
||||
mongoose = require('mongoose'),
|
||||
User = mongoose.model('User'),
|
||||
Form = mongoose.model('Form'),
|
||||
Field = mongoose.model('Field'),
|
||||
FormSubmission = mongoose.model('FormSubmission'),
|
||||
agent = request.agent(app);
|
||||
|
||||
/**
|
||||
* Globals
|
||||
*/
|
||||
var credentials, user, _Form, userSession;
|
||||
|
||||
/**
|
||||
* Form routes tests
|
||||
*/
|
||||
describe('Form CRUD tests', function() {
|
||||
|
||||
beforeEach(function(done) {
|
||||
|
||||
//Initialize Session
|
||||
userSession = new Session();
|
||||
|
||||
// Create user credentials
|
||||
credentials = {
|
||||
username: 'test@test.com',
|
||||
password: 'password'
|
||||
};
|
||||
|
||||
// Create a new user
|
||||
user = new User({
|
||||
firstName: 'Full',
|
||||
lastName: 'Name',
|
||||
email: 'test@test.com',
|
||||
username: credentials.username,
|
||||
password: credentials.password,
|
||||
provider: 'local'
|
||||
});
|
||||
|
||||
// Save a user to the test db and create new Form
|
||||
user.save(function(err) {
|
||||
if(err) done(err);
|
||||
_Form = {
|
||||
title: 'Form Title',
|
||||
language: 'english',
|
||||
admin: user._id,
|
||||
form_fields: [
|
||||
new Field({'fieldType':'textfield', 'title':'First Name', 'fieldValue': ''}),
|
||||
new Field({'fieldType':'checkbox', 'title':'nascar', 'fieldValue': ''}),
|
||||
new Field({'fieldType':'checkbox', 'title':'hockey', 'fieldValue': ''})
|
||||
]
|
||||
};
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to save a Form if logged in', function(done) {
|
||||
userSession.post('/auth/signin')
|
||||
.send(credentials)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end(function(signinErr, signinRes) {
|
||||
|
||||
// Handle signin error
|
||||
if (signinErr) done(signinErr);
|
||||
|
||||
var user = signinRes.body;
|
||||
var userId = user._id;
|
||||
|
||||
// Save a new Form
|
||||
userSession.post('/forms')
|
||||
.send({form: _Form})
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end(function(FormSaveErr, FormSaveRes) {
|
||||
// Handle Form save error
|
||||
if (FormSaveErr) done(FormSaveErr);
|
||||
|
||||
// Get a list of Forms
|
||||
userSession.get('/forms')
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end(function(FormsGetErr, FormsGetRes) {
|
||||
// Handle Form save error
|
||||
if (FormsGetErr) done(FormsGetErr);
|
||||
|
||||
// Get Forms list
|
||||
var Forms = FormsGetRes.body;
|
||||
|
||||
// Set assertions
|
||||
(Forms[0].admin).should.equal(userId);
|
||||
(Forms[0].title).should.match('Form Title');
|
||||
|
||||
// Call the assertion callback
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should not be able to create a Form if not logged in', function(done) {
|
||||
userSession.post('/forms')
|
||||
.send({form: _Form})
|
||||
.expect(401)
|
||||
.end(function(FormSaveErr, FormSaveRes) {
|
||||
(FormSaveRes.body.message).should.equal('User is not logged in');
|
||||
// Call the assertion callback
|
||||
done(FormSaveErr);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not be able to get list of users\' Forms if not logged in', function(done) {
|
||||
userSession.get('/forms')
|
||||
.expect(401)
|
||||
.end(function(FormSaveErr, FormSaveRes) {
|
||||
(FormSaveRes.body.message).should.equal('User is not logged in');
|
||||
// Call the assertion callback
|
||||
done(FormSaveErr);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not be able to save a Form if no title is provided', function(done) {
|
||||
// Set Form with a invalid title field
|
||||
_Form.title = '';
|
||||
|
||||
userSession.post('/auth/signin')
|
||||
.send(credentials)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end(function(signinErr, signinRes) {
|
||||
// Handle signin error
|
||||
if (signinErr) done(signinErr);
|
||||
|
||||
// Save a new Form
|
||||
userSession.post('/forms')
|
||||
.send({form: _Form})
|
||||
.expect(400)
|
||||
.end(function(FormSaveErr, FormSaveRes) {
|
||||
// Set message assertion
|
||||
(FormSaveRes.body.message).should.equal('Form Title cannot be blank');
|
||||
|
||||
// Handle Form save error
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to update a Form if signed in', function(done) {
|
||||
userSession.post('/auth/signin')
|
||||
.send(credentials)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end(function(signinErr, signinRes) {
|
||||
// Handle signin error
|
||||
if (signinErr) done(signinErr);
|
||||
|
||||
// Save a new Form
|
||||
userSession.post('/forms')
|
||||
.send({form: _Form})
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end(function(FormSaveErr, FormSaveRes) {
|
||||
// Handle Form save error
|
||||
if (FormSaveErr) done(FormSaveErr);
|
||||
|
||||
// Update Form title
|
||||
_Form.title = 'WHY YOU GOTTA BE SO MEAN?';
|
||||
|
||||
// Update an existing Form
|
||||
userSession.put('/forms/' + FormSaveRes.body._id)
|
||||
.send({form: _Form})
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end(function(FormUpdateErr, FormUpdateRes) {
|
||||
// Handle Form update error
|
||||
if (FormUpdateErr) done(FormUpdateErr);
|
||||
|
||||
// Set assertions
|
||||
(FormUpdateRes.body._id).should.equal(FormSaveRes.body._id);
|
||||
(FormUpdateRes.body.title).should.match('WHY YOU GOTTA BE SO MEAN?');
|
||||
|
||||
// Call the assertion callback
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to read/get a Form if not signed in', function(done) {
|
||||
// Create new Form model instance
|
||||
var FormObj = new Form(_Form);
|
||||
|
||||
// Save the Form
|
||||
FormObj.save(function(err, form) {
|
||||
if(err) done(err);
|
||||
|
||||
request(app).get('/forms/' + form._id)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end(function(err, res) {
|
||||
if(err) done(err)
|
||||
|
||||
// Set assertion
|
||||
(res.body).should.be.an.Object.with.property('title', _Form.title);
|
||||
|
||||
// Call the assertion callback
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to delete a Form if signed in', function(done) {
|
||||
|
||||
userSession.post('/auth/signin')
|
||||
.send(credentials)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end(function(signinErr, signinRes) {
|
||||
// Handle signin error
|
||||
if (signinErr) done(signinErr);
|
||||
|
||||
done();
|
||||
// Save a new Form
|
||||
// userSession.post('/forms')
|
||||
// .send({form: _Form})
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200)
|
||||
// .end(function(FormSaveErr, FormSaveRes) {
|
||||
// // Handle Form save error
|
||||
// if (FormSaveErr) done(FormSaveErr);
|
||||
|
||||
// // Delete an existing Form
|
||||
// userSession.delete('/forms/' + FormSaveRes.body._id)
|
||||
// .send(_Form)
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200)
|
||||
// .end(function(FormDeleteErr, FormDeleteRes) {
|
||||
// // Handle Form error error
|
||||
// if (FormDeleteErr) done(FormDeleteErr);
|
||||
|
||||
// // Set assertions
|
||||
// (FormDeleteRes.body._id).should.equal(FormSaveRes.body._id);
|
||||
|
||||
// // Call the assertion callback
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
it('should not be able to delete an Form if not signed in', function(done) {
|
||||
// Set Form user
|
||||
_Form.admin = user;
|
||||
|
||||
// Create new Form model instance
|
||||
var FormObj = new Form(_Form);
|
||||
|
||||
// Save the Form
|
||||
FormObj.save(function() {
|
||||
// Try deleting Form
|
||||
request(app).delete('/forms/' + FormObj._id)
|
||||
.expect(401)
|
||||
.end(function(FormDeleteErr, FormDeleteRes) {
|
||||
// Set message assertion
|
||||
(FormDeleteRes.body.message).should.match('User is not logged in');
|
||||
|
||||
// Handle Form error error
|
||||
done(FormDeleteErr);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should be able to upload a PDF an Form if logged in', function(done) {
|
||||
userSession.post('/auth/signin')
|
||||
.send(credentials)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end(function(signinErr, signinRes) {
|
||||
|
||||
// Handle signin error
|
||||
if (signinErr) done(signinErr);
|
||||
|
||||
var user = signinRes.body;
|
||||
var userId = user._id;
|
||||
|
||||
// Save a new Form
|
||||
userSession.post('/forms')
|
||||
.send({form: _Form})
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end(function(FormSaveErr, FormSaveRes) {
|
||||
// Handle Form save error
|
||||
if (FormSaveErr) done(FormSaveErr);
|
||||
|
||||
// Get a list of Forms
|
||||
userSession.get('/forms')
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end(function(FormsGetErr, FormsGetRes) {
|
||||
// Handle Form save error
|
||||
if (FormsGetErr) done(FormsGetErr);
|
||||
|
||||
// Get Forms list
|
||||
var Forms = FormsGetRes.body;
|
||||
|
||||
// Set assertions
|
||||
(Forms[0].admin).should.equal(userId);
|
||||
(Forms[0].title).should.match('Form Title');
|
||||
|
||||
// Call the assertion callback
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
describe('Form Submission tests', function() {
|
||||
var FormObj, _Submission, submissionSession;
|
||||
|
||||
beforeEach(function (done) {
|
||||
_Form.admin = user;
|
||||
FormObj = new Form(_Form);
|
||||
|
||||
FormObj.save(function(err, form) {
|
||||
if (err) done(err);
|
||||
|
||||
_Submission = {
|
||||
form_fields: [
|
||||
{'fieldType':'textfield', 'title':'First Name', 'fieldValue': 'David'},
|
||||
{'fieldType':'checkbox', 'title':'nascar', 'fieldValue': true},
|
||||
{'fieldType':'checkbox', 'title':'hockey', 'fieldValue': false}
|
||||
],
|
||||
form: form._id,
|
||||
admin: user._id,
|
||||
percentageComplete: 100,
|
||||
timeElapsed: 11.55
|
||||
};
|
||||
|
||||
FormObj = form;
|
||||
|
||||
//Setup test session
|
||||
submissionSession = new Session();
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to create a Form Submission without signing in', function(done) {
|
||||
|
||||
//Create Submission
|
||||
submissionSession.post('/forms/' + FormObj._id)
|
||||
.send(_Submission)
|
||||
.expect(200)
|
||||
.end(function(err, res) {
|
||||
|
||||
should.not.exist(err);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to get Form Submissions if signed in', function(done) {
|
||||
submissionSession.post('/auth/signin')
|
||||
.send(credentials)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end(function(signinErr, signinRes) {
|
||||
|
||||
should.not.exist(signinErr);
|
||||
|
||||
//Create Submission
|
||||
submissionSession.post('/forms/' + FormObj._id)
|
||||
.send(_Submission)
|
||||
.expect(200)
|
||||
.end(function(err, res) {
|
||||
|
||||
should.not.exist(err);
|
||||
|
||||
submissionSession.get('/forms/' + FormObj._id + '/submissions')
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end(function(err, res) {
|
||||
|
||||
// Set assertion
|
||||
should.not.exist(err);
|
||||
|
||||
// Call the assertion callback
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should not be able to get Form Submissions if not signed in', function(done) {
|
||||
// Attempt to fetch form submissions
|
||||
submissionSession.get('/forms/' + FormObj._id + '/submissions')
|
||||
.expect(401)
|
||||
.end(function(err, res) {
|
||||
|
||||
// // Set assertions
|
||||
// (res.body.message).should.equal('User is not logged in');
|
||||
// Set assertions
|
||||
(res.body.message).should.equal('User is not logged in');
|
||||
|
||||
// // Call the assertion callback
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// Call the assertion callback
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
// it('should not be able to delete Form Submission if not signed in', function(done) {
|
||||
// var SubmissionObj = new FormSubmission(_Submission);
|
||||
it('should not be able to delete Form Submission if not signed in', function(done) {
|
||||
var SubmissionObj = new FormSubmission(_Submission);
|
||||
|
||||
// SubmissionObj.save(function (err, submission) {
|
||||
// should.not.exist(err);
|
||||
|
||||
// var submission_ids = _.pluck([submission], '_id');
|
||||
|
||||
// // Attempt to delete form submissions
|
||||
// submissionSession.delete('/forms/' + FormObj._id + '/submissions')
|
||||
// .send({deleted_submissions: submission_ids})
|
||||
// .expect(401)
|
||||
// .end(function(err, res) {
|
||||
SubmissionObj.save(function (err, submission) {
|
||||
should.not.exist(err);
|
||||
|
||||
var submission_ids = _.pluck([submission], '_id');
|
||||
|
||||
// Attempt to delete form submissions
|
||||
submissionSession.delete('/forms/' + FormObj._id + '/submissions')
|
||||
.send({deleted_submissions: submission_ids})
|
||||
.expect(401)
|
||||
.end(function(err, res) {
|
||||
|
||||
// // Set assertions
|
||||
// should.not.exist(err);
|
||||
// (res.body.message).should.equal('User is not logged in');
|
||||
// Set assertions
|
||||
should.not.exist(err);
|
||||
(res.body.message).should.equal('User is not logged in');
|
||||
|
||||
// // Call the assertion callback
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// Call the assertion callback
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// it('should be able to delete Form Submission if signed in', function(done) {
|
||||
// // Create new FormSubmission model instance
|
||||
// var SubmissionObj = new FormSubmission(_Submission);
|
||||
it('should be able to delete Form Submission if signed in', function(done) {
|
||||
// Create new FormSubmission model instance
|
||||
var SubmissionObj = new FormSubmission(_Submission);
|
||||
|
||||
// SubmissionObj.save(function (err, submission) {
|
||||
// should.not.exist(err);
|
||||
SubmissionObj.save(function (err, submission) {
|
||||
should.not.exist(err);
|
||||
|
||||
// // Signin as user
|
||||
// submissionSession.post('/auth/signin')
|
||||
// .send(credentials)
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200)
|
||||
// .end(function(signinErr, signinRes) {
|
||||
// // Handle signin error
|
||||
// if (signinErr) done(signinErr);
|
||||
// Signin as user
|
||||
submissionSession.post('/auth/signin')
|
||||
.send(credentials)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end(function(signinErr, signinRes) {
|
||||
// Handle signin error
|
||||
if (signinErr) done(signinErr);
|
||||
|
||||
// var submission_ids = _.pluck([submission], '_id');
|
||||
var submission_ids = _.pluck([submission], '_id');
|
||||
|
||||
// //Delete form submissions
|
||||
// submissionSession.delete('/forms/' + FormObj._id + '/submissions')
|
||||
// .send({deleted_submissions: submission_ids})
|
||||
// .expect(200)
|
||||
// .end(function(err, res) {
|
||||
//Delete form submissions
|
||||
submissionSession.delete('/forms/' + FormObj._id + '/submissions')
|
||||
.send({deleted_submissions: submission_ids})
|
||||
.expect(200)
|
||||
.end(function(err, res) {
|
||||
|
||||
// // Set assertions
|
||||
// should.not.exist(err);
|
||||
// (res.text).should.equal('Form submissions successfully deleted');
|
||||
// Set assertions
|
||||
should.not.exist(err);
|
||||
(res.text).should.equal('Form submissions successfully deleted');
|
||||
|
||||
// // Call the assertion callback
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// Call the assertion callback
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// afterEach(function(done) {//logout current user if there is one
|
||||
// FormSubmission.remove().exec(function() {
|
||||
// Form.remove().exec(function (err) {
|
||||
// submissionSession.destroy();
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
afterEach(function(done) {//logout current user if there is one
|
||||
FormSubmission.remove().exec(function() {
|
||||
Form.remove().exec(function (err) {
|
||||
submissionSession.destroy();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// afterEach(function(done) {
|
||||
// User.remove().exec(function() {
|
||||
// Form.remove().exec(function() {
|
||||
// userSession.destroy();
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
afterEach(function(done) {
|
||||
User.remove().exec(function() {
|
||||
Form.remove().exec(function() {
|
||||
userSession.destroy();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -12,43 +12,30 @@ var should = require('should'),
|
||||
config = require('../../config/config'),
|
||||
FormSubmission = mongoose.model('FormSubmission');
|
||||
|
||||
|
||||
var exampleDemo = {
|
||||
activeCount: 1,
|
||||
unparsedDOB: '',
|
||||
address: '880-9650 Velit. St.',
|
||||
chartNo: '',
|
||||
city: '',
|
||||
dateJoined: Date.now(),
|
||||
dateOfBirth: '10',
|
||||
displayName: 'LITTLE, URIAH',
|
||||
email: '',
|
||||
familyDoctor: '<rdohip></rdohip><rd></rd>',
|
||||
firstName: 'Uriah F.',
|
||||
hcType: 'BC',
|
||||
displayName: 'Test User',
|
||||
email: 'polydaic@gmail.com',
|
||||
firstName: 'Test User',
|
||||
hin: '',
|
||||
hsAlertCount: 0,
|
||||
lastName: 'Little',
|
||||
lastName: 'AddDemographic',
|
||||
lastUpdateDate: Date.now(),
|
||||
lastUpdateUser: '',
|
||||
links: '',
|
||||
monthOfBirth: '05',
|
||||
officialLanguage: 'English',
|
||||
patientStatus: 'AC',
|
||||
patientStatusDate: Date.now(),
|
||||
phone: '250-',
|
||||
phone: '250-222-2222',
|
||||
phone2: '',
|
||||
postal: 'S4M 7T8',
|
||||
providerNo: '4',
|
||||
postal: "S4M 7T8",
|
||||
province: 'BC',
|
||||
rosterStatus: '',
|
||||
sex: 'M',
|
||||
sex: 'F',
|
||||
sexDesc: 'Female',
|
||||
sin: '',
|
||||
spokenLanguage: 'English',
|
||||
title: 'MS.',
|
||||
yearOfBirth: '2015'
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
var sampleFormFields = [
|
||||
{'fieldType':'textfield', 'title':'What\'s your first name', 'fieldValue': ''},
|
||||
@ -61,8 +48,8 @@ var sampleFormFields = [
|
||||
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': 0, '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': Date.now()},
|
||||
{'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'}
|
||||
];
|
||||
|
||||
@ -76,6 +63,7 @@ var user, myForm, mySubmission;
|
||||
* Unit tests
|
||||
*/
|
||||
describe('FormSubmission Model Unit Tests:', function() {
|
||||
this.timeout(15000);
|
||||
beforeEach(function(done) {
|
||||
user = new User({
|
||||
firstName: 'Full',
|
||||
@ -122,7 +110,7 @@ describe('FormSubmission Model Unit Tests:', function() {
|
||||
|
||||
var submissionFields = _.clone(myForm.form_fields);
|
||||
for(var z=0; z<submissionFields.length; z++){
|
||||
submissionFields[z] = _.extend(myForm.form_fields[z], submissionFields[z]);
|
||||
submissionFields[z] = _.extend(myForm.form_fields[z], sampleSubmission[z]);
|
||||
}
|
||||
|
||||
mySubmission = new FormSubmission({
|
||||
@ -152,30 +140,6 @@ describe('FormSubmission Model Unit Tests:', function() {
|
||||
|
||||
myForm.save(function(err, form){
|
||||
if(err) done(err);
|
||||
|
||||
// var submission_fields = _.cloneDeep(form.toObject().form_fields);
|
||||
/*
|
||||
var submission_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': ''}
|
||||
];
|
||||
|
||||
submission_fields[0].fieldValue = 'David';
|
||||
submission_fields[1].fieldValue = 'Baldwynn'+Date.now();
|
||||
submission_fields[2].fieldValue = 'M';
|
||||
submission_fields[3].fieldValue = Date.now();
|
||||
submission_fields[4].fieldValue = 6043158008;
|
||||
|
||||
mySubmission = new FormSubmission({
|
||||
admin: user,
|
||||
form: form,
|
||||
timeElapsed: 17.55,
|
||||
form_fields: submission_fields
|
||||
});
|
||||
*/
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -290,6 +254,59 @@ describe('FormSubmission Model Unit Tests:', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Submission of Form should add Patient to OscarHost', function() {
|
||||
before(function(done){
|
||||
myForm.form_fields = [
|
||||
new Field({'fieldType':'textfield', 'title':'What\'s your first name', 'fieldValue': ''}),
|
||||
new Field({'fieldType':'textfield', 'title':'And your last name', 'fieldValue': ''}),
|
||||
new Field({'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': ''}),
|
||||
new Field({'fieldType':'date', 'title':'When were you born?', 'fieldValue': ''}),
|
||||
new Field({'fieldType':'number', 'title':'What\'s your phone #?', 'fieldValue': ''}),
|
||||
];
|
||||
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] = 'unparsedDOB';
|
||||
myFieldMap[myForm.form_fields[4]._id] = 'phone';
|
||||
|
||||
myForm.plugins.oscarhost = {
|
||||
baseUrl: config.oscarhost.baseUrl,
|
||||
settings: {
|
||||
updateType: 'force_add',
|
||||
fieldMap: myFieldMap,
|
||||
},
|
||||
auth: config.oscarhost.auth,
|
||||
};
|
||||
|
||||
myForm.save(function(err, form){
|
||||
if(err) done(err);
|
||||
|
||||
var submission_fields = _.clone(myForm.toObject().form_fields);
|
||||
submission_fields[0].fieldValue = 'David';
|
||||
submission_fields[1].fieldValue = 'Baldwynn'+Date.now();
|
||||
submission_fields[2].fieldValue = 'M';
|
||||
submission_fields[3].fieldValue = Date.now();
|
||||
submission_fields[4].fieldValue = 6043158008;
|
||||
|
||||
mySubmission = new FormSubmission({
|
||||
form_fields: submission_fields,
|
||||
admin: form.admin,
|
||||
form: form,
|
||||
timeElapsed: 17.55
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should be able to submit a valid form without problems', function(done) {
|
||||
mySubmission.save(function(err, submission) {
|
||||
should.not.exist(err);
|
||||
should.exist(submission.oscarDemoNum);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
Form.remove().exec(function() {
|
||||
User.remove().exec(function() {
|
||||
|
||||
@ -1,213 +1,201 @@
|
||||
// 'use strict';
|
||||
'use strict';
|
||||
|
||||
// var should = require('should'),
|
||||
// _ = require('lodash'),
|
||||
// app = require('../../server'),
|
||||
// request = require('supertest'),
|
||||
// Session = require('supertest-session')({
|
||||
// app: app
|
||||
// }),
|
||||
// mongoose = require('mongoose'),
|
||||
// User = mongoose.model('User'),
|
||||
// config = require('../../config/config'),
|
||||
// tmpUser = mongoose.model(config.tempUserCollection),
|
||||
// agent = request.agent(app),
|
||||
// url = require('url');
|
||||
var should = require('should'),
|
||||
_ = require('lodash'),
|
||||
app = require('../../server'),
|
||||
request = require('supertest'),
|
||||
Session = require('supertest-session')({
|
||||
app: app
|
||||
}),
|
||||
mongoose = require('mongoose'),
|
||||
User = mongoose.model('User'),
|
||||
config = require('../../config/config'),
|
||||
tmpUser = mongoose.model(config.tempUserCollection),
|
||||
agent = request.agent(app),
|
||||
url = require('url');
|
||||
|
||||
// var mailosaur = require('mailosaur')(config.mailosaur.key),
|
||||
// mailbox = new mailosaur.Mailbox(config.mailosaur.mailbox_id);
|
||||
var mailosaur = require('mailosaur')(config.mailosaur.key),
|
||||
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
|
||||
// */
|
||||
// var credentials, _User, _Session;
|
||||
/**
|
||||
* Globals
|
||||
*/
|
||||
var credentials, _User, _Session;
|
||||
|
||||
// /**
|
||||
// * Form routes tests
|
||||
// */
|
||||
// describe('User CRUD tests', function() {
|
||||
// this.timeout(15000);
|
||||
// var userSession;
|
||||
/**
|
||||
* Form routes tests
|
||||
*/
|
||||
describe('User CRUD tests', function() {
|
||||
this.timeout(15000);
|
||||
var userSession;
|
||||
|
||||
// beforeEach(function() {
|
||||
// //Initialize Session
|
||||
// userSession = new Session();
|
||||
beforeEach(function() {
|
||||
//Initialize Session
|
||||
userSession = new Session();
|
||||
|
||||
// // Create user credentials
|
||||
// credentials = {
|
||||
// username: 'be1e58fb@mailosaur.in',
|
||||
// password: 'password'
|
||||
// };
|
||||
// Create user credentials
|
||||
credentials = {
|
||||
username: 'be1e58fb@mailosaur.in',
|
||||
password: 'password'
|
||||
};
|
||||
|
||||
// // Create a new user
|
||||
// _User = {
|
||||
// firstName: 'Full',
|
||||
// lastName: 'Name',
|
||||
// email: credentials.username,
|
||||
// username: credentials.username,
|
||||
// password: credentials.password,
|
||||
// };
|
||||
// });
|
||||
// Create a new user
|
||||
_User = {
|
||||
firstName: 'Full',
|
||||
lastName: 'Name',
|
||||
email: credentials.username,
|
||||
username: credentials.username,
|
||||
password: credentials.password,
|
||||
};
|
||||
});
|
||||
|
||||
// describe('Create, Verify and Activate a User', function() {
|
||||
// var username = 'testActiveAccount.be1e58fb@mailosaur.in';
|
||||
// var link, _tmpUser, activateToken;
|
||||
// this.timeout(15000);
|
||||
describe('Create, Verify and Activate a User', function() {
|
||||
var username = 'testActiveAccount1.be1e58fb@mailosaur.in';
|
||||
var link, _tmpUser, activateToken;
|
||||
this.timeout(15000);
|
||||
|
||||
// it('should be able to create a temporary (non-activated) User', function(done) {
|
||||
// _User.email = _User.username = username;
|
||||
// request(app).post('/auth/signup')
|
||||
// .send(_User)
|
||||
// .expect(200, 'An email has been sent to you. Please check it to verify your account.')
|
||||
// .end(function(FormSaveErr, FormSaveRes) {
|
||||
// // (FormSaveRes.text).should.equal('An email has been sent to you. Please check it to verify your account.');
|
||||
// done();
|
||||
// // tmpUser.findOne({username: _User.username}, function (err, user) {
|
||||
// // should.not.exist(err);
|
||||
// // should.exist(user);
|
||||
// // _tmpUser = user;
|
||||
it('should be able to create a temporary (non-activated) User', function(done) {
|
||||
_User.email = _User.username = username;
|
||||
userSession.post('/auth/signup')
|
||||
.send(_User)
|
||||
.expect(200, 'An email has been sent to you. Please check it to verify your account.')
|
||||
.end(function(FormSaveErr, FormSaveRes) {
|
||||
|
||||
// // _User.username.should.equal(user.username);
|
||||
// // _User.firstName.should.equal(user.firstName);
|
||||
// // _User.lastName.should.equal(user.lastName);
|
||||
tmpUser.findOne({username: _User.username}, function (err, user) {
|
||||
should.not.exist(err);
|
||||
should.exist(user);
|
||||
_tmpUser = user;
|
||||
|
||||
// // // mandrill('/messages/search', {
|
||||
// // // query: "subject:Confirm",
|
||||
// // // senders: [
|
||||
// // // "test@forms.polydaic.com"
|
||||
// // // ],
|
||||
// // // limit: 1
|
||||
// // // }, function(error, emails) {
|
||||
// // // if (error) console.log( JSON.stringify(error) );
|
||||
_User.username.should.equal(user.username);
|
||||
_User.firstName.should.equal(user.firstName);
|
||||
_User.lastName.should.equal(user.lastName);
|
||||
activateToken = user.GENERATED_VERIFYING_URL;
|
||||
|
||||
// // // var confirmation_email = emails[0];
|
||||
done();
|
||||
});
|
||||
|
||||
// // // mandrill('/messages/content', {
|
||||
// // // id: confirmation_email._id
|
||||
// // // }, function(error, email) {
|
||||
// // // if (error) console.log( JSON.stringify(error) );
|
||||
// // mandrill('/messages/search', {
|
||||
// // query: "subject:Confirm",
|
||||
// // senders: [
|
||||
// // "test@forms.polydaic.com"
|
||||
// // ],
|
||||
// // limit: 1
|
||||
// // }, function(error, emails) {
|
||||
// // if (error) console.log( JSON.stringify(error) );
|
||||
|
||||
// // // // console.log(email);
|
||||
// // // var link = _(email.text.split('\n')).reverse().value()[1];
|
||||
// // // console.log(link);
|
||||
// // // activateToken = _(url.parse(link).hash.split('/')).reverse().value()[0];
|
||||
// // // console.log('actual activateToken: '+ activateToken);
|
||||
// // // console.log('expected activateToken: ' + user.GENERATED_VERIFYING_URL);
|
||||
// // var confirmation_email = emails[0];
|
||||
|
||||
// // // done();
|
||||
// // mandrill('/messages/content', {
|
||||
// // id: confirmation_email._id
|
||||
// // }, function(error, email) {
|
||||
// // if (error) console.log( JSON.stringify(error) );
|
||||
|
||||
// // // });
|
||||
// // // });
|
||||
// // // console.log(email);
|
||||
// // var link = _(email.text.split('\n')).reverse().value()[1];
|
||||
// // console.log(link);
|
||||
// // activateToken = _(url.parse(link).hash.split('/')).reverse().value()[0];
|
||||
// // console.log('actual activateToken: '+ activateToken);
|
||||
// // console.log('expected activateToken: ' + user.GENERATED_VERIFYING_URL);
|
||||
|
||||
// // done();
|
||||
|
||||
<<<<<<< HEAD
|
||||
// // mailbox.getEmails(function(err, _emails) {
|
||||
// // if(err) done(err);
|
||||
// // });
|
||||
// // });
|
||||
|
||||
// // var emails = _emails;
|
||||
// // mailbox.getEmails(function(err, _emails) {
|
||||
// // if(err) done(err);
|
||||
|
||||
// // console.log('mailbox.getEmails:');
|
||||
// // console.log(emails[0].text.links);
|
||||
// // var emails = _emails;
|
||||
|
||||
// // var link = emails[0].text.links[0].href;
|
||||
// // activateToken = _(url.parse(link).hash.split('/')).reverse().value()[0];
|
||||
// // console.log('actual activateToken: '+ activateToken);
|
||||
// // console.log('expected activateToken: ' + user.GENERATED_VERIFYING_URL);
|
||||
// // (activateToken).should.equal(user.GENERATED_VERIFYING_URL);
|
||||
// // console.log('mailbox.getEmails:');
|
||||
// // console.log(emails[0].text.links);
|
||||
|
||||
// // done();
|
||||
// // });
|
||||
// // });
|
||||
// });
|
||||
// });
|
||||
// // var link = emails[0].text.links[0].href;
|
||||
// // activateToken = _(url.parse(link).hash.split('/')).reverse().value()[0];
|
||||
// // console.log('actual activateToken: '+ activateToken);
|
||||
// // console.log('expected activateToken: ' + user.GENERATED_VERIFYING_URL);
|
||||
// // (activateToken).should.equal(user.GENERATED_VERIFYING_URL);
|
||||
|
||||
// // done();
|
||||
// // });
|
||||
// });
|
||||
});
|
||||
});
|
||||
|
||||
// it('shold have created User Account', function(done){
|
||||
// tmpUser.findOne({username: _User.username}, function (err, user) {
|
||||
// should.not.exist(err);
|
||||
// should.exist(user);
|
||||
// _tmpUser = user;
|
||||
it('should be able to verify a User Account', function(done) {
|
||||
console.log('activateToken: '+activateToken);
|
||||
userSession.get('/auth/verify/'+activateToken)
|
||||
.expect(200)
|
||||
.end(function(VerifyErr, VerifyRes) {
|
||||
should.not.exist(VerifyErr);
|
||||
if(VerifyErr) console.log(VerifyRes.text);
|
||||
(VerifyRes.text).should.equal('User successfully verified');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
// _User.username.should.equal(user.username);
|
||||
// _User.firstName.should.equal(user.firstName);
|
||||
// _User.lastName.should.equal(user.lastName)
|
||||
// it('should receive confirmation email after verifying a User Account', function(done) {
|
||||
// mailbox.getEmails(function(err, _emails) {
|
||||
// if(err) throw err;
|
||||
// var email = _emails[0];
|
||||
|
||||
// activateToken = user.GENERATED_VERIFYING_URL;
|
||||
// // console.log('mailbox.getEmails:');
|
||||
// console.log(email);
|
||||
// (email.subject).should.equal('Account successfully verified!');
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
});
|
||||
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// it('should be able to verify a User Account', function(done) {
|
||||
// userSession.get('/auth/verify/'+activateToken)
|
||||
// .expect(200)
|
||||
// .end(function(VerifyErr, VerifyRes) {
|
||||
// should.not.exist(VerifyErr);
|
||||
// (VerifyRes.text).should.equal('User successfully verified');
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
|
||||
// // it('should receive confirmation email after verifying a User Account', function(done) {
|
||||
// // mailbox.getEmails(function(err, _emails) {
|
||||
// // if(err) throw err;
|
||||
// // var email = _emails[0];
|
||||
|
||||
// // // console.log('mailbox.getEmails:');
|
||||
// // console.log(email);
|
||||
// // (email.subject).should.equal('Account successfully verified!');
|
||||
// // done();
|
||||
// // });
|
||||
// // });
|
||||
// });
|
||||
|
||||
// // it('should be able to login and logout a User', function (done) {
|
||||
// // var username = 'testActiveAccount.be1e58fb@mailosaur.in';
|
||||
// // _User.email = _User.username = credentials.username = username;
|
||||
// // userSession.post('/auth/signup')
|
||||
// // .send(_User)
|
||||
// // .expect(200)
|
||||
// // .end(function(FormSaveErr, FormSaveRes) {
|
||||
// // (FormSaveRes.text).should.equal('An email has been sent to you. Please check it to verify your account.');
|
||||
it('should be able to login and logout a User', function (done) {
|
||||
var username = 'testActiveAccount.be1e58fb@mailosaur.in';
|
||||
_User.email = _User.username = credentials.username = username;
|
||||
userSession.post('/auth/signup')
|
||||
.send(_User)
|
||||
.expect(200)
|
||||
.end(function(FormSaveErr, FormSaveRes) {
|
||||
(FormSaveRes.text).should.equal('An email has been sent to you. Please check it to verify your account.');
|
||||
|
||||
|
||||
// // userSession.post('/auth/signin')
|
||||
// // .send(credentials)
|
||||
// // .expect('Content-Type', /json/)
|
||||
// // .expect(200)
|
||||
// // .end(function(signinErr, signinRes) {
|
||||
userSession.post('/auth/signin')
|
||||
.send(credentials)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end(function(signinErr, signinRes) {
|
||||
|
||||
// // // Handle signin error
|
||||
// // if (signinErr) throw signinErr;
|
||||
// Handle signin error
|
||||
if (signinErr) throw signinErr;
|
||||
|
||||
// // userSession.get('/auth/signout')
|
||||
// // .expect(200)
|
||||
// // .end(function(signoutErr, signoutRes) {
|
||||
userSession.get('/auth/signout')
|
||||
.expect(200)
|
||||
.end(function(signoutErr, signoutRes) {
|
||||
|
||||
// // // Handle signout error
|
||||
// // if (signoutErr) throw signoutErr;
|
||||
// Handle signout error
|
||||
if (signoutErr) throw 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) {
|
||||
// User.remove().exec(function () {
|
||||
// tmpUser.remove().exec(function(){
|
||||
// // mailbox.deleteAllEmail(function (err, body) {
|
||||
// // if(err) throw err;
|
||||
// userSession.destroy();
|
||||
// done();
|
||||
// // });
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
afterEach(function(done) {
|
||||
User.remove().exec(function () {
|
||||
tmpUser.remove().exec(function(){
|
||||
// mailbox.deleteAllEmail(function (err, body) {
|
||||
// if(err) throw err;
|
||||
userSession.destroy();
|
||||
done();
|
||||
// });
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user