2015-12-12 20:08:48 +00:00
|
|
|
// 'use strict';
|
2015-09-10 22:06:28 +00:00
|
|
|
|
2015-12-12 20:08:48 +00:00
|
|
|
// /**
|
|
|
|
// * Module dependencies.
|
|
|
|
// */
|
|
|
|
// var should = require('should'),
|
|
|
|
// mongoose = require('mongoose'),
|
|
|
|
// User = mongoose.model('User'),
|
|
|
|
// Form = mongoose.model('Form'),
|
|
|
|
// Field = mongoose.model('Field'),
|
|
|
|
// _ = require('lodash'),
|
|
|
|
// config = require('../../config/config'),
|
|
|
|
// FormSubmission = mongoose.model('FormSubmission');
|
2015-09-10 22:06:28 +00:00
|
|
|
|
2015-09-10 22:06:28 +00:00
|
|
|
|
2015-10-06 20:24:02 +00:00
|
|
|
|
2015-12-12 20:08:48 +00:00
|
|
|
// 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'
|
|
|
|
// };
|
2015-09-10 22:06:28 +00:00
|
|
|
|
2015-12-12 20:08:48 +00:00
|
|
|
// /**
|
|
|
|
// * Globals
|
|
|
|
// */
|
|
|
|
// var user, myForm, mySubmission;
|
2015-09-10 22:06:28 +00:00
|
|
|
|
2015-12-12 20:08:48 +00:00
|
|
|
// /**
|
|
|
|
// * Unit tests
|
|
|
|
// */
|
|
|
|
// describe('Form Model Unit Tests:', function() {
|
|
|
|
// this.timeout(15000);
|
|
|
|
// beforeEach(function(done) {
|
|
|
|
// user = new User({
|
|
|
|
// firstName: 'Full',
|
|
|
|
// lastName: 'Name',
|
|
|
|
// displayName: 'Full Name',
|
|
|
|
// email: 'test@test.com',
|
|
|
|
// username: 'aueoaueoa',
|
|
|
|
// password: 'password',
|
|
|
|
// provider: 'local'
|
|
|
|
// });
|
2015-10-06 20:14:38 +00:00
|
|
|
|
2015-12-12 20:08:48 +00:00
|
|
|
// user.save(function(err) {
|
|
|
|
// if(err) {
|
|
|
|
// done(err);
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// myForm = new Form({
|
|
|
|
// title: 'Form Title',
|
|
|
|
// admin: user,
|
|
|
|
// language: 'english',
|
|
|
|
// form_fields: [
|
|
|
|
// {'fieldType':'textfield', title:'First Name', 'fieldValue': ''},
|
|
|
|
// {'fieldType':'checkbox', title:'nascar', 'fieldValue': ''},
|
|
|
|
// {'fieldType':'checkbox', title:'hockey', 'fieldValue': ''}
|
|
|
|
// ]
|
|
|
|
// });
|
|
|
|
// done();
|
|
|
|
// });
|
|
|
|
// });
|
2015-09-10 22:06:28 +00:00
|
|
|
|
2015-12-12 20:08:48 +00:00
|
|
|
// describe('Method Save', function() {
|
|
|
|
// it('should be able to save without problems', function(done) {
|
|
|
|
// return myForm.save(function(err) {
|
|
|
|
// should.not.exist(err);
|
|
|
|
// done();
|
|
|
|
// });
|
|
|
|
// });
|
2015-09-10 22:06:28 +00:00
|
|
|
|
2015-12-12 20:08:48 +00:00
|
|
|
// it('should be able to show an error when try to save without title', function(done) {
|
2015-09-10 22:06:28 +00:00
|
|
|
|
2015-12-12 20:08:48 +00:00
|
|
|
// var _form = myForm;
|
|
|
|
// _form.title = '';
|
2015-10-06 20:24:02 +00:00
|
|
|
|
2015-12-12 20:08:48 +00:00
|
|
|
// return _form.save(function(err) {
|
|
|
|
// should.exist(err);
|
|
|
|
// should.equal(err.errors.title.message, 'Form Title cannot be blank');
|
|
|
|
// done();
|
|
|
|
// });
|
|
|
|
// });
|
|
|
|
// });
|
2015-09-10 22:06:28 +00:00
|
|
|
|
2015-12-12 20:08:48 +00:00
|
|
|
// describe('Method Find', function(){
|
|
|
|
// beforeEach(function(done){
|
|
|
|
// myForm.save(function(err) {
|
|
|
|
// if(err) return done(err);
|
|
|
|
// done();
|
|
|
|
// });
|
|
|
|
// });
|
|
|
|
// it('should be able to findOne my form without problems', function(done) {
|
|
|
|
// return Form.findOne({title: myForm.title}).exec(function(err,form) {
|
|
|
|
// should.not.exist(err);
|
|
|
|
// should.exist(form);
|
|
|
|
// should.deepEqual(form.toObject(), myForm.toObject());
|
|
|
|
// done();
|
|
|
|
// });
|
|
|
|
// });
|
|
|
|
// });
|
2015-09-10 22:06:28 +00:00
|
|
|
|
2015-12-12 20:08:48 +00:00
|
|
|
// afterEach(function(done) {
|
|
|
|
// Form.remove().exec(function() {
|
|
|
|
// User.remove().exec(done);
|
|
|
|
// });
|
|
|
|
// });
|
|
|
|
// });
|