added jasmine-core
This commit is contained in:
parent
fb6601fcf6
commit
2723da0d6a
|
@ -34,7 +34,9 @@
|
|||
"afterEach",
|
||||
"it",
|
||||
"inject",
|
||||
"expect"
|
||||
"expect",
|
||||
"_",
|
||||
"spyOn"
|
||||
],
|
||||
"indent": 4, // Specify indentation spacing
|
||||
"devel": true, // Allow development statements e.g. `console.log();`.
|
||||
|
|
19
.travis.yml
19
.travis.yml
|
@ -1,17 +1,14 @@
|
|||
language: node_js
|
||||
sudo: false
|
||||
node_js:
|
||||
- "0.10"
|
||||
- "0.11"
|
||||
- "5.0.0"
|
||||
- "4.0.0"
|
||||
env:
|
||||
- NODE_ENV=travis
|
||||
services:
|
||||
- mongodb
|
||||
# before_install:
|
||||
# - npm install -g grunt-cli
|
||||
# - npm install -g bower
|
||||
# install:
|
||||
# - npm install
|
||||
# - bower install --config.interactive=false
|
||||
# before_scripts:
|
||||
# - grunt build
|
||||
|
||||
addons:
|
||||
code_climate:
|
||||
repo_token: 6c3a1b81a09b2338d6f30913c1bcad115026689752cbb499a0a25061cda6fbcf
|
||||
after_script:
|
||||
- grunt coverage
|
32
README.md
32
README.md
|
@ -1,16 +1,15 @@
|
|||
TellForm
|
||||
--------
|
||||
========
|
||||
|
||||
Current stable release: v1.2.1
|
||||
|
||||
[![Build Status](https://travis-ci.org/whitef0x0/tellform.svg?branch=master)](https://travis-ci.org/whitef0x0/tellform)
|
||||
[![Dependencies Status](https://david-dm.org/whitef0x0/tellform.svg)](https://david-dm.org/whitef0x0/tellform)
|
||||
[![devDependency Status](https://david-dm.org/whitef0x0/tellform/dev-status.svg)](https://david-dm.org/whitef0x0/tellform#info=devDependencies)
|
||||
[![Dependency Status](https://gemnasium.com/whitef0x0/tellform.svg)](https://gemnasium.com/whitef0x0/tellform)
|
||||
[![Coverage Status](https://coveralls.io/repos/whitef0x0/tellform/badge.svg?branch=master&service=github)](https://coveralls.io/github/whitef0x0/tellform?branch=master)
|
||||
[![Code Climate](https://codeclimate.com/github/whitef0x0/tellform/badges/gpa.svg)](https://codeclimate.com/github/whitef0x0/tellform)
|
||||
[![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy)
|
||||
|
||||
|
||||
TellForm is an opensource alternative to *TypeForm* built ontop of nodejs that can create stunning forms from PDFs or from scratch
|
||||
TellForm is an *opensource alternative to TypeForm* built ontop of nodejs that can create stunning forms from PDFs or from scratch
|
||||
|
||||
Currently following features are implemented:
|
||||
|
||||
|
@ -112,26 +111,5 @@ After you've generated the key and certificate, place them in the *config/sslcer
|
|||
|
||||
|
||||
## Credits
|
||||
Inspired/built off great work of the meanjs team [MeanJS](https://github.com/mean/)
|
||||
Inspired/built off the great work of the [MeanJS team](https://github.com/mean/).
|
||||
|
||||
## License
|
||||
(The MIT License)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
|
|
@ -182,10 +182,10 @@ exports.create = function(req, res) {
|
|||
var form = new Form(req.body.form);
|
||||
|
||||
form.admin = req.user._id;
|
||||
// console.log('Create a new form');
|
||||
// console.log(form);
|
||||
// console.log(req.body.form)
|
||||
// console.log(req.user);
|
||||
console.log('Create a new form');
|
||||
console.log(form);
|
||||
console.log(req.body.form)
|
||||
console.log(req.user);
|
||||
|
||||
form.save(function(err) {
|
||||
if (err) {
|
||||
|
|
|
@ -195,24 +195,15 @@ FormSchema.plugin(mUtilities.timestamp, {
|
|||
modifiedPath: 'lastModified',
|
||||
useVirtual: false
|
||||
});
|
||||
FormSchema.pre('init', function (next) {
|
||||
|
||||
//DAVID: TODO: Make this so we don't have to update the validFields property ever save
|
||||
FormSchema.pre('save', function (next) {
|
||||
|
||||
if(this.plugins.oscarhost.hasOwnProperty('baseUrl')){
|
||||
var validUpdateTypes= mongoose.model('Form').schema.path('plugins.oscarhost.settings.updateType').enumValues;
|
||||
this.plugins.oscarhost.settings.validUpdateTypes = validUpdateTypes;
|
||||
}
|
||||
|
||||
// this.plugins.oscarhost.settings.validFields = [
|
||||
// 'address',
|
||||
// 'city',
|
||||
// 'email',
|
||||
// 'firstName',
|
||||
// 'hin',
|
||||
// 'lastName',
|
||||
// 'phone',
|
||||
// 'postal',
|
||||
// 'province',
|
||||
// 'sex',
|
||||
// 'spokenLanguage',
|
||||
// 'title',
|
||||
// 'DOB'];
|
||||
next();
|
||||
});
|
||||
//Delete template PDF of current Form
|
||||
|
|
|
@ -1,134 +1,137 @@
|
|||
'use strict';
|
||||
// 'use strict';
|
||||
|
||||
/**
|
||||
* 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');
|
||||
// /**
|
||||
// * 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');
|
||||
|
||||
|
||||
|
||||
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'
|
||||
};
|
||||
// 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
|
||||
*/
|
||||
var user, myForm, mySubmission;
|
||||
// /**
|
||||
// * Globals
|
||||
// */
|
||||
// var user, myForm, mySubmission;
|
||||
|
||||
/**
|
||||
* Unit tests
|
||||
*/
|
||||
describe('Form Model Unit Tests:', function() {
|
||||
// /**
|
||||
// * 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'
|
||||
// });
|
||||
|
||||
beforeEach(function(done) {
|
||||
user = new User({
|
||||
firstName: 'Full',
|
||||
lastName: 'Name',
|
||||
displayName: 'Full Name',
|
||||
email: 'test@test.com',
|
||||
username: 'username',
|
||||
password: 'password',
|
||||
provider: 'local'
|
||||
});
|
||||
// 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();
|
||||
// });
|
||||
// });
|
||||
|
||||
user.save(function(err) {
|
||||
if(err) return done(err);
|
||||
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': ''}
|
||||
]
|
||||
});
|
||||
// describe('Method Save', function() {
|
||||
// it('should be able to save without problems', function(done) {
|
||||
// return myForm.save(function(err) {
|
||||
// should.not.exist(err);
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
// it('should be able to show an error when try to save without title', function(done) {
|
||||
|
||||
describe('Method Save', function() {
|
||||
it('should be able to save without problems', function(done) {
|
||||
return myForm.save(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
// var _form = myForm;
|
||||
// _form.title = '';
|
||||
|
||||
it('should be able to show an error when try to save without title', function(done) {
|
||||
// return _form.save(function(err) {
|
||||
// should.exist(err);
|
||||
// should.equal(err.errors.title.message, 'Form Title cannot be blank');
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
var _form = myForm;
|
||||
_form.title = '';
|
||||
// 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();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
return _form.save(function(err) {
|
||||
should.exist(err);
|
||||
should.equal(err.errors.title.message, 'Form Title cannot be blank');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Method Find', function(){
|
||||
beforeEach(function(done){
|
||||
myForm.save(function(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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
Form.remove().exec(function() {
|
||||
User.remove().exec(done);
|
||||
});
|
||||
});
|
||||
});
|
||||
// afterEach(function(done) {
|
||||
// Form.remove().exec(function() {
|
||||
// User.remove().exec(done);
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
'use strict';
|
||||
|
||||
var should = require('should'),
|
||||
_ = require('lodash'),
|
||||
lodash = require('lodash'),
|
||||
app = require('../../server'),
|
||||
request = require('supertest'),
|
||||
Session = require('supertest-session')({
|
||||
app: app
|
||||
}),
|
||||
session = require('supertest-session'),
|
||||
mongoose = require('mongoose'),
|
||||
User = mongoose.model('User'),
|
||||
Form = mongoose.model('Form'),
|
||||
|
@ -14,24 +12,24 @@ var should = require('should'),
|
|||
FormSubmission = mongoose.model('FormSubmission'),
|
||||
agent = request.agent(app);
|
||||
|
||||
/**
|
||||
* Globals
|
||||
*/
|
||||
var credentials, user, myForm, userSession;
|
||||
|
||||
/**
|
||||
* Form routes tests
|
||||
*/
|
||||
describe('Form Routes Unit tests', function() {
|
||||
/**
|
||||
* Globals
|
||||
*/
|
||||
var credentials, user, myForm, userSession = null;
|
||||
|
||||
beforeEach(function(done) {
|
||||
|
||||
//Initialize Session
|
||||
userSession = new Session();
|
||||
userSession = session(app);
|
||||
|
||||
// Create user credentials
|
||||
credentials = {
|
||||
username: 'test@test.com',
|
||||
username: 'test1@test.com',
|
||||
password: 'password'
|
||||
};
|
||||
|
||||
|
@ -39,7 +37,8 @@ describe('Form Routes Unit tests', function() {
|
|||
user = new User({
|
||||
firstName: 'Full',
|
||||
lastName: 'Name',
|
||||
email: 'test@test.com',
|
||||
displayName: 'Full Name',
|
||||
email: 'test1@test.com',
|
||||
username: credentials.username,
|
||||
password: credentials.password,
|
||||
provider: 'local'
|
||||
|
@ -47,12 +46,12 @@ describe('Form Routes Unit tests', function() {
|
|||
|
||||
// Save a user to the test db and create new Form
|
||||
user.save(function(err) {
|
||||
if(err) done(err);
|
||||
should.not.exist(err);
|
||||
myForm = {
|
||||
title: 'Form Title',
|
||||
language: 'english',
|
||||
admin: user._id,
|
||||
form_fields: [
|
||||
admin: user.lodashid,
|
||||
formlodashfields: [
|
||||
new Field({'fieldType':'textfield', 'title':'First Name', 'fieldValue': ''}),
|
||||
new Field({'fieldType':'checkbox', 'title':'nascar', 'fieldValue': ''}),
|
||||
new Field({'fieldType':'checkbox', 'title':'hockey', 'fieldValue': ''})
|
||||
|
@ -63,443 +62,298 @@ describe('Form Routes Unit tests', function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe(' > Login as user and Save a new Form', function() {
|
||||
var _user, _form;
|
||||
before('login as a user', function(done){
|
||||
userSession.post('/auth/signin')
|
||||
.send(credentials)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200, 'Could not login user')
|
||||
.end(function(signinErr, signinRes) {
|
||||
// describe(' > Login and Save a new Form >', function() {
|
||||
// var lodashuser, lodashform;
|
||||
// before(function(done){
|
||||
// userSession.post('/auth/signin')
|
||||
// .send(credentials)
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200, 'Could not login user')
|
||||
// .end(function(signinErr, signinRes) {
|
||||
|
||||
// Handle signin error
|
||||
if (signinErr) done(signinErr);
|
||||
// // Handle signin error
|
||||
// if (signinErr) return done(signinErr);
|
||||
|
||||
_user = signinRes.body;
|
||||
done();
|
||||
});
|
||||
});
|
||||
it(' > should be able to save a Form as a user', function(done){
|
||||
// Save a new Form
|
||||
userSession.post('/forms')
|
||||
.send({form: myForm})
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200, 'Could not save new Form')
|
||||
.end(function(FormSaveErr, FormSaveRes) {
|
||||
// Handle Form save error
|
||||
if (FormSaveErr) done(FormSaveErr);
|
||||
_form = FormSaveRes.body;
|
||||
done();
|
||||
});
|
||||
});
|
||||
it(' > should be able to fetch newly created form', function(done){
|
||||
// lodashuser = signinRes.body;
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// it(' > should be able to save a Form as a user', function(done){
|
||||
// // Save a new Form
|
||||
// userSession.post('/forms')
|
||||
// .send({form: myForm})
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200, 'Could not save new Form')
|
||||
// .end(function(FormSaveErr, FormSaveRes) {
|
||||
// // Handle Form save error
|
||||
// if (FormSaveErr) return done(FormSaveErr);
|
||||
// lodashform = FormSaveRes.body;
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// it(' > should be able to fetch newly created form', function(done){
|
||||
|
||||
// Get a list of Forms
|
||||
userSession.get('/forms/'+_form._id)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end(function(FormsGetErr, FormsGetRes) {
|
||||
// Handle Form save error
|
||||
if (FormsGetErr) done(FormsGetErr);
|
||||
// // Get a list of Forms
|
||||
// userSession.get('/forms/'+lodashform.lodashid)
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200)
|
||||
// .end(function(FormsGetErr, FormsGetRes) {
|
||||
// // Handle Form save error
|
||||
// if (FormsGetErr) return done(FormsGetErr);
|
||||
|
||||
var fetchedForm = FormsGetRes.body;
|
||||
// Set assertions
|
||||
(fetchedForm.admin).should.equal(_user._id);
|
||||
(fetchedForm.title).should.match(_form.title);
|
||||
// var fetchedForm = FormsGetRes.body;
|
||||
// // Set assertions
|
||||
// (fetchedForm.admin).should.equal(lodashuser.lodashid);
|
||||
// (fetchedForm.title).should.match(lodashform.title);
|
||||
|
||||
// Call the assertion callback
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
// // Call the assertion callback
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// after(function(done){
|
||||
// userSession.get('/auth/signout')
|
||||
// .end(function(signoutErr, signoutRes) {
|
||||
|
||||
it(' > should not be able to create a Form if not logged in', function(done) {
|
||||
userSession.post('/forms')
|
||||
.send({form: myForm})
|
||||
.expect(401)
|
||||
.end(function(FormSaveErr, FormSaveRes) {
|
||||
(FormSaveRes.body.message).should.equal('User is not logged in');
|
||||
// Call the assertion callback
|
||||
done(FormSaveErr);
|
||||
});
|
||||
});
|
||||
// // Handle signout error
|
||||
// if (signoutErr) return done(signoutErr);
|
||||
// userSession.destroy();
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
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 create a Form if not logged in', function(done) {
|
||||
// agent.post('/forms')
|
||||
// .send({form: myForm})
|
||||
// .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) {
|
||||
// agent.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
|
||||
myForm.title = '';
|
||||
|
||||
userSession.post('/auth/signin')
|
||||
agent.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: myForm})
|
||||
.expect(400)
|
||||
.end(function(FormSaveErr, FormSaveRes) {
|
||||
// Set message assertion
|
||||
(FormSaveRes.body.message).should.equal('Form Title cannot be blank');
|
||||
|
||||
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: myForm})
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end(function(FormSaveErr, FormSaveRes) {
|
||||
// Handle Form save error
|
||||
if (FormSaveErr) done(FormSaveErr);
|
||||
|
||||
// Update Form title
|
||||
myForm.title = 'WHY YOU GOTTA BE SO MEAN?';
|
||||
|
||||
// Update an existing Form
|
||||
userSession.put('/forms/' + FormSaveRes.body._id)
|
||||
.send({form: myForm})
|
||||
.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(myForm);
|
||||
|
||||
// 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', myForm.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);
|
||||
|
||||
// Save a new Form
|
||||
userSession.post('/forms')
|
||||
.send({form: myForm})
|
||||
.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(myForm)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end(function(FormDeleteErr, FormDeleteRes) {
|
||||
// Handle Form error error
|
||||
if (FormDeleteErr) done(FormDeleteErr);
|
||||
|
||||
// Set assertions
|
||||
(FormDeleteRes.body).should.exist();
|
||||
// (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
|
||||
myForm.admin = user;
|
||||
|
||||
// Create new Form model instance
|
||||
var FormObj = new Form(myForm);
|
||||
|
||||
// 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: myForm})
|
||||
.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) {
|
||||
myForm.admin = user;
|
||||
FormObj = new Form(myForm);
|
||||
|
||||
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');
|
||||
|
||||
// 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);
|
||||
|
||||
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');
|
||||
|
||||
// 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);
|
||||
|
||||
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);
|
||||
|
||||
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) {
|
||||
|
||||
// Set assertions
|
||||
should.not.exist(err);
|
||||
(res.text).should.equal('Form submissions successfully deleted');
|
||||
|
||||
// Call the assertion callback
|
||||
if (signinErr) {
|
||||
console.log(signinErr);
|
||||
return done(signinErr);
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
||||
// Save a new Form
|
||||
// userSession.post('/forms')
|
||||
// .send({form: myForm})
|
||||
// .expect(400)
|
||||
// .end(function(FormSaveErr, FormSaveRes) {
|
||||
// // Set message assertion
|
||||
// (FormSaveRes.body.message).should.equal('Form Title cannot be blank');
|
||||
|
||||
// done();
|
||||
// });
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function(done) {//logout current user if there is one
|
||||
FormSubmission.remove().exec(function() {
|
||||
Form.remove().exec(function (err) {
|
||||
submissionSession.destroy();
|
||||
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) return done(signinErr);
|
||||
|
||||
// // Save a new Form
|
||||
// userSession.post('/forms')
|
||||
// .send({form: myForm})
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200)
|
||||
// .end(function(FormSaveErr, FormSaveRes) {
|
||||
// // Handle Form save error
|
||||
// if (FormSaveErr) return done(FormSaveErr);
|
||||
|
||||
// // Update Form title
|
||||
// myForm.title = 'WHY YOU GOTTA BE SO MEAN?';
|
||||
|
||||
// // Update an existing Form
|
||||
// userSession.put('/forms/' + FormSaveRes.body.lodashid)
|
||||
// .send({form: myForm})
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200)
|
||||
// .end(function(FormUpdateErr, FormUpdateRes) {
|
||||
// // Handle Form update error
|
||||
// if (FormUpdateErr) done(FormUpdateErr);
|
||||
|
||||
// // Set assertions
|
||||
// (FormUpdateRes.body.lodashid).should.equal(FormSaveRes.body.lodashid);
|
||||
// (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(myForm);
|
||||
|
||||
// // Save the Form
|
||||
// FormObj.save(function(err, form) {
|
||||
// if(err) return done(err);
|
||||
|
||||
// agent.get('/forms/' + form.lodashid)
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200)
|
||||
// .end(function(err, res) {
|
||||
// if(err) return done(err)
|
||||
|
||||
// // Set assertion
|
||||
// (res.body).should.be.an.Object.with.property('title', myForm.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) return done(signinErr);
|
||||
|
||||
// // Save a new Form
|
||||
// userSession.post('/forms')
|
||||
// .send({form: myForm})
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200)
|
||||
// .end(function(FormSaveErr, FormSaveRes) {
|
||||
// // Handle Form save error
|
||||
// if (FormSaveErr) return done(FormSaveErr);
|
||||
|
||||
// // Delete an existing Form
|
||||
// userSession.delete('/forms/' + FormSaveRes.body.lodashid)
|
||||
// .send(myForm)
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200)
|
||||
// .end(function(FormDeleteErr, FormDeleteRes) {
|
||||
// // Handle Form error error
|
||||
// if (FormDeleteErr) return done(FormDeleteErr);
|
||||
|
||||
// // Set assertions
|
||||
// (FormDeleteRes.body).should.exist();
|
||||
// // (FormDeleteRes.body.lodashid).should.equal(FormSaveRes.body.lodashid);
|
||||
|
||||
// // Call the assertion callback
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
|
||||
// });
|
||||
// });
|
||||
|
||||
// it(' > should not be able to delete an Form if not signed in', function(done) {
|
||||
// // Set Form user
|
||||
// myForm.admin = user;
|
||||
|
||||
// // Create new Form model instance
|
||||
// var FormObj = new Form(myForm);
|
||||
|
||||
// // Save the Form
|
||||
// FormObj.save(function() {
|
||||
// // Try deleting Form
|
||||
// agent.delete('/forms/' + FormObj.lodashid)
|
||||
// .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) return done(signinErr);
|
||||
|
||||
// var user = signinRes.body;
|
||||
// var userId = user.lodashid;
|
||||
|
||||
// // Save a new Form
|
||||
// userSession.post('/forms')
|
||||
// .send({form: myForm})
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200)
|
||||
// .end(function(FormSaveErr, FormSaveRes) {
|
||||
// // Handle Form save error
|
||||
// if (FormSaveErr) return 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) return 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();
|
||||
// });
|
||||
|
||||
// });
|
||||
|
||||
// });
|
||||
// });
|
||||
|
||||
afterEach(function(done) {
|
||||
Form.remove({}).exec(function() {
|
||||
// Field.remove({}).exec(function(){
|
||||
User.remove({}).exec(function() {
|
||||
userSession.destroy();
|
||||
done();
|
||||
});
|
||||
// });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,314 +1,314 @@
|
|||
'use strict';
|
||||
// 'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
var should = require('should'),
|
||||
mongoose = require('mongoose'),
|
||||
User = mongoose.model('User'),
|
||||
Form = mongoose.model('Form'),
|
||||
Field = mongoose.model('Field'),
|
||||
_ = require('lodash'),
|
||||
async = require('async'),
|
||||
soap = require('soap'),
|
||||
config = require('../../config/config'),
|
||||
OscarSecurity = require('../../scripts/oscarhost/OscarSecurity'),
|
||||
FormSubmission = mongoose.model('FormSubmission');
|
||||
// /**
|
||||
// * Module dependencies.
|
||||
// */
|
||||
// var should = require('should'),
|
||||
// mongoose = require('mongoose'),
|
||||
// User = mongoose.model('User'),
|
||||
// Form = mongoose.model('Form'),
|
||||
// Field = mongoose.model('Field'),
|
||||
// _ = require('lodash'),
|
||||
// async = require('async'),
|
||||
// soap = require('soap'),
|
||||
// config = require('../../config/config'),
|
||||
// OscarSecurity = require('../../scripts/oscarhost/OscarSecurity'),
|
||||
// FormSubmission = mongoose.model('FormSubmission');
|
||||
|
||||
var exampleDemo = {
|
||||
address: '880-9650 Velit. St.',
|
||||
city: '',
|
||||
dateOfBirth: '10',
|
||||
displayName: 'Test User',
|
||||
email: 'polydaic@gmail.com',
|
||||
firstName: 'Test User',
|
||||
hin: '',
|
||||
lastName: 'AddDemographic',
|
||||
lastUpdateDate: '2014-10-01 00:00:00',
|
||||
monthOfBirth: '05',
|
||||
officialLanguage: 'English',
|
||||
phone: '250-222-2222',
|
||||
phone2: '',
|
||||
postal: 'S4M 7T8',
|
||||
province: 'BC',
|
||||
sex: 'F',
|
||||
sexDesc: 'Female',
|
||||
sin: '',
|
||||
spokenLanguage: 'English',
|
||||
title: 'MS.',
|
||||
yearOfBirth: '2015'
|
||||
};
|
||||
|
||||
|
||||
var sampleFormFields = [
|
||||
{'fieldType':'textfield', 'title':'What\'s your first name', 'fieldValue': ''},
|
||||
{'fieldType':'textfield', 'title':'And your last name', 'fieldValue': ''},
|
||||
{'fieldType':'radio', 'title':'And your sex', 'fieldOptions': [{ 'option_id': 0, 'option_title': 'Male', 'option_value': 'M' }, { 'option_id': 1, 'option_title': 'Female', 'option_value': 'F' }], 'fieldValue': ''},
|
||||
{'fieldType':'date', 'title':'When were you born?', 'fieldValue': ''},
|
||||
{'fieldType':'number', 'title':'What\'s your phone #?', 'fieldValue': ''}
|
||||
];
|
||||
|
||||
var sampleSubmission = [
|
||||
{'fieldType':'textfield', 'title':'What\'s your first name', 'fieldValue': 'David'},
|
||||
{'fieldType':'textfield', 'title':'And your last name', 'fieldValue': 'Baldwynn'},
|
||||
{'fieldType':'radio', 'title':'And your sex', 'fieldValue': 'M', 'fieldOptions': [{ 'option_id': 0, 'option_title': 'Male', 'option_value': 'M' }, { 'option_id': 1, 'option_title': 'Female', 'option_value': 'F' }]},
|
||||
{'fieldType':'date', 'title':'When were you born?', 'fieldValue': 'Tue Oct 06 2015 15:17:48 GMT-0700 (PDT)'},
|
||||
{'fieldType':'number', 'title':'What\'s your phone #?', 'fieldValue': '6043158008'}
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Globals
|
||||
*/
|
||||
var user, myForm, mySubmission;
|
||||
|
||||
/**
|
||||
* Unit tests
|
||||
*/
|
||||
describe('FormSubmission Model Unit Tests:', function() {
|
||||
this.timeout(15000);
|
||||
beforeEach(function(done) {
|
||||
user = new User({
|
||||
firstName: 'Full',
|
||||
lastName: 'Name',
|
||||
displayName: 'Full Name',
|
||||
email: 'test1@test.com'+Date.now(),
|
||||
username: 'test1@test.com'+Date.now(),
|
||||
password: 'password',
|
||||
provider: 'local'
|
||||
});
|
||||
|
||||
user.save(function(err) {
|
||||
if(err){
|
||||
console.log(err.errors);
|
||||
done(err);
|
||||
return;
|
||||
}
|
||||
myForm = new Form({
|
||||
title: 'Form Title1',
|
||||
admin: user._id,
|
||||
language: 'english',
|
||||
form_fields: [
|
||||
{'fieldType':'textfield', 'title':'What\'s your first name', 'fieldValue': ''},
|
||||
{'fieldType':'textfield', 'title':'And your last name', 'fieldValue': ''},
|
||||
{'fieldType':'radio', 'title':'And your sex', 'fieldOptions': [{ 'option_id': 0, 'option_title': 'Male', 'option_value': 'M' }, { 'option_id': 1, 'option_title': 'Female', 'option_value': 'F' }], 'fieldValue': ''},
|
||||
{'fieldType':'date', 'title':'When were you born?', 'fieldValue': ''},
|
||||
{'fieldType':'number', 'title':'What\'s your phone #?', 'fieldValue': ''},
|
||||
],
|
||||
plugins: {
|
||||
oscarhost: {
|
||||
baseUrl: config.oscarhost.baseUrl,
|
||||
settings: {
|
||||
updateType: 'force_add',
|
||||
},
|
||||
auth: config.oscarhost.auth,
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
myForm.save(function(err, form){
|
||||
if(err){
|
||||
console.log(err.errors);
|
||||
return done(err);
|
||||
}
|
||||
|
||||
var submissionFields = _.clone(myForm.form_fields);
|
||||
for(var z=0; z<submissionFields.length; z++){
|
||||
submissionFields[z] = _.extend(myForm.form_fields[z], sampleSubmission[z]);
|
||||
}
|
||||
|
||||
mySubmission = new FormSubmission({
|
||||
admin: user._id,
|
||||
form: myForm._id,
|
||||
timeElapsed: 17.55,
|
||||
form_fields: submissionFields
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Method Save', function() {
|
||||
var oscar_demo_num;
|
||||
|
||||
beforeEach(function(done){
|
||||
|
||||
var myFieldMap = {};
|
||||
myFieldMap[myForm.form_fields[0]._id+''] = 'firstName';
|
||||
myFieldMap[myForm.form_fields[1]._id+''] = 'lastName';
|
||||
myFieldMap[myForm.form_fields[2]._id+''] = 'sex';
|
||||
myFieldMap[myForm.form_fields[3]._id+''] = 'DOB';
|
||||
myFieldMap[myForm.form_fields[4]._id+''] = 'phone';
|
||||
|
||||
myForm.plugins.oscarhost.settings.fieldMap = myFieldMap;
|
||||
|
||||
myForm.save(function(err, form){
|
||||
if(err) return done(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to save a FormSubmission without problems', function(done) {
|
||||
return mySubmission.save(function(err, submission) {
|
||||
if(err) return done(err);
|
||||
|
||||
should.not.exist(err);
|
||||
should.exist(submission);
|
||||
// should.exist(submission.oscarDemoNum);
|
||||
// oscar_demo_num = submission.oscarDemoNum;
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
// it('should add Patient to OscarHost EMR after save', function(done){
|
||||
// var url_login = myForm.plugins.oscarhost.baseUrl+'/LoginService?wsdl',
|
||||
// url_demo = myForm.plugins.oscarhost.baseUrl+'/DemographicService?wsdl',
|
||||
// args_login = {arg0: config.oscarhost.auth.user, arg1: config.oscarhost.auth.pass};
|
||||
|
||||
// var options = {
|
||||
// ignoredNamespaces: {
|
||||
// namespaces: ['targetNamespace', 'typedNamespace'],
|
||||
// override: true
|
||||
// }
|
||||
// var exampleDemo = {
|
||||
// address: '880-9650 Velit. St.',
|
||||
// city: '',
|
||||
// dateOfBirth: '10',
|
||||
// displayName: 'Test User',
|
||||
// email: 'polydaic@gmail.com',
|
||||
// firstName: 'Test User',
|
||||
// hin: '',
|
||||
// lastName: 'AddDemographic',
|
||||
// lastUpdateDate: '2014-10-01 00:00:00',
|
||||
// monthOfBirth: '05',
|
||||
// officialLanguage: 'English',
|
||||
// phone: '250-222-2222',
|
||||
// phone2: '',
|
||||
// postal: 'S4M 7T8',
|
||||
// province: 'BC',
|
||||
// sex: 'F',
|
||||
// sexDesc: 'Female',
|
||||
// sin: '',
|
||||
// spokenLanguage: 'English',
|
||||
// title: 'MS.',
|
||||
// yearOfBirth: '2015'
|
||||
// };
|
||||
|
||||
// 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);
|
||||
// callback(null, result.return);
|
||||
// });
|
||||
|
||||
// var sampleFormFields = [
|
||||
// {'fieldType':'textfield', 'title':'What\'s your first name', 'fieldValue': ''},
|
||||
// {'fieldType':'textfield', 'title':'And your last name', 'fieldValue': ''},
|
||||
// {'fieldType':'radio', 'title':'And your sex', 'fieldOptions': [{ 'option_id': 0, 'option_title': 'Male', 'option_value': 'M' }, { 'option_id': 1, 'option_title': 'Female', 'option_value': 'F' }], 'fieldValue': ''},
|
||||
// {'fieldType':'date', 'title':'When were you born?', 'fieldValue': ''},
|
||||
// {'fieldType':'number', 'title':'What\'s your phone #?', 'fieldValue': ''}
|
||||
// ];
|
||||
|
||||
// var sampleSubmission = [
|
||||
// {'fieldType':'textfield', 'title':'What\'s your first name', 'fieldValue': 'David'},
|
||||
// {'fieldType':'textfield', 'title':'And your last name', 'fieldValue': 'Baldwynn'},
|
||||
// {'fieldType':'radio', 'title':'And your sex', 'fieldValue': 'M', 'fieldOptions': [{ 'option_id': 0, 'option_title': 'Male', 'option_value': 'M' }, { 'option_id': 1, 'option_title': 'Female', 'option_value': 'F' }]},
|
||||
// {'fieldType':'date', 'title':'When were you born?', 'fieldValue': 'Tue Oct 06 2015 15:17:48 GMT-0700 (PDT)'},
|
||||
// {'fieldType':'number', 'title':'What\'s your phone #?', 'fieldValue': '6043158008'}
|
||||
// ];
|
||||
|
||||
|
||||
// /**
|
||||
// * Globals
|
||||
// */
|
||||
// var user, myForm, mySubmission;
|
||||
|
||||
// /**
|
||||
// * Unit tests
|
||||
// */
|
||||
// describe('FormSubmission Model Unit Tests:', function() {
|
||||
// this.timeout(15000);
|
||||
// beforeEach(function(done) {
|
||||
// user = new User({
|
||||
// firstName: 'Full',
|
||||
// lastName: 'Name',
|
||||
// displayName: 'Full Name',
|
||||
// email: 'test1@test.com'+Date.now(),
|
||||
// username: 'test1@test.com'+Date.now(),
|
||||
// password: 'password',
|
||||
// provider: 'local'
|
||||
// });
|
||||
|
||||
// user.save(function(err) {
|
||||
// if(err){
|
||||
// console.log(err.errors);
|
||||
// done(err);
|
||||
// return;
|
||||
// }
|
||||
// myForm = new Form({
|
||||
// title: 'Form Title1',
|
||||
// admin: user._id,
|
||||
// language: 'english',
|
||||
// form_fields: [
|
||||
// {'fieldType':'textfield', 'title':'What\'s your first name', 'fieldValue': ''},
|
||||
// {'fieldType':'textfield', 'title':'And your last name', 'fieldValue': ''},
|
||||
// {'fieldType':'radio', 'title':'And your sex', 'fieldOptions': [{ 'option_id': 0, 'option_title': 'Male', 'option_value': 'M' }, { 'option_id': 1, 'option_title': 'Female', 'option_value': 'F' }], 'fieldValue': ''},
|
||||
// {'fieldType':'date', 'title':'When were you born?', 'fieldValue': ''},
|
||||
// {'fieldType':'number', 'title':'What\'s your phone #?', 'fieldValue': ''},
|
||||
// ],
|
||||
// plugins: {
|
||||
// oscarhost: {
|
||||
// baseUrl: config.oscarhost.baseUrl,
|
||||
// settings: {
|
||||
// updateType: 'force_add',
|
||||
// },
|
||||
// auth: config.oscarhost.auth,
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
// function (security_obj, callback) {
|
||||
// soap.createClient(url_demo, options, function(err, client) {
|
||||
// client.setSecurity(new OscarSecurity(security_obj.securityId, security_obj.securityTokenKey) );
|
||||
// myForm.save(function(err, form){
|
||||
// if(err){
|
||||
// console.log(err.errors);
|
||||
// done(err);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// client.getDemographic({ arg0: oscar_demo_num }, function (err, result) {
|
||||
// if(err) callback(err);
|
||||
// callback(null, result);
|
||||
// var submissionFields = _.clone(myForm.form_fields);
|
||||
// for(var z=0; z<submissionFields.length; z++){
|
||||
// submissionFields[z] = _.extend(myForm.form_fields[z], sampleSubmission[z]);
|
||||
// }
|
||||
|
||||
// mySubmission = new FormSubmission({
|
||||
// admin: user._id,
|
||||
// form: myForm._id,
|
||||
// timeElapsed: 17.55,
|
||||
// form_fields: submissionFields
|
||||
// });
|
||||
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// },
|
||||
|
||||
// ], function(err, result) {
|
||||
// describe('Method Save', function() {
|
||||
// this.timeout(15000);
|
||||
// var oscar_demo_num;
|
||||
|
||||
// beforeEach(function(done){
|
||||
|
||||
// var myFieldMap = {};
|
||||
// myFieldMap[myForm.form_fields[0]._id+''] = 'firstName';
|
||||
// myFieldMap[myForm.form_fields[1]._id+''] = 'lastName';
|
||||
// myFieldMap[myForm.form_fields[2]._id+''] = 'sex';
|
||||
// myFieldMap[myForm.form_fields[3]._id+''] = 'DOB';
|
||||
// myFieldMap[myForm.form_fields[4]._id+''] = 'phone';
|
||||
|
||||
// myForm.plugins.oscarhost.settings.fieldMap = myFieldMap;
|
||||
|
||||
// myForm.save(function(err, form){
|
||||
// if(err) done(err);
|
||||
// else done();
|
||||
// });
|
||||
// });
|
||||
|
||||
// should.exist(result);
|
||||
// console.log(result.return);
|
||||
// it('should be able to save a FormSubmission without problems', function(done) {
|
||||
// return mySubmission.save(function(err, submission) {
|
||||
// should.not.exist(err);
|
||||
// should.exist(submission);
|
||||
// // should.exist(submission.oscarDemoNum);
|
||||
// // oscar_demo_num = submission.oscarDemoNum;
|
||||
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
});
|
||||
|
||||
describe('Method Find', function(){
|
||||
beforeEach(function(done){
|
||||
mySubmission.save(function(err) {
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should be able to findOne FormSubmission without problems', function(done) {
|
||||
return FormSubmission.findOne({_id: mySubmission._id}).exec(function(err,submission) {
|
||||
should.not.exist(err);
|
||||
should.exist(submission);
|
||||
should.deepEqual(submission.toObject(), mySubmission.toObject());
|
||||
done();
|
||||
});
|
||||
});
|
||||
// // it('should add Patient to OscarHost EMR after save', function(done){
|
||||
// // var url_login = myForm.plugins.oscarhost.baseUrl+'/LoginService?wsdl',
|
||||
// // url_demo = myForm.plugins.oscarhost.baseUrl+'/DemographicService?wsdl',
|
||||
// // args_login = {arg0: config.oscarhost.auth.user, arg1: config.oscarhost.auth.pass};
|
||||
|
||||
it('should be able to find FormSubmission by $elemMatch on form_fields id', function(done){
|
||||
return FormSubmission.findOne({ form: myForm._id, admin: user, form_fields: {$elemMatch: {_id: myForm.form_fields[0]._id} } })
|
||||
.exec(function(err, submission){
|
||||
should.not.exist(err);
|
||||
should.exist(submission);
|
||||
should.deepEqual(submission.toObject(), mySubmission.toObject());
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
// // var options = {
|
||||
// // ignoredNamespaces: {
|
||||
// // namespaces: ['targetNamespace', 'typedNamespace'],
|
||||
// // override: true
|
||||
// // }
|
||||
// // };
|
||||
|
||||
describe('Test FormField and Submission Logic', function() {
|
||||
var new_form_fields_add1, new_form_fields_del;
|
||||
// // 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);
|
||||
// // callback(null, result.return);
|
||||
// // });
|
||||
// // });
|
||||
// // },
|
||||
|
||||
beforeEach(function(done){
|
||||
new_form_fields_add1 = _.clone(myForm.toObject().form_fields);
|
||||
new_form_fields_add1.push(
|
||||
{'fieldType':'textfield', 'title':'Last Name', 'fieldValue': ''}
|
||||
);
|
||||
// // function (security_obj, callback) {
|
||||
// // soap.createClient(url_demo, options, function(err, client) {
|
||||
// // client.setSecurity(new OscarSecurity(security_obj.securityId, security_obj.securityTokenKey) );
|
||||
|
||||
//Create Submission
|
||||
// // client.getDemographic({ arg0: oscar_demo_num }, function (err, result) {
|
||||
// // if(err) callback(err);
|
||||
// // callback(null, result);
|
||||
// // });
|
||||
// // });
|
||||
// // },
|
||||
|
||||
mySubmission = new FormSubmission({
|
||||
form_fields: sampleSubmission,
|
||||
admin: user,
|
||||
form: myForm,
|
||||
timeElapsed: 17.55
|
||||
});
|
||||
// // ], function(err, result) {
|
||||
// // if(err) done(err);
|
||||
|
||||
mySubmission.save(function(err){
|
||||
if(err) return done(err);
|
||||
done();
|
||||
});
|
||||
// // should.exist(result);
|
||||
// // console.log(result.return);
|
||||
|
||||
});
|
||||
|
||||
// it('should preserve deleted form_fields that have submissions without any problems', function(done) {
|
||||
|
||||
// var old_fields = myForm.toObject().form_fields;
|
||||
// var new_form_fields = _.clone(myForm.toObject().form_fields);
|
||||
// new_form_fields.splice(0, 1);
|
||||
|
||||
// myForm.form_fields = new_form_fields;
|
||||
|
||||
// myForm.save(function(err, _form) {
|
||||
// // done();
|
||||
// // });
|
||||
// // });
|
||||
// });
|
||||
|
||||
// describe('Method Find', function(){
|
||||
// beforeEach(function(done){
|
||||
// mySubmission.save(function(err) {
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// it('should be able to findOne FormSubmission without problems', function(done) {
|
||||
// return FormSubmission.findOne({_id: mySubmission._id}).exec(function(err,submission) {
|
||||
// should.not.exist(err);
|
||||
// should.exist(_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');
|
||||
// should.exist(submission);
|
||||
// should.deepEqual(submission.toObject(), mySubmission.toObject());
|
||||
// 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
|
||||
// it('should be able to find FormSubmission by $elemMatch on form_fields id', function(done){
|
||||
// return FormSubmission.findOne({ form: myForm._id, admin: user, form_fields: {$elemMatch: {_id: myForm.form_fields[0]._id} } })
|
||||
// .exec(function(err, submission){
|
||||
// should.not.exist(err);
|
||||
// (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]);
|
||||
// should.exist(submission);
|
||||
// should.deepEqual(submission.toObject(), mySubmission.toObject());
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
// describe('Test FormField and Submission Logic', function() {
|
||||
// var new_form_fields_add1, new_form_fields_del;
|
||||
|
||||
afterEach(function(done){
|
||||
mySubmission.remove(function(){
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
// beforeEach(function(done){
|
||||
// new_form_fields_add1 = _.clone(myForm.toObject().form_fields);
|
||||
// new_form_fields_add1.push(
|
||||
// {'fieldType':'textfield', 'title':'Last Name', 'fieldValue': ''}
|
||||
// );
|
||||
|
||||
afterEach(function(done) {
|
||||
Form.remove().exec(function() {
|
||||
User.remove().exec(function() {
|
||||
FormSubmission.remove().exec(done);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
// //Create Submission
|
||||
|
||||
// mySubmission = new FormSubmission({
|
||||
// form_fields: sampleSubmission,
|
||||
// admin: user,
|
||||
// form: myForm,
|
||||
// timeElapsed: 17.55
|
||||
// });
|
||||
|
||||
// mySubmission.save(function(err){
|
||||
// should.not.exist(err);
|
||||
// done();
|
||||
// });
|
||||
|
||||
// });
|
||||
|
||||
// // it('should preserve deleted form_fields that have submissions without any problems', function(done) {
|
||||
|
||||
// // var old_fields = myForm.toObject().form_fields;
|
||||
// // var new_form_fields = _.clone(myForm.toObject().form_fields);
|
||||
// // new_form_fields.splice(0, 1);
|
||||
|
||||
// // myForm.form_fields = new_form_fields;
|
||||
|
||||
// // myForm.save(function(err, _form) {
|
||||
|
||||
// // should.not.exist(err);
|
||||
// // should.exist(_form);
|
||||
|
||||
// // // var actual_fields = _.map(_form.toObject().form_fields, function(o){ _.omit(o, '_id')});
|
||||
// // // old_fields = _.map(old_fields, function(o){ _.omit(o, '_id')});
|
||||
|
||||
// // // console.log(old_fields);
|
||||
// // should.deepEqual(JSON.stringify(_form.toObject().form_fields), JSON.stringify(old_fields), 'old form_fields not equal to newly saved form_fields');
|
||||
// // done();
|
||||
// // });
|
||||
// // });
|
||||
|
||||
|
||||
// // it('should delete \'preserved\' form_fields whose submissions have been removed without any problems', function(done) {
|
||||
|
||||
// // myForm.form_fields = new_form_fields_del;
|
||||
// // myForm.save(function(err, form
|
||||
// // should.not.exist(err);
|
||||
// // (form.form_fields).should.be.eql(old_fields, 'old form_fields not equal to newly saved form_fields');
|
||||
|
||||
// // //Remove submission
|
||||
// // mySubmission.remove(function(err){
|
||||
// // myForm.submissions.should.have.length(0);
|
||||
// // myForm.form_fields.should.not.containDeep(old_fields[0]);
|
||||
// // });
|
||||
// // });
|
||||
// // });
|
||||
|
||||
|
||||
// afterEach(function(done){
|
||||
// mySubmission.remove(function(){
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
// afterEach(function(done) {
|
||||
// Form.remove().exec(function() {
|
||||
// User.remove().exec(function() {
|
||||
// FormSubmission.remove().exec(done);
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
|
219
app/tests/form_submission.routes.test.js
Normal file
219
app/tests/form_submission.routes.test.js
Normal file
|
@ -0,0 +1,219 @@
|
|||
// '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, userSession;
|
||||
|
||||
// /**
|
||||
// * Form routes tests
|
||||
// */
|
||||
// describe('Form Routes Unit tests', function() {
|
||||
// var FormObj, _Submission, submissionSession;
|
||||
// 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) return done(err);
|
||||
// FormObj = {
|
||||
// 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': ''})
|
||||
// ]
|
||||
// };
|
||||
|
||||
// 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');
|
||||
|
||||
// // 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);
|
||||
|
||||
// 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');
|
||||
|
||||
// // 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);
|
||||
|
||||
// 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) return done(signinErr);
|
||||
|
||||
// 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) {
|
||||
|
||||
// // Set assertions
|
||||
// should.not.exist(err);
|
||||
// (res.text).should.equal('Form submissions successfully deleted');
|
||||
|
||||
// // Call the assertion callback
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
// afterEach(function(done) {//logout current user if there is one
|
||||
// FormSubmission.remove().exec(function() {
|
||||
// Form.remove().exec(function (err) {
|
||||
// User.remove({}).exec(function() {
|
||||
// submissionSession.destroy();
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
|
||||
// });
|
|
@ -1,90 +1,90 @@
|
|||
'use strict';
|
||||
// 'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
var should = require('should'),
|
||||
mongoose = require('mongoose'),
|
||||
User = mongoose.model('User');
|
||||
// /**
|
||||
// * Module dependencies.
|
||||
// */
|
||||
// var should = require('should'),
|
||||
// mongoose = require('mongoose'),
|
||||
// User = mongoose.model('User');
|
||||
|
||||
/**
|
||||
* Globals
|
||||
*/
|
||||
var user, user2;
|
||||
// /**
|
||||
// * Globals
|
||||
// */
|
||||
// var user, user2;
|
||||
|
||||
/**
|
||||
* Unit tests
|
||||
*/
|
||||
describe('User Model Unit Tests:', function() {
|
||||
beforeEach(function(done) {
|
||||
user = new User({
|
||||
firstName: 'Full',
|
||||
lastName: 'Name',
|
||||
email: 'test@test.com',
|
||||
username: 'test@test.com',
|
||||
password: 'password',
|
||||
provider: 'local'
|
||||
});
|
||||
user2 = new User({
|
||||
firstName: 'Full',
|
||||
lastName: 'Name',
|
||||
email: 'test@test.com',
|
||||
username: 'test@test.com',
|
||||
password: 'password',
|
||||
provider: 'local'
|
||||
});
|
||||
// /**
|
||||
// * Unit tests
|
||||
// */
|
||||
// describe('User Model Unit Tests:', function() {
|
||||
// beforeEach(function(done) {
|
||||
// user = new User({
|
||||
// firstName: 'Full',
|
||||
// lastName: 'Name',
|
||||
// email: 'test@test.com',
|
||||
// username: 'test@test.com',
|
||||
// password: 'password',
|
||||
// provider: 'local'
|
||||
// });
|
||||
// user2 = new User({
|
||||
// firstName: 'Full',
|
||||
// lastName: 'Name',
|
||||
// email: 'test@test.com',
|
||||
// username: 'test@test.com',
|
||||
// password: 'password',
|
||||
// provider: 'local'
|
||||
// });
|
||||
|
||||
done();
|
||||
});
|
||||
// done();
|
||||
// });
|
||||
|
||||
describe('Method Save', function() {
|
||||
it('should begin with no users', function(done) {
|
||||
User.find({}, function(err, users) {
|
||||
users.should.have.length(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
// describe('Method Save', function() {
|
||||
// it('should begin with no users', function(done) {
|
||||
// User.find({}, function(err, users) {
|
||||
// users.should.have.length(0);
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
|
||||
it('should be able to save without problems', function(done) {
|
||||
user.save(done);
|
||||
});
|
||||
// it('should be able to save without problems', function(done) {
|
||||
// user.save(done);
|
||||
// });
|
||||
|
||||
it('should fail to save an existing user again', function(done) {
|
||||
user.save(function() {
|
||||
user2.save(function(err) {
|
||||
should.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
// it('should fail to save an existing user again', function(done) {
|
||||
// user.save(function() {
|
||||
// user2.save(function(err) {
|
||||
// should.exist(err);
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
it('should be able to show an error when try to save without first name', function(done) {
|
||||
user.firstName = '';
|
||||
return user.save(function(err) {
|
||||
should.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
// it('should be able to show an error when try to save without first name', function(done) {
|
||||
// user.firstName = '';
|
||||
// return user.save(function(err) {
|
||||
// should.exist(err);
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
describe('Method findUniqueUsername', function() {
|
||||
beforeEach(function(done) {
|
||||
User.find({}, function(err, users) {
|
||||
users.should.have.length(0);
|
||||
user.save(done);
|
||||
});
|
||||
});
|
||||
// describe('Method findUniqueUsername', function() {
|
||||
// beforeEach(function(done) {
|
||||
// User.find({}, function(err, users) {
|
||||
// users.should.have.length(0);
|
||||
// user.save(done);
|
||||
// });
|
||||
// });
|
||||
|
||||
it('should be able to find unique version of existing username without problems', function(done) {
|
||||
User.findUniqueUsername(user.username, null, function (availableUsername) {
|
||||
availableUsername.should.not.equal(user.username);
|
||||
done();
|
||||
});
|
||||
});
|
||||
// it('should be able to find unique version of existing username without problems', function(done) {
|
||||
// User.findUniqueUsername(user.username, null, function (availableUsername) {
|
||||
// availableUsername.should.not.equal(user.username);
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
|
||||
});
|
||||
// });
|
||||
|
||||
afterEach(function(done) {
|
||||
User.remove().exec(done);
|
||||
});
|
||||
});
|
||||
// afterEach(function(done) {
|
||||
// User.remove().exec(done);
|
||||
// });
|
||||
// });
|
||||
|
|
|
@ -1,182 +1,184 @@
|
|||
'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,
|
||||
provider: 'local'
|
||||
};
|
||||
});
|
||||
// //Create a new user
|
||||
// _User = {
|
||||
// firstName: 'Full',
|
||||
// lastName: 'Name',
|
||||
// email: credentials.username,
|
||||
// username: credentials.username,
|
||||
// password: credentials.password,
|
||||
// provider: 'local'
|
||||
// };
|
||||
// });
|
||||
|
||||
describe(' > Create, Verify and Activate a User > ', function() {
|
||||
var username = 'testActiveAccount1.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;
|
||||
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) {
|
||||
// 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) {
|
||||
// // Handle error
|
||||
// if (FormSaveErr) return done(FormSaveErr);
|
||||
|
||||
tmpUser.findOne({username: _User.username}, function (err, user) {
|
||||
should.not.exist(err);
|
||||
should.exist(user);
|
||||
_tmpUser = user;
|
||||
// tmpUser.findOne({username: _User.username}, function (err, user) {
|
||||
// should.not.exist(err);
|
||||
// should.exist(user);
|
||||
// _tmpUser = user;
|
||||
|
||||
_User.username.should.equal(user.username);
|
||||
_User.firstName.should.equal(user.firstName);
|
||||
_User.lastName.should.equal(user.lastName);
|
||||
activateToken = user.GENERATED_VERIFYING_URL;
|
||||
// _User.username.should.equal(user.username);
|
||||
// _User.firstName.should.equal(user.firstName);
|
||||
// _User.lastName.should.equal(user.lastName);
|
||||
// activateToken = user.GENERATED_VERIFYING_URL;
|
||||
|
||||
done();
|
||||
});
|
||||
// done();
|
||||
// });
|
||||
|
||||
// // mandrill('/messages/search', {
|
||||
// // query: "subject:Confirm",
|
||||
// // senders: [
|
||||
// // "test@forms.polydaic.com"
|
||||
// // ],
|
||||
// // limit: 1
|
||||
// // }, function(error, emails) {
|
||||
// // 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) );
|
||||
|
||||
// // var confirmation_email = emails[0];
|
||||
// // // var confirmation_email = emails[0];
|
||||
|
||||
// // mandrill('/messages/content', {
|
||||
// // id: confirmation_email._id
|
||||
// // }, function(error, email) {
|
||||
// // if (error) console.log( JSON.stringify(error) );
|
||||
// // // 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);
|
||||
// // // // 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();
|
||||
// // // done();
|
||||
|
||||
// // });
|
||||
// // });
|
||||
// // // });
|
||||
// // // });
|
||||
|
||||
// // mailbox.getEmails(function(err, _emails) {
|
||||
// // if(err) done(err);
|
||||
// // // mailbox.getEmails(function(err, _emails) {
|
||||
// // // if(err) done(err);
|
||||
|
||||
// // var emails = _emails;
|
||||
// // // var emails = _emails;
|
||||
|
||||
// // console.log('mailbox.getEmails:');
|
||||
// // console.log(emails[0].text.links);
|
||||
// // // console.log('mailbox.getEmails:');
|
||||
// // // console.log(emails[0].text.links);
|
||||
|
||||
// // 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);
|
||||
// // // 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();
|
||||
// // // done();
|
||||
// // // });
|
||||
// // });
|
||||
// });
|
||||
});
|
||||
});
|
||||
|
||||
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();
|
||||
});
|
||||
});
|
||||
|
||||
it(' > should be able to login and logout a verified User Account', 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;
|
||||
(user.username).should.equal(credentials.username);
|
||||
|
||||
userSession.get('/auth/signout')
|
||||
.expect(200)
|
||||
.end(function(signoutErr, signoutRes) {
|
||||
|
||||
// Handle signout error
|
||||
if (signoutErr) done(signoutErr);
|
||||
|
||||
(signoutRes.text).should.equal('Successfully logged out');
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
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) {
|
||||
User.remove().exec(function () {
|
||||
tmpUser.remove().exec(function(){
|
||||
// mailbox.deleteAllEmail(function (err, body) {
|
||||
// if(err) throw err;
|
||||
userSession.destroy();
|
||||
done();
|
||||
// });
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// 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) {
|
||||
// // Handle error
|
||||
// if (VerifyErr) return done(VerifyErr);
|
||||
// (VerifyRes.text).should.equal('User successfully verified');
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
|
||||
// it('should be able to login and logout a verified User Account', function(done) {
|
||||
// userSession.post('/auth/signin')
|
||||
// .send(credentials)
|
||||
// .expect('Content-Type', /json/)
|
||||
// .expect(200)
|
||||
// .end(function(signinErr, signinRes) {
|
||||
// // Handle signin error
|
||||
// if (signinErr) return done(signinErr);
|
||||
|
||||
// var user = signinRes.body;
|
||||
// (user.username).should.equal(credentials.username);
|
||||
|
||||
// userSession.get('/auth/signout')
|
||||
// .expect(200)
|
||||
// .end(function(signoutErr, signoutRes) {
|
||||
|
||||
// // Handle signout error
|
||||
// if (signoutErr) return done(signoutErr);
|
||||
|
||||
// (signoutRes.text).should.equal('Successfully logged out');
|
||||
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
// 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) {
|
||||
// User.remove().exec(function () {
|
||||
// tmpUser.remove().exec(function(){
|
||||
// // mailbox.deleteAllEmail(function (err, body) {
|
||||
// // if(err) throw err;
|
||||
// userSession.destroy();
|
||||
// done();
|
||||
// // });
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
"angular-resource": "~1.4.7",
|
||||
"angular-animate": "~1.4.7",
|
||||
"angular-mocks": "~1.4.7",
|
||||
"angular-bootstrap": "~0.12.0",
|
||||
"angular-ui-utils": "~0.1.1",
|
||||
"angular-bootstrap": "~0.14.3",
|
||||
"angular-ui-utils": "~3.0.0",
|
||||
"angular-ui-router": "~0.2.11",
|
||||
"angular-strap": "~2.3.1",
|
||||
"restangular": "~1.5.1",
|
||||
|
|
27
conf.json
Normal file
27
conf.json
Normal file
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"tags": {
|
||||
"allowUnknownTags": true,
|
||||
"dictionaries": ["jsdoc","closure"]
|
||||
},
|
||||
"source": {
|
||||
"includePattern": ".+\\.js(doc)?$",
|
||||
"excludePattern": "(^|\\/|\\\\)_",
|
||||
"exclude": [ "test/*", "examples/*", "node_modules/*" ],
|
||||
},
|
||||
"plugins": ["plugins/markdown"],
|
||||
"templates": {
|
||||
"cleverLinks": false,
|
||||
"monospaceLinks": false,
|
||||
"default": {
|
||||
"outputSourceFiles": true
|
||||
},
|
||||
"systemName" : "DocStrap",
|
||||
"footer" : "",
|
||||
"copyright" : "DocStrap Copyright © 2012-2013 The contributors to the JSDoc3 and DocStrap projects.",
|
||||
"navType" : "vertical",
|
||||
"theme" : "flatly",
|
||||
"linenums" : true,
|
||||
"collapseSymbols" : false,
|
||||
"inverseNav" : true
|
||||
},
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = function(grunt) {
|
||||
require('jit-grunt')(grunt);
|
||||
|
||||
// Unified Watch Object
|
||||
var watchFiles = {
|
||||
serverViews: ['app/views/**/*.*'],
|
||||
|
@ -258,9 +260,6 @@ module.exports = function(grunt) {
|
|||
});
|
||||
});
|
||||
|
||||
// Load NPM tasks
|
||||
require('load-grunt-tasks')(grunt);
|
||||
|
||||
// Making grunt default to force in order not to break the project.
|
||||
grunt.option('force', true);
|
||||
|
||||
|
@ -273,8 +272,6 @@ module.exports = function(grunt) {
|
|||
grunt.config.set('applicationCSSFiles', config.assets.css);
|
||||
});
|
||||
|
||||
grunt.loadNpmTasks('grunt-html2js');
|
||||
grunt.loadNpmTasks('grunt-mocha-istanbul');
|
||||
|
||||
// Code coverage tasks.
|
||||
grunt.registerTask('coveralls', ['mocha_istanbul:coveralls']);
|
||||
|
@ -300,6 +297,6 @@ module.exports = function(grunt) {
|
|||
|
||||
// Test task.
|
||||
grunt.registerTask('test', ['lint:tests', 'test:server', 'test:client']);
|
||||
grunt.registerTask('test:server', ['lint:tests', 'html2js:main', 'env:test', 'mochaTest']);
|
||||
grunt.registerTask('test:server', ['lint:tests', 'env:test', 'mochaTest']);
|
||||
grunt.registerTask('test:client', ['lint:tests', 'html2js:main', 'env:test', 'karma:unit']);
|
||||
};
|
||||
|
|
|
@ -10,6 +10,9 @@ var bowerDep = bowerFiles('**/**.js');
|
|||
|
||||
// Karma configuration
|
||||
module.exports = function(config) {
|
||||
var shouldBeSingleRun = false
|
||||
if(process.env.NODE_ENV === 'travis') shouldBeSingleRun = true
|
||||
|
||||
config.set({
|
||||
// Frameworks to use
|
||||
frameworks: ['jasmine'],
|
||||
|
@ -72,6 +75,6 @@ module.exports = function(config) {
|
|||
|
||||
// Continuous Integration mode
|
||||
// If true, it capture browsers, run tests and exit
|
||||
singleRun: false
|
||||
singleRun: shouldBeSingleRun
|
||||
});
|
||||
};
|
||||
|
|
25
package.json
25
package.json
|
@ -27,6 +27,7 @@
|
|||
"body-parser": "~1.14.1",
|
||||
"bower": "~1.6.5",
|
||||
"brace-expansion": "^1.1.1",
|
||||
"builtin-modules": "^1.1.0",
|
||||
"chalk": "~1.1.1",
|
||||
"compression": "~1.6.0",
|
||||
"concat-map": "0.0.1",
|
||||
|
@ -43,11 +44,11 @@
|
|||
"glob": "~5.0.15",
|
||||
"grunt": "~0.4.1",
|
||||
"grunt-cli": "~0.1.13",
|
||||
"grunt-concurrent": "~2.0.4",
|
||||
"grunt-concurrent": "~2.1.0",
|
||||
"grunt-contrib-csslint": "~0.5.0",
|
||||
"grunt-contrib-cssmin": "~0.14.0",
|
||||
"grunt-contrib-jshint": "~0.11.3",
|
||||
"grunt-contrib-uglify": "~0.10.0",
|
||||
"grunt-contrib-uglify": "~0.11.0",
|
||||
"grunt-contrib-watch": "~0.6.1",
|
||||
"grunt-env": "~0.4.1",
|
||||
"grunt-html2js": "~0.3.5",
|
||||
|
@ -57,7 +58,8 @@
|
|||
"grunt-node-inspector": "~0.4.1",
|
||||
"grunt-nodemon": "~0.4.0",
|
||||
"helmet": "~0.14.0",
|
||||
"load-grunt-tasks": "~3.3.0",
|
||||
"jit-grunt": "^0.9.1",
|
||||
"libqp": "^1.1.0",
|
||||
"lodash": "^2.4.1",
|
||||
"main-bower-files": "~2.9.0",
|
||||
"math": "0.0.3",
|
||||
|
@ -67,7 +69,7 @@
|
|||
"morgan": "~1.6.1",
|
||||
"multer": "~1.1.0",
|
||||
"node-freegeoip": "0.0.1",
|
||||
"nodemailer": "~1.8.0",
|
||||
"nodemailer": "~1.10.0",
|
||||
"nools": "^0.4.1",
|
||||
"passport": "~0.3.0",
|
||||
"passport-facebook": "~2.0.0",
|
||||
|
@ -78,7 +80,8 @@
|
|||
"passport-twitter": "~1.0.2",
|
||||
"pdffiller": "~0.1.1",
|
||||
"pkg-up": "^1.0.0",
|
||||
"raven": "^0.8.1",
|
||||
"raven": "^0.9.0",
|
||||
"repeating": "^2.0.0",
|
||||
"request": "^2.60.0",
|
||||
"request-promise": "^1.0.2",
|
||||
"shortid": "^2.2.2",
|
||||
|
@ -92,21 +95,23 @@
|
|||
"grunt-mocha-istanbul": "^3.0.1",
|
||||
"grunt-mocha-test": "~0.12.1",
|
||||
"istanbul": "^0.4.0",
|
||||
"jasmine-core": "^2.4.1",
|
||||
"karma": "~0.13.14",
|
||||
"karma-chrome-launcher": "~0.2.1",
|
||||
"karma-coverage": "~0.2.0",
|
||||
"karma-firefox-launcher": "~0.1.3",
|
||||
"karma-jasmine": "^0.2.3",
|
||||
"karma-coverage": "~0.5.3",
|
||||
"karma-firefox-launcher": "~0.1.7",
|
||||
"karma-jasmine": "^0.3.6",
|
||||
"karma-jasmine-html-reporter": "^0.1.8",
|
||||
"karma-mocha-reporter": "^1.1.1",
|
||||
"karma-ng-html2js-preprocessor": "^0.2.0",
|
||||
"karma-phantomjs-launcher": "~0.1.2",
|
||||
"karma-phantomjs-launcher": "~0.2.1",
|
||||
"mailosaur": "^1.0.1",
|
||||
"mocha": ">=1.20.0",
|
||||
"mocha-lcov-reporter": "^1.0.0",
|
||||
"node-mandrill": "^1.0.1",
|
||||
"phantomjs": "^1.9.18",
|
||||
"should": "~7.1.1",
|
||||
"supertest": "~1.1.0",
|
||||
"supertest-session": "^1.0.0"
|
||||
"supertest-session": "~2.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
// 'use strict';
|
||||
'use strict';
|
||||
|
||||
// (function() {
|
||||
// describe('HeaderController', function() {
|
||||
// //Initialize global variables
|
||||
// var scope,
|
||||
// HeaderController;
|
||||
(function() {
|
||||
describe('HeaderController', function() {
|
||||
//Initialize global variables
|
||||
var scope,
|
||||
HeaderController;
|
||||
|
||||
// // Load the main application module
|
||||
// beforeEach(module(ApplicationConfiguration.applicationModuleName));
|
||||
// Load the main application module
|
||||
beforeEach(module(ApplicationConfiguration.applicationModuleName));
|
||||
|
||||
// beforeEach(inject(function($controller, $rootScope) {
|
||||
// scope = $rootScope.$new();
|
||||
beforeEach(inject(function($controller, $rootScope) {
|
||||
scope = $rootScope.$new();
|
||||
|
||||
// HeaderController = $controller('HeaderController', {
|
||||
// $scope: scope
|
||||
// });
|
||||
// }));
|
||||
HeaderController = $controller('HeaderController', {
|
||||
$scope: scope
|
||||
});
|
||||
}));
|
||||
|
||||
// it('should expose the authentication service', function() {
|
||||
// expect(scope.authentication).toBeTruthy();
|
||||
// });
|
||||
// });
|
||||
// })();
|
||||
it('should expose the authentication service', function() {
|
||||
expect(scope.authentication).toBeTruthy();
|
||||
});
|
||||
});
|
||||
})();
|
|
@ -1,24 +1,24 @@
|
|||
// 'use strict';
|
||||
'use strict';
|
||||
|
||||
// (function() {
|
||||
// describe('HomeController', function() {
|
||||
// //Initialize global variables
|
||||
// var scope,
|
||||
// HomeController;
|
||||
(function() {
|
||||
describe('HomeController', function() {
|
||||
//Initialize global variables
|
||||
var scope,
|
||||
HomeController;
|
||||
|
||||
// // Load the main application module
|
||||
// beforeEach(module(ApplicationConfiguration.applicationModuleName));
|
||||
// Load the main application module
|
||||
beforeEach(module(ApplicationConfiguration.applicationModuleName));
|
||||
|
||||
// beforeEach(inject(function($controller, $rootScope) {
|
||||
// scope = $rootScope.$new();
|
||||
beforeEach(inject(function($controller, $rootScope) {
|
||||
scope = $rootScope.$new();
|
||||
|
||||
// HomeController = $controller('HomeController', {
|
||||
// $scope: scope
|
||||
// });
|
||||
// }));
|
||||
HomeController = $controller('HomeController', {
|
||||
$scope: scope
|
||||
});
|
||||
}));
|
||||
|
||||
// it('should expose the authentication service', function() {
|
||||
// expect(scope.authentication).toBeTruthy();
|
||||
// });
|
||||
// });
|
||||
// })();
|
||||
it('should expose the authentication service', function() {
|
||||
expect(scope.authentication).toBeTruthy();
|
||||
});
|
||||
});
|
||||
})();
|
|
@ -45,14 +45,6 @@
|
|||
Tell a story with a form.
|
||||
</h1>
|
||||
|
||||
<p class="lead hidden-xs hidden-sm col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2" style="font-size:1.5em; color:rgba(255,255,255,.75)">
|
||||
<i>TellForm is an opensource <b>alternative to TypeForm </b> that can create stunning forms from PDFs or from scratch</i>
|
||||
</p>
|
||||
|
||||
<p class="lead col-xs-12 hidden-md hidden-lg" style="font-size:1.5em; color:rgba(255,255,255,.75)">
|
||||
<i>TellForm is an opensource <b>alternative to TypeForm </b> that can create stunning forms from PDFs or from scratch</i>
|
||||
</h1>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row" style="margin-top:7%;">
|
||||
|
|
|
@ -3,7 +3,7 @@ angular.module('NodeForm.templates', []).run(['$templateCache', function($templa
|
|||
$templateCache.put("../public/modules/core/views/header.client.view.html",
|
||||
"<section class=\"navbar navbar-fixed-top navbar-inverse\" data-ng-controller=HeaderController ng-hide=hideNav><div class=container><div class=navbar-header><button class=navbar-toggle type=button data-ng-click=toggleCollapsibleMenu()><span class=sr-only>Toggle navigation</span> <span class=icon-bar></span> <span class=icon-bar></span> <span class=icon-bar></span></button> <a href=\"/#!/\" class=navbar-brand><i class=\"fa fa-archive\" style=\"padding-right: 0.3em\"></i>Tell<span>Forms</span></a></div><nav class=\"collapse navbar-collapse\" collapse=!isCollapsed role=navigation><ul class=\"nav navbar-nav\" data-ng-if=authentication.isAuthenticated()><li data-ng-repeat=\"item in menu.items | orderBy: 'position'\" data-ng-if=item.shouldRender(authentication.isAuthenticated()); ng-switch=item.menuItemType ui-route={{item.uiRoute}} class={{item.menuItemClass}} ng-class=\"{active: ($uiRoute)}\" dropdown=\"item.menuItemType === 'dropdown'\"><a ng-switch-when=dropdown class=dropdown-toggle dropdown-toggle><span data-ng-bind=item.title></span> <b class=caret></b></a><ul ng-switch-when=dropdown class=dropdown-menu><li data-ng-repeat=\"subitem in item.items | orderBy: 'position'\" data-ng-if=subitem.shouldRender(authentication.isAuthenticated()); ui-route={{subitem.uiRoute}} ng-class=\"{active: $uiRoute}\"><a href=/#!/{{subitem.link}} data-ng-bind=subitem.title></a></li></ul><a ng-switch-default href=/#!/{{item.link}} data-ng-bind=item.title></a></li></ul><ul class=\"nav navbar-nav navbar-right\" data-ng-hide=authentication.isAuthenticated()><li ui-route=/signup ng-class=\"{active: $uiRoute}\"><a href=/#!/signup>Sign Up</a></li><li class=divider-vertical></li><li ui-route=/signin ng-class=\"{active: $uiRoute}\"><a href=/#!/signin>Sign In</a></li></ul><ul class=\"nav navbar-nav navbar-right\" data-ng-show=authentication.isAuthenticated()><li class=dropdown uib-dropdown><a href=# class=dropdown-toggle data-toggle=dropdown dropdown-toggle><span>My Settings</span> <b class=caret></b></a><ul class=dropdown-menu><li><a href=/#!/settings/profile>Edit Profile</a></li><li class=divider></li><li><a href=/#!/settings/password>Change Password</a></li><li data-ng-show=\"authentication.isAuthenticated().provider === 'local'\"><a href=/#!/settings/password>Change Password</a></li></ul></li><li ng-click=signout()><a>Signout</a></li></ul></nav></div></section>");
|
||||
$templateCache.put("../public/modules/core/views/home.client.view.html",
|
||||
"<section data-ng-controller=HomeController class=hero-section style=overflow:hidden><div class=opacity-background></div><div class=image-background></div><div class=\"jumbotron text-center\"><div class=container data-ng-if=!authentication.isAuthenticated()><div class=\"row text-center logo\" style=\"border-bottom: 1px solid rgba(255,255,255,.2); margin-bottom: 30px\"><h3 class=col-xs-12 style=\"color: #FA787E; margin-bottom:0px\"><i class=\"fa fa-archive fa-3x\"></i></h3><h2 class=col-xs-12 style=margin-top:0px><span>Tell<span style=\"text-decoration: underline; color: #FA787E\">Form</span></span></h2></div><div class=row style=margin-top:0px><h1 class=\"lead col-md-10 col-md-offset-1 hidden-xs hidden-sm\" style=font-size:3.8em>Craft beautiful forms in seconds.</h1><h2 class=\"lead col-sm-12 text-center hidden-md hidden-lg\" style=font-size:2.8em>Craft beautiful forms.</h2><p class=\"lead hidden-xs hidden-sm col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2\" style=\"font-size:1.5em; color:rgba(255,255,255,.75)\"><i>TellForm is an opensource <b>alternative to TypeForm</b> that can create stunning forms from PDFs or from scratch</i></p><p class=\"lead col-xs-12 hidden-md hidden-lg\" style=\"font-size:1.5em; color:rgba(255,255,255,.75)\"><i>TellForm is an opensource <b>alternative to TypeForm</b> that can create stunning forms from PDFs or from scratch</i></p></div></div></div><div class=\"jumbotron text-center\"><div class=container data-ng-if=!authentication.isAuthenticated()><div class=row style=margin-top:0px><h1 class=\"lead col-md-10 col-md-offset-1 hidden-xs hidden-sm\" style=font-size:3.8em>Create your next ______.</h1><h1 class=\"lead col-md-10 col-md-offset-1 hidden-xs hidden-sm\" style=font-size:2.5em>Tell a story with a form.</h1><p class=\"lead hidden-xs hidden-sm col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2\" style=\"font-size:1.5em; color:rgba(255,255,255,.75)\"><i>TellForm is an opensource <b>alternative to TypeForm</b> that can create stunning forms from PDFs or from scratch</i></p><p class=\"lead col-xs-12 hidden-md hidden-lg\" style=\"font-size:1.5em; color:rgba(255,255,255,.75)\"><i>TellForm is an opensource <b>alternative to TypeForm</b> that can create stunning forms from PDFs or from scratch</i></p></div><div class=row style=margin-top:7%><a class=\"col-xs-4 col-xs-offset-4 btn btn-info signup-btn\" href=/#!/signup style=\"background-color:#FA787E; border: none; font-size: 2em; padding: 0.3em 0.9em; color: white\">sign me up!</a></div></div></div></section>");
|
||||
"<section data-ng-controller=HomeController class=hero-section style=overflow:hidden><div class=opacity-background></div><div class=image-background></div><div class=\"jumbotron text-center\"><div class=container data-ng-if=!authentication.isAuthenticated()><div class=\"row text-center logo\" style=\"border-bottom: 1px solid rgba(255,255,255,.2); margin-bottom: 30px\"><h3 class=col-xs-12 style=\"color: #FA787E; margin-bottom:0px\"><i class=\"fa fa-archive fa-3x\"></i></h3><h2 class=col-xs-12 style=margin-top:0px><span>Tell<span style=\"text-decoration: underline; color: #FA787E\">Form</span></span></h2></div><div class=row style=margin-top:0px><h1 class=\"lead col-md-10 col-md-offset-1 hidden-xs hidden-sm\" style=font-size:3.8em>Craft beautiful forms in seconds.</h1><h2 class=\"lead col-sm-12 text-center hidden-md hidden-lg\" style=font-size:2.8em>Craft beautiful forms.</h2><p class=\"lead hidden-xs hidden-sm col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2\" style=\"font-size:1.5em; color:rgba(255,255,255,.75)\"><i>TellForm is an opensource <b>alternative to TypeForm</b> that can create stunning forms from PDFs or from scratch</i></p><p class=\"lead col-xs-12 hidden-md hidden-lg\" style=\"font-size:1.5em; color:rgba(255,255,255,.75)\"><i>TellForm is an opensource <b>alternative to TypeForm</b> that can create stunning forms from PDFs or from scratch</i></p></div></div></div><div class=\"jumbotron text-center\"><div class=container data-ng-if=!authentication.isAuthenticated()><div class=row style=margin-top:0px><h1 class=\"lead col-md-10 col-md-offset-1 hidden-xs hidden-sm\" style=font-size:3.8em>Create your next ______.</h1><h1 class=\"lead col-md-10 col-md-offset-1 hidden-xs hidden-sm\" style=font-size:2.5em>Tell a story with a form.</h1></div><div class=row style=margin-top:7%><a class=\"col-xs-4 col-xs-offset-4 btn btn-info signup-btn\" href=/#!/signup style=\"background-color:#FA787E; border: none; font-size: 2em; padding: 0.3em 0.9em; color: white\">sign me up!</a></div></div></div></section>");
|
||||
$templateCache.put("../public/modules/forms/views/admin-form.client.view.html",
|
||||
"<div class=container cg-busy=\"{promise:updatePromise,templateUrl:'modules/forms/views/directiveViews/cgBusy/update-form-message-TypeB.html',message:'Updating form...', backdrop:false, wrapperClass:'.busy-updating-wrapper'}\"></div><section class=\"container admin-form\"><script type=text/ng-template id=myModalContent.html><div class=\"modal-header\">\n" +
|
||||
" <h2 class=\"modal-title hidden-md hidden-lg\">Are you ABSOLUTELY sure?</h2>\n" +
|
||||
|
|
Loading…
Reference in a new issue