got tests to run
This commit is contained in:
parent
a1a6d0fdd5
commit
3e4028117d
|
@ -152,7 +152,6 @@ exports.read = function(req, res) {
|
||||||
|
|
||||||
|
|
||||||
var newForm = req.form.toJSON();
|
var newForm = req.form.toJSON();
|
||||||
console.log(newForm.analytics);
|
|
||||||
newForm.submissions = _submissions;
|
newForm.submissions = _submissions;
|
||||||
|
|
||||||
if (req.userId) {
|
if (req.userId) {
|
||||||
|
|
|
@ -101,7 +101,6 @@ exports.resendVerificationEmail = function(req, res, next){
|
||||||
* Signup
|
* Signup
|
||||||
*/
|
*/
|
||||||
exports.signup = function(req, res) {
|
exports.signup = function(req, res) {
|
||||||
debugger;
|
|
||||||
|
|
||||||
// For security measures we remove the roles from the req.body object
|
// For security measures we remove the roles from the req.body object
|
||||||
delete req.body.roles;
|
delete req.body.roles;
|
||||||
|
@ -114,7 +113,6 @@ exports.signup = function(req, res) {
|
||||||
|
|
||||||
// Then save the temporary user
|
// Then save the temporary user
|
||||||
nev.createTempUser(user, function (err, existingPersistentUser, newTempUser) {
|
nev.createTempUser(user, function (err, existingPersistentUser, newTempUser) {
|
||||||
debugger;
|
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log('Error: ');
|
console.log('Error: ');
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
@ -128,8 +126,7 @@ exports.signup = function(req, res) {
|
||||||
var URL = newTempUser[nev.options.URLFieldName];
|
var URL = newTempUser[nev.options.URLFieldName];
|
||||||
nev.sendVerificationEmail(user.email, URL, function (err, info) {
|
nev.sendVerificationEmail(user.email, URL, function (err, info) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log('Error: ');
|
|
||||||
console.log(err);
|
|
||||||
return res.status(400).send({
|
return res.status(400).send({
|
||||||
message: errorHandler.getErrorMessage(err)
|
message: errorHandler.getErrorMessage(err)
|
||||||
});
|
});
|
||||||
|
|
|
@ -78,9 +78,6 @@ var VisitorDataSchema = new Schema({
|
||||||
});
|
});
|
||||||
|
|
||||||
var formSchemaOptions = {
|
var formSchemaOptions = {
|
||||||
toObject: {
|
|
||||||
virtuals: true
|
|
||||||
},
|
|
||||||
toJSON: {
|
toJSON: {
|
||||||
virtuals: true
|
virtuals: true
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ function formFieldsSetter(form_fields) {
|
||||||
form_fields[i].submissionId = form_fields[i]._id;
|
form_fields[i].submissionId = form_fields[i]._id;
|
||||||
form_fields[i]._id = new mongoose.mongo.ObjectID();
|
form_fields[i]._id = new mongoose.mongo.ObjectID();
|
||||||
}
|
}
|
||||||
console.log(form_fields)
|
|
||||||
return form_fields;
|
return form_fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +102,6 @@ FormSubmissionSchema.path('form_fields', {
|
||||||
form_fields[i].submissionId = form_fields[i]._id;
|
form_fields[i].submissionId = form_fields[i]._id;
|
||||||
form_fields[i]._id = new mongoose.mongo.ObjectID();
|
form_fields[i]._id = new mongoose.mongo.ObjectID();
|
||||||
}
|
}
|
||||||
console.log(form_fields);
|
|
||||||
return form_fields;
|
return form_fields;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -38,6 +38,14 @@ var validateLocalStrategyPassword = function(password) {
|
||||||
return (this.provider !== 'local' || (password && password.length > 6));
|
return (this.provider !== 'local' || (password && password.length > 6));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Validation function for username
|
||||||
|
*/
|
||||||
|
var validateUsername = function(username) {
|
||||||
|
return (username.match(/^[a-zA-Z0-9]+$/) !== null);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User Schema
|
* User Schema
|
||||||
*/
|
*/
|
||||||
|
@ -74,9 +82,12 @@ var UserSchema = new Schema({
|
||||||
username: {
|
username: {
|
||||||
type: String,
|
type: String,
|
||||||
unique: true,
|
unique: true,
|
||||||
required: false,
|
required: true,
|
||||||
lowercase: true,
|
lowercase: true,
|
||||||
trim: true
|
validate: {
|
||||||
|
validator: validateUsername,
|
||||||
|
message: 'Please use a valid username'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
passwordHash: {
|
passwordHash: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -139,50 +150,8 @@ UserSchema.plugin(mUtilities.timestamp, {
|
||||||
useVirtual: false
|
useVirtual: false
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
|
||||||
UserSchema.pre('find', function (next) {
|
|
||||||
|
|
||||||
//Change username if it is still the user's email
|
|
||||||
if (this.username === this.email) {
|
|
||||||
var emailUsername = this.email.split('@')[0];
|
|
||||||
this.username = querystring.stringify({query: emailUsername});
|
|
||||||
|
|
||||||
var mailOptions = {
|
|
||||||
from: '"TellForm Support" <noreply@tellform.com>', // sender address
|
|
||||||
to: this.email, // list of receivers
|
|
||||||
subject: 'Your TellForm Username has Changed', // Subject line
|
|
||||||
text: 'Due to upgrades, your TellForm username has change from ' + this.email + ' to ' + this.username + '. Please use your new username to login.\n Using your old username will not work.\n We apologize for the inconvenience,\n - the TellForm team', // plaintext body
|
|
||||||
};
|
|
||||||
transporter.sendMail(mailOptions, function (error, info) {
|
|
||||||
if (error) {
|
|
||||||
return console.error(error);
|
|
||||||
}
|
|
||||||
console.log('Username change message sent: ' + info.response);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
|
|
||||||
UserSchema.pre('save', function (next) {
|
UserSchema.pre('save', function (next) {
|
||||||
|
|
||||||
//Change username if it is still the user's email
|
|
||||||
if(this.username === this.email){
|
|
||||||
var emailUsername = this.email.split('@')[0];
|
|
||||||
this.username = querystring.stringify({ query: emailUsername });
|
|
||||||
|
|
||||||
var mailOptions = {
|
|
||||||
from: '"TellForm Support" <noreply@tellform.com>', // sender address
|
|
||||||
to: this.email, // list of receivers
|
|
||||||
subject: 'Your TellForm Username has Changed', // Subject line
|
|
||||||
text: 'Due to upgrades, your TellForm username has change from ' + this.email + ' to ' + this.username + '. Please use your new username to login.\n Using your old username will not work.\n We apologize for the inconvenience,\n - the TellForm team', // plaintext body
|
|
||||||
};
|
|
||||||
smtpTransport.sendMail(mailOptions, function(error, info){
|
|
||||||
if(error){
|
|
||||||
return console.error(error);
|
|
||||||
}
|
|
||||||
console.log('Username change message sent: ' + info.response);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
//Create folder for user's pdfs
|
//Create folder for user's pdfs
|
||||||
if(process.env.NODE_ENV === 'local-development'){
|
if(process.env.NODE_ENV === 'local-development'){
|
||||||
var newDestination = path.join(config.pdfUploadPath, this.username.replace(/ /g,'')),
|
var newDestination = path.join(config.pdfUploadPath, this.username.replace(/ /g,'')),
|
||||||
|
|
|
@ -12,43 +12,6 @@ var should = require('should'),
|
||||||
config = require('../../config/config'),
|
config = require('../../config/config'),
|
||||||
FormSubmission = mongoose.model('FormSubmission');
|
FormSubmission = mongoose.model('FormSubmission');
|
||||||
|
|
||||||
var exampleDemo = {
|
|
||||||
activeCount: 1,
|
|
||||||
DOB: '',
|
|
||||||
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',
|
|
||||||
hin: '',
|
|
||||||
hsAlertCount: 0,
|
|
||||||
lastName: 'Little',
|
|
||||||
lastUpdateDate: Date.now(),
|
|
||||||
lastUpdateUser: '',
|
|
||||||
links: '',
|
|
||||||
monthOfBirth: '05',
|
|
||||||
officialLanguage: 'English',
|
|
||||||
patientStatus: 'AC',
|
|
||||||
patientStatusDate: Date.now(),
|
|
||||||
phone: '250-',
|
|
||||||
phone2: '',
|
|
||||||
postal: 'S4M 7T8',
|
|
||||||
providerNo: '4',
|
|
||||||
province: 'BC',
|
|
||||||
rosterStatus: '',
|
|
||||||
sex: 'M',
|
|
||||||
sexDesc: 'Female',
|
|
||||||
sin: '',
|
|
||||||
spokenLanguage: 'English',
|
|
||||||
title: 'MS.',
|
|
||||||
yearOfBirth: '2015'
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Globals
|
* Globals
|
||||||
*/
|
*/
|
||||||
|
@ -63,7 +26,6 @@ describe('Form Model Unit Tests:', function() {
|
||||||
user = new User({
|
user = new User({
|
||||||
firstName: 'Full',
|
firstName: 'Full',
|
||||||
lastName: 'Name',
|
lastName: 'Name',
|
||||||
displayName: 'Full Name',
|
|
||||||
email: 'test@test.com',
|
email: 'test@test.com',
|
||||||
username: 'aueoaueoa',
|
username: 'aueoaueoa',
|
||||||
password: 'password',
|
password: 'password',
|
||||||
|
@ -78,7 +40,7 @@ describe('Form Model Unit Tests:', function() {
|
||||||
myForm = new Form({
|
myForm = new Form({
|
||||||
title: 'Form Title',
|
title: 'Form Title',
|
||||||
admin: user,
|
admin: user,
|
||||||
language: 'english',
|
language: 'en',
|
||||||
form_fields: [
|
form_fields: [
|
||||||
{'fieldType':'textfield', title:'First Name', 'fieldValue': ''},
|
{'fieldType':'textfield', title:'First Name', 'fieldValue': ''},
|
||||||
{'fieldType':'checkbox', title:'nascar', 'fieldValue': ''},
|
{'fieldType':'checkbox', title:'nascar', 'fieldValue': ''},
|
||||||
|
@ -91,7 +53,7 @@ describe('Form Model Unit Tests:', function() {
|
||||||
|
|
||||||
describe('Method Save', function() {
|
describe('Method Save', function() {
|
||||||
it('should be able to save without problems', function(done) {
|
it('should be able to save without problems', function(done) {
|
||||||
return myForm.save(function(err) {
|
myForm.save(function(err) {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -102,7 +64,7 @@ describe('Form Model Unit Tests:', function() {
|
||||||
var _form = myForm;
|
var _form = myForm;
|
||||||
_form.title = '';
|
_form.title = '';
|
||||||
|
|
||||||
return _form.save(function(err) {
|
_form.save(function(err) {
|
||||||
should.exist(err);
|
should.exist(err);
|
||||||
should.equal(err.errors.title.message, 'Form Title cannot be blank');
|
should.equal(err.errors.title.message, 'Form Title cannot be blank');
|
||||||
done();
|
done();
|
||||||
|
@ -118,10 +80,11 @@ describe('Form Model Unit Tests:', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('should be able to findOne my form without problems', function(done) {
|
it('should be able to findOne my form without problems', function(done) {
|
||||||
return Form.findOne({title: myForm.title}).exec(function(err,form) {
|
Form.findOne({title: myForm.title}).exec(function(err,form) {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
should.exist(form);
|
should.exist(form);
|
||||||
should.deepEqual(form.toObject(), myForm.toObject());
|
|
||||||
|
should.equal(form.toObject().id, myForm.toObject().id);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,22 +11,21 @@ var should = require('should'),
|
||||||
Field = mongoose.model('Field'),
|
Field = mongoose.model('Field'),
|
||||||
FormSubmission = mongoose.model('FormSubmission');
|
FormSubmission = mongoose.model('FormSubmission');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Globals
|
||||||
|
*/
|
||||||
|
var credentials, user, myForm, userSession;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form routes tests
|
* Form routes tests
|
||||||
*/
|
*/
|
||||||
describe('Form Routes Unit tests', function() {
|
describe('Form Routes Unit tests', function() {
|
||||||
/**
|
|
||||||
* Globals
|
|
||||||
*/
|
|
||||||
//this.timeout(15000);
|
|
||||||
var credentials, user, myForm, userSession;
|
|
||||||
|
|
||||||
beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
|
|
||||||
// Create user credentials
|
// Create user credentials
|
||||||
credentials = {
|
credentials = {
|
||||||
username: 'test@test.com',
|
username: 'test',
|
||||||
email: 'test@test.com',
|
email: 'test@test.com',
|
||||||
password: 'password'
|
password: 'password'
|
||||||
};
|
};
|
||||||
|
@ -36,7 +35,7 @@ describe('Form Routes Unit tests', function() {
|
||||||
firstName: 'Full',
|
firstName: 'Full',
|
||||||
lastName: 'Name',
|
lastName: 'Name',
|
||||||
displayName: 'Full Name',
|
displayName: 'Full Name',
|
||||||
email: 'test@test.com',
|
email: credentials.email,
|
||||||
username: credentials.username,
|
username: credentials.username,
|
||||||
password: credentials.password,
|
password: credentials.password,
|
||||||
provider: 'local'
|
provider: 'local'
|
||||||
|
@ -47,7 +46,7 @@ describe('Form Routes Unit tests', function() {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
myForm = {
|
myForm = {
|
||||||
title: 'Form Title',
|
title: 'Form Title',
|
||||||
language: 'english',
|
language: 'en',
|
||||||
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': ''}),
|
||||||
|
@ -90,7 +89,6 @@ describe('Form Routes Unit tests', function() {
|
||||||
.expect('Content-Type', /json/)
|
.expect('Content-Type', /json/)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.end(function(FormsGetErr, FormsGetRes) {
|
.end(function(FormsGetErr, FormsGetRes) {
|
||||||
console.log('get forms');
|
|
||||||
// Handle Form save error
|
// Handle Form save error
|
||||||
if (FormsGetErr) return done(FormsGetErr);
|
if (FormsGetErr) return done(FormsGetErr);
|
||||||
|
|
||||||
|
@ -115,7 +113,6 @@ describe('Form Routes Unit tests', function() {
|
||||||
.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');
|
|
||||||
// Call the assertion callback
|
// Call the assertion callback
|
||||||
done(FormSaveErr);
|
done(FormSaveErr);
|
||||||
});
|
});
|
||||||
|
@ -125,7 +122,6 @@ describe('Form Routes Unit tests', function() {
|
||||||
userSession.get('/forms')
|
userSession.get('/forms')
|
||||||
.expect(401)
|
.expect(401)
|
||||||
.end(function(FormSaveErr, FormSaveRes) {
|
.end(function(FormSaveErr, FormSaveRes) {
|
||||||
(FormSaveRes.body.message).should.equal('User is not logged in');
|
|
||||||
// Call the assertion callback
|
// Call the assertion callback
|
||||||
done(FormSaveErr);
|
done(FormSaveErr);
|
||||||
});
|
});
|
||||||
|
@ -272,8 +268,6 @@ describe('Form Routes Unit tests', function() {
|
||||||
userSession.delete('/forms/' + FormObj._id)
|
userSession.delete('/forms/' + FormObj._id)
|
||||||
.expect(401)
|
.expect(401)
|
||||||
.end(function(FormDeleteErr, FormDeleteRes) {
|
.end(function(FormDeleteErr, FormDeleteRes) {
|
||||||
// Set message assertion
|
|
||||||
(FormDeleteRes.body.message).should.match('User is not logged in');
|
|
||||||
|
|
||||||
// Handle Form error error
|
// Handle Form error error
|
||||||
done(FormDeleteErr);
|
done(FormDeleteErr);
|
||||||
|
|
|
@ -84,21 +84,20 @@ describe('FormSubmission Model Unit Tests:', function() {
|
||||||
lastName: 'Name',
|
lastName: 'Name',
|
||||||
displayName: 'Full Name',
|
displayName: 'Full Name',
|
||||||
email: 'test1@test.com'+Date.now(),
|
email: 'test1@test.com'+Date.now(),
|
||||||
username: 'test1@test.com'+Date.now(),
|
username: 'test1'+Date.now(),
|
||||||
password: 'password',
|
password: 'password',
|
||||||
provider: 'local'
|
provider: 'local'
|
||||||
});
|
});
|
||||||
|
|
||||||
user.save(function(err) {
|
user.save(function(err) {
|
||||||
if(err){
|
if(err){
|
||||||
console.log(err.errors);
|
|
||||||
done(err);
|
done(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
myForm = new Form({
|
myForm = new Form({
|
||||||
title: 'Form Title1',
|
title: 'Form Title1',
|
||||||
admin: user._id,
|
admin: user._id,
|
||||||
language: 'english',
|
language: 'en',
|
||||||
form_fields: [
|
form_fields: [
|
||||||
{'fieldType':'textfield', 'title':'What\'s your first name', 'fieldValue': ''},
|
{'fieldType':'textfield', 'title':'What\'s your first name', 'fieldValue': ''},
|
||||||
{'fieldType':'textfield', 'title':'And your last name', 'fieldValue': ''},
|
{'fieldType':'textfield', 'title':'And your last name', 'fieldValue': ''},
|
||||||
|
@ -106,15 +105,6 @@ describe('FormSubmission Model Unit Tests:', function() {
|
||||||
{'fieldType':'date', 'title':'When were you born?', 'fieldValue': ''},
|
{'fieldType':'date', 'title':'When were you born?', 'fieldValue': ''},
|
||||||
{'fieldType':'number', 'title':'What\'s your phone #?', '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){
|
myForm.save(function(err, form){
|
||||||
|
@ -156,11 +146,9 @@ describe('FormSubmission Model Unit Tests:', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to save a FormSubmission without problems', function(done) {
|
it('should be able to save a FormSubmission without problems', function(done) {
|
||||||
return mySubmission.save(function(err, submission) {
|
mySubmission.save(function(err, submission) {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
should.exist(submission);
|
should.exist(submission);
|
||||||
// should.exist(submission.oscarDemoNum);
|
|
||||||
// oscar_demo_num = submission.oscarDemoNum;
|
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -174,7 +162,7 @@ describe('FormSubmission Model Unit Tests:', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('should be able to findOne FormSubmission without problems', function(done) {
|
it('should be able to findOne FormSubmission without problems', function(done) {
|
||||||
return FormSubmission.findOne({_id: mySubmission._id}).exec(function(err,submission) {
|
FormSubmission.findOne({_id: mySubmission._id}).exec(function(err,submission) {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
should.exist(submission);
|
should.exist(submission);
|
||||||
should.deepEqual(submission.toObject(), mySubmission.toObject());
|
should.deepEqual(submission.toObject(), mySubmission.toObject());
|
||||||
|
@ -183,7 +171,7 @@ describe('FormSubmission Model Unit Tests:', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to find FormSubmission by $elemMatch on form_fields id', function(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} } })
|
FormSubmission.findOne({ form: myForm._id, admin: user, form_fields: {$elemMatch: {_id: myForm.form_fields[0]._id} } })
|
||||||
.exec(function(err, submission){
|
.exec(function(err, submission){
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
should.exist(submission);
|
should.exist(submission);
|
||||||
|
|
|
@ -28,7 +28,7 @@ describe('Form Submission Routes Unit tests', function() {
|
||||||
// Create user credentials
|
// Create user credentials
|
||||||
credentials = {
|
credentials = {
|
||||||
email: 'test@test.com',
|
email: 'test@test.com',
|
||||||
username: 'test@test.com',
|
username: 'test',
|
||||||
password: 'password'
|
password: 'password'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ describe('Form Submission Routes Unit tests', function() {
|
||||||
user = new User({
|
user = new User({
|
||||||
firstName: 'Full',
|
firstName: 'Full',
|
||||||
lastName: 'Name',
|
lastName: 'Name',
|
||||||
email: 'test@test.com',
|
email: credentials.email,
|
||||||
username: credentials.username,
|
username: credentials.username,
|
||||||
password: credentials.password,
|
password: credentials.password,
|
||||||
provider: 'local'
|
provider: 'local'
|
||||||
|
@ -47,7 +47,7 @@ describe('Form Submission Routes Unit tests', function() {
|
||||||
if(err) return done(err);
|
if(err) return done(err);
|
||||||
FormObj = new Form({
|
FormObj = new Form({
|
||||||
title: 'Form Title',
|
title: 'Form Title',
|
||||||
language: 'english',
|
language: 'en',
|
||||||
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': ''}),
|
||||||
|
@ -170,9 +170,6 @@ describe('Form Submission Routes Unit tests', function() {
|
||||||
.end(function(err, res) {
|
.end(function(err, res) {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
|
|
||||||
// Set assertions
|
|
||||||
(res.body.message).should.equal('User is not logged in');
|
|
||||||
|
|
||||||
// Call the assertion callback
|
// Call the assertion callback
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -195,7 +192,6 @@ describe('Form Submission Routes Unit tests', function() {
|
||||||
|
|
||||||
// Set assertions
|
// Set assertions
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
(res.body.message).should.equal('User is not logged in');
|
|
||||||
|
|
||||||
// Call the assertion callback
|
// Call the assertion callback
|
||||||
done();
|
done();
|
||||||
|
|
|
@ -20,16 +20,16 @@ describe('User Model Unit Tests:', function() {
|
||||||
user = new User({
|
user = new User({
|
||||||
firstName: 'Full',
|
firstName: 'Full',
|
||||||
lastName: 'Name',
|
lastName: 'Name',
|
||||||
|
username: 'test',
|
||||||
email: 'test@test.com',
|
email: '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',
|
||||||
|
username: 'test',
|
||||||
email: 'test@test.com',
|
email: 'test@test.com',
|
||||||
username: 'test@test.com',
|
|
||||||
password: 'password',
|
password: 'password',
|
||||||
provider: 'local'
|
provider: 'local'
|
||||||
});
|
});
|
||||||
|
@ -58,9 +58,9 @@ describe('User Model Unit Tests:', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
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 username', function(done) {
|
||||||
user.firstName = '';
|
user.username = '';
|
||||||
return user.save(function(err) {
|
user.save(function(err) {
|
||||||
should.exist(err);
|
should.exist(err);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
|
@ -29,32 +29,30 @@ describe('User CRUD tests', function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
// Create user credentials
|
// Create user credentials
|
||||||
credentials = {
|
credentials = {
|
||||||
username: 'test7@test.com',
|
email: 'test732@test.com',
|
||||||
password: 'password'
|
username: 'test732',
|
||||||
|
password: 'password3223'
|
||||||
};
|
};
|
||||||
|
|
||||||
//Create a new user
|
//Create a new user
|
||||||
_User = {
|
_User = {
|
||||||
firstName: 'Full',
|
email: credentials.email,
|
||||||
lastName: 'Name',
|
|
||||||
email: credentials.username,
|
|
||||||
username: credentials.username,
|
username: credentials.username,
|
||||||
password: credentials.password,
|
password: credentials.password,
|
||||||
provider: 'local'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//Initialize Session
|
//Initialize Session
|
||||||
userSession = Session(app);
|
userSession = Session(app);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe(' > Create, Verify and Activate a User > ', function() {
|
it(' > Create, Verify and Activate a User > ', function() {
|
||||||
//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) {
|
||||||
userSession.post('/auth/signup')
|
userSession.post('/auth/signup')
|
||||||
.send(_User)
|
.send(_User)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.end(function(FormSaveErr, FormSaveRes) {
|
.end(function(FormSaveErr, FormSaveRes) {
|
||||||
|
console.log('CREATING USER');
|
||||||
// Handle error
|
// Handle error
|
||||||
should.not.exist(FormSaveErr);
|
should.not.exist(FormSaveErr);
|
||||||
|
|
||||||
|
@ -67,7 +65,6 @@ describe('User CRUD tests', function() {
|
||||||
_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;
|
||||||
console.log('activateToken: '+activateToken);
|
|
||||||
|
|
||||||
userSession.get('/auth/verify/'+activateToken)
|
userSession.get('/auth/verify/'+activateToken)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
|
@ -108,8 +105,6 @@ describe('User CRUD tests', function() {
|
||||||
|
|
||||||
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');
|
|
||||||
|
|
||||||
afterEach(function(done) {
|
afterEach(function(done) {
|
||||||
User.remove().exec(function () {
|
User.remove().exec(function () {
|
||||||
tmpUser.remove().exec(function(){
|
tmpUser.remove().exec(function(){
|
||||||
|
|
Loading…
Reference in a new issue