Merge branch 'master' into controllers_translation_support
This commit is contained in:
commit
9a4538328d
6
app.json
6
app.json
|
@ -10,9 +10,9 @@
|
||||||
"description": "Disable support for running subdomains. (This should be true if you are not using your own custom domain.",
|
"description": "Disable support for running subdomains. (This should be true if you are not using your own custom domain.",
|
||||||
"value": "TRUE"
|
"value": "TRUE"
|
||||||
},
|
},
|
||||||
"DISABLE_CLUSTER_MODE": {
|
"ENABLE_CLUSTER_MODE": {
|
||||||
"description": "Disable support for running in cluster mode on pm2",
|
"description": "ENABLE support for running in cluster mode on pm2",
|
||||||
"value": "TRUE"
|
"value": "FALSE"
|
||||||
},
|
},
|
||||||
"NODE_ENV": {
|
"NODE_ENV": {
|
||||||
"description": "Choose whether to run app in development or production mode",
|
"description": "Choose whether to run app in development or production mode",
|
||||||
|
|
|
@ -139,7 +139,6 @@ exports.read = function(req, res) {
|
||||||
if(!req.user || (req.form.admin.id !== req.user.id) ){
|
if(!req.user || (req.form.admin.id !== req.user.id) ){
|
||||||
readForRender(req, res);
|
readForRender(req, res);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
FormSubmission.find({ form: req.form._id }).exec(function(err, _submissions) {
|
FormSubmission.find({ form: req.form._id }).exec(function(err, _submissions) {
|
||||||
if (err) {
|
if (err) {
|
||||||
res.status(400).send({
|
res.status(400).send({
|
||||||
|
|
|
@ -280,22 +280,6 @@ FormSchema.plugin(mUtilities.timestamp, {
|
||||||
useVirtual: false
|
useVirtual: false
|
||||||
});
|
});
|
||||||
|
|
||||||
var _original;
|
|
||||||
|
|
||||||
function getDeletedIndexes(needle, haystack){
|
|
||||||
var deletedIndexes = [];
|
|
||||||
|
|
||||||
if(haystack.length > 0){
|
|
||||||
for(var i = 0; i < needle.length; i++){
|
|
||||||
if(haystack.indexOf(needle[i]) === -1){
|
|
||||||
deletedIndexes.push(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return deletedIndexes;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
FormSchema.pre('save', function (next) {
|
FormSchema.pre('save', function (next) {
|
||||||
switch(this.language){
|
switch(this.language){
|
||||||
case 'spanish':
|
case 'spanish':
|
||||||
|
@ -317,14 +301,39 @@ FormSchema.pre('save', function (next) {
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function getDeletedIndexes(needle, haystack){
|
||||||
|
var deletedIndexes = [];
|
||||||
|
|
||||||
|
if(haystack.length > 0){
|
||||||
|
for(var i = 0; i < needle.length; i++){
|
||||||
|
if(haystack.indexOf(needle[i]) === -1){
|
||||||
|
deletedIndexes.push(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return deletedIndexes;
|
||||||
|
}
|
||||||
|
|
||||||
|
function formFieldsAllHaveIds(form_fields){
|
||||||
|
for(var i=0; i<form_fields.length; i++){
|
||||||
|
if(!form_fields[i].hasOwnProperty('_id') && !form_fields[i].hasOwnProperty('globalId')){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
FormSchema.pre('save', function (next) {
|
FormSchema.pre('save', function (next) {
|
||||||
var that = this;
|
var that = this;
|
||||||
|
var _original;
|
||||||
|
|
||||||
async.series([function(cb) {
|
async.series([function(cb) {
|
||||||
that.constructor
|
that.constructor
|
||||||
.findOne({_id: that._id}).exec(function (err, original) {
|
.findOne({_id: that._id}).exec(function (err, original) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return cb(err);
|
return cb(err);
|
||||||
|
} else if (!original){
|
||||||
|
return next();
|
||||||
} else {
|
} else {
|
||||||
_original = original;
|
_original = original;
|
||||||
return cb(null);
|
return cb(null);
|
||||||
|
@ -332,21 +341,18 @@ FormSchema.pre('save', function (next) {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function(cb) {
|
function(cb) {
|
||||||
var hasIds = true;
|
if(that.form_fields && that.isModified('form_fields') && formFieldsAllHaveIds(that.toObject().form_fields)){
|
||||||
for(var i=0; i<that.form_fields.length; i++){
|
|
||||||
if(!that.form_fields.hasOwnProperty('_id')){
|
|
||||||
hasIds = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(that.isModified('form_fields') && that.form_fields && _original && hasIds){
|
|
||||||
|
|
||||||
var old_form_fields = _original.form_fields,
|
var current_form = that.toObject(),
|
||||||
new_ids = _.map(_.pluck(that.form_fields, 'id'), function(id){ return ''+id;}),
|
old_form_fields = _original.toObject().form_fields,
|
||||||
old_ids = _.map(_.pluck(old_form_fields, 'id'), function(id){ return ''+id;}),
|
new_ids = _.map(_.map(current_form.form_fields, 'globalId'), function(id){ return ''+id;}),
|
||||||
|
old_ids = _.map(_.map(old_form_fields, 'globalId'), function(id){ return ''+id;}),
|
||||||
deletedIds = getDeletedIndexes(old_ids, new_ids);
|
deletedIds = getDeletedIndexes(old_ids, new_ids);
|
||||||
|
|
||||||
//Preserve fields that have at least one submission
|
console.log(deletedIds);
|
||||||
|
console.log(new_ids);
|
||||||
|
console.log(old_ids);
|
||||||
|
//Check if any form_fileds were deleted
|
||||||
if( deletedIds.length > 0 ){
|
if( deletedIds.length > 0 ){
|
||||||
|
|
||||||
var modifiedSubmissions = [];
|
var modifiedSubmissions = [];
|
||||||
|
@ -355,23 +361,21 @@ FormSchema.pre('save', function (next) {
|
||||||
function (deletedIdIndex, key, cb_id) {
|
function (deletedIdIndex, key, cb_id) {
|
||||||
|
|
||||||
var deleted_id = old_ids[deletedIdIndex];
|
var deleted_id = old_ids[deletedIdIndex];
|
||||||
|
|
||||||
//Find FormSubmissions that contain field with _id equal to 'deleted_id'
|
//Find FormSubmissions that contain field with _id equal to 'deleted_id'
|
||||||
FormSubmission.
|
FormSubmission.
|
||||||
find({ form: that._id, admin: that.admin, form_fields: {$elemMatch: {submissionId: deleted_id} } }).
|
find({ form: that, form_fields: {$elemMatch: {globalId: deleted_id} } }).
|
||||||
exec(function(err, submissions){
|
exec(function(err, submissions){
|
||||||
if(err) {
|
if(err) {
|
||||||
return cb_id(err);
|
return cb_id(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Delete field if there are no submission(s) found
|
//Preserve fields that have at least one submission
|
||||||
if (submissions.length) {
|
if (submissions.length) {
|
||||||
//Add submissions
|
//Add submissions
|
||||||
modifiedSubmissions.push.apply(modifiedSubmissions, submissions);
|
modifiedSubmissions.push.apply(modifiedSubmissions, submissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cb_id(null);
|
return cb_id(null);
|
||||||
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function (err) {
|
function (err) {
|
||||||
|
@ -383,29 +387,33 @@ FormSchema.pre('save', function (next) {
|
||||||
//Iterate through all submissions with modified form_fields
|
//Iterate through all submissions with modified form_fields
|
||||||
async.forEachOfSeries(modifiedSubmissions, function (submission, key, callback) {
|
async.forEachOfSeries(modifiedSubmissions, function (submission, key, callback) {
|
||||||
|
|
||||||
//Iterate through ids of deleted fields
|
var submission_form_fields = submission.toObject().form_fields;
|
||||||
for (i = 0; i < deletedIds.length; i++) {
|
var currentform_form_fields = that.toObject().form_fields;
|
||||||
|
|
||||||
var index = _.findIndex(submission.form_fields, function (field) {
|
//Iterate through ids of deleted fields
|
||||||
var tmp_id = field._id + '';
|
for (var i = 0; i < deletedIds.length; i++) {
|
||||||
|
var index = _.findIndex(submission_form_fields, function (field) {
|
||||||
|
var tmp_id = field.globalId + '';
|
||||||
return tmp_id === old_ids[deletedIds[i]];
|
return tmp_id === old_ids[deletedIds[i]];
|
||||||
});
|
});
|
||||||
|
|
||||||
var deletedField = submission.form_fields[index];
|
var deletedField = submission_form_fields[index];
|
||||||
|
|
||||||
//Hide field if it exists
|
//Hide field if it exists
|
||||||
if (deletedField) {
|
if (deletedField) {
|
||||||
|
|
||||||
//Delete old form_field
|
//Delete old form_field
|
||||||
submission.form_fields.splice(index, 1);
|
submission_form_fields.splice(index, 1);
|
||||||
|
|
||||||
deletedField.deletePreserved = true;
|
deletedField.deletePreserved = true;
|
||||||
|
|
||||||
//Move deleted form_field to start
|
//Move deleted form_field to start
|
||||||
submission.form_fields.unshift(deletedField);
|
submission_form_fields.unshift(deletedField);
|
||||||
that.form_fields.unshift(deletedField);
|
currentform_form_fields.unshift(deletedField);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
submission.form_fields = submission_form_fields;
|
||||||
|
that.form_fields = currentform_form_fields;
|
||||||
|
|
||||||
submission.save(function (saveErr) {
|
submission.save(function (saveErr) {
|
||||||
return callback(saveErr);
|
return callback(saveErr);
|
||||||
|
@ -413,13 +421,14 @@ FormSchema.pre('save', function (next) {
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
return cb(err);
|
return cb(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
return cb(null);
|
return cb(null);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
return cb(null);
|
return cb(null);
|
||||||
|
}
|
||||||
}],
|
}],
|
||||||
function(err, results){
|
function(err, results){
|
||||||
next(err);
|
next(err);
|
||||||
|
|
|
@ -10,6 +10,9 @@ var mongoose = require('mongoose'),
|
||||||
Schema = mongoose.Schema,
|
Schema = mongoose.Schema,
|
||||||
LogicJumpSchema = require('./logic_jump.server.model');
|
LogicJumpSchema = require('./logic_jump.server.model');
|
||||||
|
|
||||||
|
const UIDGenerator = require('uid-generator');
|
||||||
|
const uidgen3 = new UIDGenerator(256, UIDGenerator.BASE62);
|
||||||
|
|
||||||
var FieldOptionSchema = new Schema({
|
var FieldOptionSchema = new Schema({
|
||||||
option_id: {
|
option_id: {
|
||||||
type: Number
|
type: Number
|
||||||
|
@ -61,6 +64,9 @@ function BaseFieldSchema(){
|
||||||
Schema.apply(this, arguments);
|
Schema.apply(this, arguments);
|
||||||
|
|
||||||
this.add({
|
this.add({
|
||||||
|
globalId: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
isSubmission: {
|
isSubmission: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
|
@ -193,6 +199,9 @@ FormFieldSchema.pre('save', function(next) {
|
||||||
if(this.logicJump && this.logicJump.fieldA) {
|
if(this.logicJump && this.logicJump.fieldA) {
|
||||||
if(this.logicJump.jumpTo === '') delete this.logicJump.jumpTo;
|
if(this.logicJump.jumpTo === '') delete this.logicJump.jumpTo;
|
||||||
}
|
}
|
||||||
|
if(!this.globalId){
|
||||||
|
this.globalId = uidgen3.generateSync()
|
||||||
|
}
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,16 @@ var FormSubmissionSchema = new Schema({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
FormSubmissionSchema.pre('save', function (next) {
|
||||||
|
//Iterate through form fields and format data
|
||||||
|
for(var i = 0; i < this.form_fields.length; i++){
|
||||||
|
if(this.form_fields[i].fieldType === 'dropdown'){
|
||||||
|
this.form_fields[i].fieldValue = this.form_fields[i].fieldValue.option_value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
|
||||||
FormSubmissionSchema.path('form_fields', {
|
FormSubmissionSchema.path('form_fields', {
|
||||||
set: function(form_fields){
|
set: function(form_fields){
|
||||||
for (var i = 0; i < form_fields.length; i++) {
|
for (var i = 0; i < form_fields.length; i++) {
|
||||||
|
|
|
@ -149,7 +149,6 @@ describe('FormSubmission Model Unit Tests:', function() {
|
||||||
mySubmission.save(function(err, submission) {
|
mySubmission.save(function(err, submission) {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
should.exist(submission);
|
should.exist(submission);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -187,7 +186,7 @@ describe('FormSubmission Model Unit Tests:', function() {
|
||||||
|
|
||||||
//Create Submission
|
//Create Submission
|
||||||
mySubmission = new FormSubmission({
|
mySubmission = new FormSubmission({
|
||||||
form_fields: sampleSubmission,
|
form_fields: _.merge(sampleSubmission, myForm.form_fields),
|
||||||
admin: user,
|
admin: user,
|
||||||
form: myForm,
|
form: myForm,
|
||||||
timeElapsed: 17.55
|
timeElapsed: 17.55
|
||||||
|
@ -200,7 +199,6 @@ describe('FormSubmission Model Unit Tests:', function() {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
|
||||||
it('should preserve deleted form_fields that have submissions without any problems', function(done) {
|
it('should preserve deleted form_fields that have submissions without any problems', function(done) {
|
||||||
|
|
||||||
var old_fields = myForm.toObject().form_fields;
|
var old_fields = myForm.toObject().form_fields;
|
||||||
|
@ -214,17 +212,18 @@ describe('FormSubmission Model Unit Tests:', function() {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
should.exist(_form.form_fields);
|
should.exist(_form.form_fields);
|
||||||
|
|
||||||
var actual_fields = _.deepOmit(_form.toObject().form_fields, ['lastModified', 'created', '_id']);
|
var actual_fields = _.deepOmit(_form.toObject().form_fields, ['deletePreserved', 'globalId', 'lastModified', 'created', '_id', 'submissionId']);
|
||||||
old_fields = _.deepOmit(old_fields, ['lastModified', 'created', '_id']);
|
old_fields = _.deepOmit(old_fields, ['deletePreserved', 'globalId', 'lastModified', 'created', '_id', 'submissionId']);
|
||||||
|
|
||||||
should.deepEqual(JSON.stringify(actual_fields), JSON.stringify(old_fields), 'old form_fields not equal to newly saved form_fields');
|
should.deepEqual(actual_fields, old_fields, 'old form_fields not equal to newly saved form_fields');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
//
|
|
||||||
it('should delete \'preserved\' form_fields whose submissions have been removed without any problems', function(done) {
|
it('should delete \'preserved\' form_fields whose submissions have been removed without any problems', function(done) {
|
||||||
|
|
||||||
var old_fields = myForm.toObject().form_fields;
|
var old_fields = myForm.toObject().form_fields;
|
||||||
|
old_fields.splice(0,1);
|
||||||
var new_form_fields = _.clone(myForm.toObject().form_fields);
|
var new_form_fields = _.clone(myForm.toObject().form_fields);
|
||||||
new_form_fields.splice(0, 1);
|
new_form_fields.splice(0, 1);
|
||||||
|
|
||||||
|
@ -240,16 +239,9 @@ describe('FormSubmission Model Unit Tests:', function() {
|
||||||
|
|
||||||
should.deepEqual(JSON.stringify(actual_fields), JSON.stringify(old_fields)); //'old form_fields not equal to newly saved form_fields');
|
should.deepEqual(JSON.stringify(actual_fields), JSON.stringify(old_fields)); //'old form_fields not equal to newly saved form_fields');
|
||||||
done();
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// //Remove submission
|
|
||||||
// mySubmission.remove(function(err){
|
|
||||||
// myForm.submissions.should.have.length(0);
|
|
||||||
// myForm.form_fields.should.not.containDeep(old_fields[0]);
|
|
||||||
// done();
|
|
||||||
// });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
afterEach(function(done){
|
afterEach(function(done){
|
||||||
mySubmission.remove(function(){
|
mySubmission.remove(function(){
|
||||||
done();
|
done();
|
||||||
|
|
2
config/env/all.js
vendored
2
config/env/all.js
vendored
|
@ -28,7 +28,7 @@ module.exports = {
|
||||||
reCAPTCHA_Key: process.env.reCAPTCHA_KEY || '',
|
reCAPTCHA_Key: process.env.reCAPTCHA_KEY || '',
|
||||||
|
|
||||||
signupDisabled: (process.env.SIGNUP_DISABLED === 'TRUE'),
|
signupDisabled: (process.env.SIGNUP_DISABLED === 'TRUE'),
|
||||||
disableClusterMode: (process.env.DISABLE_CLUSTER_MODE === 'TRUE'),
|
enableClusterMode: (process.env.ENABLE_CLUSTER_MODE === 'TRUE'),
|
||||||
baseUrl: '',
|
baseUrl: '',
|
||||||
tempUserCollection: 'temporary_users',
|
tempUserCollection: 'temporary_users',
|
||||||
|
|
||||||
|
|
1
config/env/development.js
vendored
1
config/env/development.js
vendored
|
@ -9,7 +9,6 @@ module.exports = {
|
||||||
pass: ''
|
pass: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
log: {
|
log: {
|
||||||
// Can specify one of 'combined', 'common', 'dev', 'short', 'tiny'
|
// Can specify one of 'combined', 'common', 'dev', 'short', 'tiny'
|
||||||
format: 'dev',
|
format: 'dev',
|
||||||
|
|
2
config/env/production.js
vendored
2
config/env/production.js
vendored
|
@ -7,7 +7,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
port: process.env.PORT || 5000,
|
port: process.env.PORT || 5000,
|
||||||
socketUrl: process.env.SOCKET_URL || 'ws.tellform.com',
|
socketUrl: process.env.SOCKET_URL || 'ws.tellform.com',
|
||||||
socketPort: process.env.SOCKET_PORT || null,
|
socketPort: process.env.SOCKET_PORT || 20523,
|
||||||
log: {
|
log: {
|
||||||
// Can specify one of 'combined', 'common', 'dev', 'short', 'tiny'
|
// Can specify one of 'combined', 'common', 'dev', 'short', 'tiny'
|
||||||
format: 'combined',
|
format: 'combined',
|
||||||
|
|
|
@ -58,15 +58,12 @@ module.exports = function(db) {
|
||||||
|
|
||||||
if(config.socketPort){
|
if(config.socketPort){
|
||||||
app.locals.socketPort = config.socketPort;
|
app.locals.socketPort = config.socketPort;
|
||||||
} else {
|
|
||||||
app.locals.socketPort = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(config.socketUrl){
|
if(config.socketUrl){
|
||||||
app.locals.socketUrl = config.socketUrl;
|
app.locals.socketUrl = config.socketUrl;
|
||||||
} else {
|
|
||||||
app.locals.socketUrl = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
app.locals.bowerJSFiles = config.getBowerJSAssets();
|
app.locals.bowerJSFiles = config.getBowerJSAssets();
|
||||||
app.locals.bowerCssFiles = config.getBowerCSSAssets();
|
app.locals.bowerCssFiles = config.getBowerCSSAssets();
|
||||||
app.locals.bowerOtherFiles = config.getBowerOtherAssets();
|
app.locals.bowerOtherFiles = config.getBowerOtherAssets();
|
||||||
|
|
|
@ -9,13 +9,9 @@ var config = require('./config'),
|
||||||
// Define the Socket.io configuration method
|
// Define the Socket.io configuration method
|
||||||
module.exports = function (app, db) {
|
module.exports = function (app, db) {
|
||||||
var server = http.createServer(app);
|
var server = http.createServer(app);
|
||||||
var io = socketio(20523, { transports: ['websocket', 'polling'] });
|
var io = socketio(config.socketPort, { transports: ['websocket', 'polling'] });
|
||||||
|
|
||||||
if(config.socketPort){
|
if(config.enableClusterMode){
|
||||||
io = socketio(config.socketPort, { transports: ['websocket', 'polling'] });
|
|
||||||
}
|
|
||||||
|
|
||||||
if(config.disableClusterMode){
|
|
||||||
var redis = require('socket.io-redis');
|
var redis = require('socket.io-redis');
|
||||||
io.adapter(redis( process.env.REDIS_URL || { host: process.env.REDIS_DB_PORT_6379_TCP_ADDR || '127.0.0.1' , port: process.env.REDIS_DB_PORT_6379_TCP_PORT || 6379 }));
|
io.adapter(redis( process.env.REDIS_URL || { host: process.env.REDIS_DB_PORT_6379_TCP_ADDR || '127.0.0.1' , port: process.env.REDIS_DB_PORT_6379_TCP_PORT || 6379 }));
|
||||||
}
|
}
|
||||||
|
|
13
gruntfile.js
13
gruntfile.js
|
@ -210,13 +210,22 @@ module.exports = function(grunt) {
|
||||||
reporter: 'spec',
|
reporter: 'spec',
|
||||||
quiet: false,
|
quiet: false,
|
||||||
require: 'server.js',
|
require: 'server.js',
|
||||||
ui: 'bdd'
|
ui: 'bdd',
|
||||||
|
debug: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
karma: {
|
karma: {
|
||||||
unit: {
|
unit: {
|
||||||
configFile: 'karma.conf.js',
|
configFile: 'karma.conf.js',
|
||||||
singleRun: true
|
singleRun: true
|
||||||
|
},
|
||||||
|
debug: {
|
||||||
|
configFile: 'karma.conf.js',
|
||||||
|
browserConsoleLogOptions: {
|
||||||
|
level: 'log',
|
||||||
|
terminal: true
|
||||||
|
},
|
||||||
|
singleRun: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
protractor: {
|
protractor: {
|
||||||
|
@ -367,4 +376,6 @@ module.exports = function(grunt) {
|
||||||
grunt.registerTask('test', ['lint:tests', 'test:server', 'test:client']);
|
grunt.registerTask('test', ['lint:tests', 'test:server', 'test:client']);
|
||||||
grunt.registerTask('test:server', ['lint:tests', 'env:test', 'mochaTest']);
|
grunt.registerTask('test:server', ['lint:tests', 'env:test', 'mochaTest']);
|
||||||
grunt.registerTask('test:client', ['lint:tests', 'html2js:main', 'html2js:forms', 'env:test', 'karma:unit']);
|
grunt.registerTask('test:client', ['lint:tests', 'html2js:main', 'html2js:forms', 'env:test', 'karma:unit']);
|
||||||
|
|
||||||
|
grunt.registerTask('testdebug', ['env:test', 'karma:debug']);
|
||||||
};
|
};
|
||||||
|
|
|
@ -95,6 +95,7 @@
|
||||||
"socket.io": "^1.4.6",
|
"socket.io": "^1.4.6",
|
||||||
"socket.io-redis": "^1.0.0",
|
"socket.io-redis": "^1.0.0",
|
||||||
"swig": "~1.4.1",
|
"swig": "~1.4.1",
|
||||||
|
"uid-generator": "^0.1.1",
|
||||||
"uuid-token-generator": "^0.5.0",
|
"uuid-token-generator": "^0.5.0",
|
||||||
"wildcard-subdomains": "github:tellform/wildcard-subdomains",
|
"wildcard-subdomains": "github:tellform/wildcard-subdomains",
|
||||||
"winston": "^2.3.1",
|
"winston": "^2.3.1",
|
||||||
|
@ -126,7 +127,7 @@
|
||||||
"karma-jasmine-html-reporter": "^0.1.8",
|
"karma-jasmine-html-reporter": "^0.1.8",
|
||||||
"karma-mocha-reporter": "^1.1.1",
|
"karma-mocha-reporter": "^1.1.1",
|
||||||
"karma-ng-html2js-preprocessor": "^0.2.0",
|
"karma-ng-html2js-preprocessor": "^0.2.0",
|
||||||
"karma-phantomjs-launcher": "~0.2.1",
|
"karma-phantomjs-launcher": "^1.0.4",
|
||||||
"mailosaur": "^1.0.1",
|
"mailosaur": "^1.0.1",
|
||||||
"mocha": "^3.1.2",
|
"mocha": "^3.1.2",
|
||||||
"mocha-lcov-reporter": "^1.0.0",
|
"mocha-lcov-reporter": "^1.0.0",
|
||||||
|
|
63
public/dist/application.js
vendored
63
public/dist/application.js
vendored
File diff suppressed because one or more lines are too long
10
public/dist/application.min.js
vendored
10
public/dist/application.min.js
vendored
File diff suppressed because one or more lines are too long
8
public/dist/form-application.js
vendored
8
public/dist/form-application.js
vendored
File diff suppressed because one or more lines are too long
4
public/dist/form-application.min.js
vendored
4
public/dist/form-application.min.js
vendored
File diff suppressed because one or more lines are too long
8
public/dist/form_populate_template_cache.js
vendored
8
public/dist/form_populate_template_cache.js
vendored
File diff suppressed because one or more lines are too long
2228
public/dist/vendor.min.js
vendored
2228
public/dist/vendor.min.js
vendored
File diff suppressed because one or more lines are too long
2713
public/dist/vendor_forms_uglified.js
vendored
2713
public/dist/vendor_forms_uglified.js
vendored
File diff suppressed because one or more lines are too long
|
@ -44,10 +44,11 @@
|
||||||
socket: null
|
socket: null
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log($window.socketUrl);
|
||||||
var url = '';
|
var url = '';
|
||||||
if($window.socketUrl && $window.socketPort){
|
if($window.socketUrl && $window.socketPort){
|
||||||
url = window.location.protocol + '//' + $window.socketUrl + ':' + $window.socketPort;
|
url = window.location.protocol + '//' + $window.socketUrl + ':' + $window.socketPort;
|
||||||
} else if ($window.socketUrl && !$window.socketPort){
|
} else if ($window.socketUrl){
|
||||||
url = window.location.protocol + '//' + $window.socketUrl;
|
url = window.location.protocol + '//' + $window.socketUrl;
|
||||||
} else if ($window.socketPort){
|
} else if ($window.socketPort){
|
||||||
url = window.location.protocol + '//' + window.location.hostname + ':' + $window.socketPort;
|
url = window.location.protocol + '//' + window.location.hostname + ':' + $window.socketPort;
|
||||||
|
@ -65,5 +66,4 @@
|
||||||
|
|
||||||
Socket.$inject = ['$timeout', '$window'];
|
Socket.$inject = ['$timeout', '$window'];
|
||||||
|
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|
|
@ -25,13 +25,11 @@ angular.module(ApplicationConfiguration.applicationModuleName).run(['$rootScope'
|
||||||
if(statesToIgnore.indexOf(toState.name) > 0){
|
if(statesToIgnore.indexOf(toState.name) > 0){
|
||||||
if(Auth.isAuthenticated()){
|
if(Auth.isAuthenticated()){
|
||||||
event.preventDefault(); // stop current execution
|
event.preventDefault(); // stop current execution
|
||||||
//console.log('go to forms');
|
|
||||||
$state.go('listForms'); // go to listForms page
|
$state.go('listForms'); // go to listForms page
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Redirect to 'signup' route if user is not authenticated
|
//Redirect to 'signup' route if user is not authenticated
|
||||||
else if(toState.name !== 'access_denied' && !Auth.isAuthenticated() && toState.name !== 'submitForm'){
|
else if(toState.name !== 'access_denied' && !Auth.isAuthenticated() && toState.name !== 'submitForm'){
|
||||||
console.log('go to signup');
|
|
||||||
event.preventDefault(); // stop current execution
|
event.preventDefault(); // stop current execution
|
||||||
$state.go('listForms'); // go to listForms page
|
$state.go('listForms'); // go to listForms page
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,10 +51,10 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$windo
|
||||||
heading: $filter('translate')('CONFIGURE_TAB'),
|
heading: $filter('translate')('CONFIGURE_TAB'),
|
||||||
templateName: 'configure'
|
templateName: 'configure'
|
||||||
},
|
},
|
||||||
{
|
/*{
|
||||||
heading: $filter('translate')('ANALYZE_TAB'),
|
heading: $filter('translate')('ANALYZE_TAB'),
|
||||||
templateName: 'analyze'
|
templateName: 'analyze'
|
||||||
}
|
}*/
|
||||||
];
|
];
|
||||||
|
|
||||||
$scope.setForm = function(form){
|
$scope.setForm = function(form){
|
||||||
|
|
|
@ -28,8 +28,6 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
start: function(e, ui) {
|
start: function(e, ui) {
|
||||||
console.log(ui.item);
|
|
||||||
console.log(ui.placeholder);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,18 +13,16 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
|
||||||
|
|
||||||
$scope.table = {
|
$scope.table = {
|
||||||
masterChecker: false,
|
masterChecker: false,
|
||||||
rows: []
|
rows: $scope.myform.submissions
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.table.rows = [];
|
|
||||||
|
|
||||||
var initController = function(){
|
var initController = function(){
|
||||||
|
|
||||||
Forms.get({
|
Forms.get({
|
||||||
formId: $stateParams.formId
|
formId: $stateParams.formId
|
||||||
}, function(form){
|
}, function(form){
|
||||||
$scope.myform = form;
|
$scope.myform = form;
|
||||||
var defaultFormFields = _.cloneDeep($scope.myform.form_fields);
|
$scope.table.rows = form.submissions;
|
||||||
|
/*var defaultFormFields = _.cloneDeep($scope.myform.form_fields);
|
||||||
|
|
||||||
var submissions = $scope.myform.submissions || [];
|
var submissions = $scope.myform.submissions || [];
|
||||||
|
|
||||||
|
@ -41,24 +39,25 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
|
||||||
submissions[i].selected = false;
|
submissions[i].selected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.table.rows = submissions;
|
$scope.table.rows = submissions;*/
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Analytics Functions
|
** Analytics Functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$scope.AverageTimeElapsed = (function(){
|
$scope.AverageTimeElapsed = (function(){
|
||||||
var totalTime = 0;
|
var totalTime = 0;
|
||||||
var numSubmissions = $scope.table.rows.length;
|
var numSubmissions = $scope.table.rows.length;
|
||||||
|
|
||||||
for(i=0; i<$scope.table.rows.length; i++){
|
for(var i=0; i<$scope.table.rows.length; i++){
|
||||||
totalTime += $scope.table.rows[i].timeElapsed;
|
totalTime += $scope.table.rows[i].timeElapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(numSubmissions === 0) {
|
if(numSubmissions === 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (totalTime/numSubmissions).toFixed(0);
|
return (totalTime/numSubmissions).toFixed(0);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
@ -82,7 +81,7 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
|
||||||
|
|
||||||
if($scope.myform.analytics && $scope.myform.analytics.visitors) {
|
if($scope.myform.analytics && $scope.myform.analytics.visitors) {
|
||||||
var visitors = $scope.myform.analytics.visitors;
|
var visitors = $scope.myform.analytics.visitors;
|
||||||
for (i = 0; i < visitors.length; i++) {
|
for (var i = 0; i < visitors.length; i++) {
|
||||||
var visitor = visitors[i];
|
var visitor = visitors[i];
|
||||||
var deviceType = visitor.deviceType;
|
var deviceType = visitor.deviceType;
|
||||||
|
|
||||||
|
@ -105,11 +104,6 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
|
||||||
return stats;
|
return stats;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
|
||||||
initController();
|
|
||||||
|
|
||||||
var updateFields = $interval(initController, 1000000);
|
var updateFields = $interval(initController, 1000000);
|
||||||
|
|
||||||
$scope.$on('$destroy', function() {
|
$scope.$on('$destroy', function() {
|
||||||
|
|
|
@ -62,12 +62,16 @@
|
||||||
<div class="col-xs-12">
|
<div class="col-xs-12">
|
||||||
<uib-tabset active="activePill" vertical="true" type="pills">
|
<uib-tabset active="activePill" vertical="true" type="pills">
|
||||||
<uib-tab index="0" heading="{{ 'CREATE_TAB' | translate }}">
|
<uib-tab index="0" heading="{{ 'CREATE_TAB' | translate }}">
|
||||||
<edit-form-directive myform="myform"></edit-form-directive>
|
<edit-submissions-form-directive myform="myform"></edit-submissions-form-directive>
|
||||||
</uib-tab>
|
</uib-tab>
|
||||||
<uib-tab ng-repeat="tab in tabData" index="{{$index}}+1" heading="{{tab.heading}}">
|
<uib-tab ng-repeat="tab in tabData" index="{{$index}}+1" heading="{{tab.heading}}">
|
||||||
<div class='row' data-ng-include="'/static/modules/forms/admin/views/adminTabs/'+tab.templateName+'.html'" onload="form_url = trustSrc(formURL)"></div>
|
<div class='row' data-ng-include="'/static/modules/forms/admin/views/adminTabs/'+tab.templateName+'.html'" onload="form_url = trustSrc(formURL)"></div>
|
||||||
</uib-tab>
|
</uib-tab>
|
||||||
<uib-tab ng-if="tabData" heading="{{ 'SHARE_TAB' | translate }}" index="{{tabData.length}}">
|
<uib-tab ng-if="tabData" heading="{{ 'SHARE_TAB' | translate }}" index="{{tabData.length}}">
|
||||||
|
<uib-tab index="2" heading="{{ 'ANALYZE_TAB' | translate }}">
|
||||||
|
<edit-form-directive myform="myform" user="myform.admin"></edit-form-directive>
|
||||||
|
</uib-tab>
|
||||||
|
<uib-tab ng-if="tabData" heading="Share" index="{{tabData.length}}">
|
||||||
<div class="config-form">
|
<div class="config-form">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
|
|
|
@ -382,7 +382,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-4 col-xs-12 field-input">{{ 'DISABLED' | translate }}</div>
|
<div class="col-md-4 col-xs-12 field-input">{{ 'DISABLED' | translate }}</div>
|
||||||
<div class="col-md-8 col-xs-12 field-input">
|
<div class="col-md-8 col-xs-12 field-input">
|
||||||
<label class="switch-light switch-holo" ng-click="console.log('clicked switch')">
|
<label class="switch-light switch-holo">
|
||||||
<input type="checkbox" ng-model="field.disabled">
|
<input type="checkbox" ng-model="field.disabled">
|
||||||
<span>
|
<span>
|
||||||
<span> {{ 'OFF' | translate }}</span>
|
<span> {{ 'OFF' | translate }}</span>
|
||||||
|
|
|
@ -57,9 +57,7 @@ angular.module('forms').directive('fieldDirective', ['$http', '$compile', '$root
|
||||||
}else if(type === 'rating'){
|
}else if(type === 'rating'){
|
||||||
scope.field.fieldValue = 0;
|
scope.field.fieldValue = 0;
|
||||||
}else if(scope.field.fieldType === 'radio'){
|
}else if(scope.field.fieldType === 'radio'){
|
||||||
console.log(scope.field);
|
|
||||||
scope.field.fieldValue = scope.field.fieldOptions[0].option_value;
|
scope.field.fieldValue = scope.field.fieldOptions[0].option_value;
|
||||||
console.log(scope.field.fieldValue);
|
|
||||||
}else if(type === 'legal'){
|
}else if(type === 'legal'){
|
||||||
scope.field.fieldValue = 'true';
|
scope.field.fieldValue = 'true';
|
||||||
$rootScope.nextField();
|
$rootScope.nextField();
|
||||||
|
@ -68,7 +66,6 @@ angular.module('forms').directive('fieldDirective', ['$http', '$compile', '$root
|
||||||
|
|
||||||
scope.setActiveField = $rootScope.setActiveField;
|
scope.setActiveField = $rootScope.setActiveField;
|
||||||
|
|
||||||
console.log(scope);
|
|
||||||
//Set format only if field is a date
|
//Set format only if field is a date
|
||||||
if(scope.field.fieldType === 'date'){
|
if(scope.field.fieldType === 'date'){
|
||||||
scope.dateOptions = {
|
scope.dateOptions = {
|
||||||
|
|
|
@ -219,8 +219,6 @@ angular.module('forms').directive('submitFormDirective', ['$http', 'TimeCounter'
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
$scope.submitPromise = $http.post('/forms/' + $scope.myform._id, form)
|
$scope.submitPromise = $http.post('/forms/' + $scope.myform._id, form)
|
||||||
.success(function (data, status, headers) {
|
.success(function (data, status, headers) {
|
||||||
console.log('\n\n\n\n\nSUBMITTING PROMISE');
|
|
||||||
console.log(data);
|
|
||||||
$scope.myform.submitted = true;
|
$scope.myform.submitted = true;
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
SendVisitorData.send($scope.myform, getActiveField(), _timeElapsed);
|
SendVisitorData.send($scope.myform, getActiveField(), _timeElapsed);
|
||||||
|
|
|
@ -1,49 +1,14 @@
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
//Dummy Service for Previewing Form
|
||||||
function SendVisitorData() {
|
function SendVisitorData() {
|
||||||
|
|
||||||
// Create a controller method for sending visitor data
|
// Create a controller method for sending visitor data
|
||||||
function send(form, lastActiveIndex) {
|
function send(form, lastActiveIndex) {
|
||||||
// Create a new message object
|
|
||||||
/*var visitorData = {
|
|
||||||
referrer: document.referrer,
|
|
||||||
isSubmitted: form.submitted,
|
|
||||||
formId: form._id,
|
|
||||||
lastActiveField: form.form_fields[lastActiveIndex]._id,
|
|
||||||
timeElapsed: timeElapsed,
|
|
||||||
//@TODO @FIXME: David: Need to make this get the language from the HTTP Header instead
|
|
||||||
language: window.navigator.userLanguage || window.navigator.language,
|
|
||||||
ipAddr: '',
|
|
||||||
deviceType: ''
|
|
||||||
};
|
|
||||||
|
|
||||||
$http.get('https://jsonip.com/').success(function(response) {
|
|
||||||
visitorData.ipAddr = response['ip']+'';
|
|
||||||
}).error(function(error) {
|
|
||||||
console.error('Could not get users\'s ip');
|
|
||||||
}).then(function(){
|
|
||||||
|
|
||||||
visitorData.userAgent = deviceDetector.raw;
|
|
||||||
|
|
||||||
if(deviceDetector.isTablet()) {
|
|
||||||
visitorData.deviceType = 'tablet';
|
|
||||||
}else if(deviceDetector.isMobile()){
|
|
||||||
visitorData.deviceType = 'phone';
|
|
||||||
}else {
|
|
||||||
visitorData.deviceType = 'desktop';
|
|
||||||
}
|
|
||||||
console.log(visitorData.deviceType);
|
|
||||||
Socket.emit('form-visitor-data', visitorData);
|
|
||||||
});*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function init(){
|
function init(){
|
||||||
// Make sure the Socket is connected
|
|
||||||
/*if (!Socket.socket) {
|
|
||||||
Socket.connect();
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var service = {
|
var service = {
|
||||||
|
@ -54,14 +19,11 @@
|
||||||
return service;
|
return service;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the SendVisitorData service
|
// Create the SendVisitorData service
|
||||||
angular
|
angular
|
||||||
.module('forms')
|
.module('forms')
|
||||||
.factory('SendVisitorData', SendVisitorData);
|
.factory('SendVisitorData', SendVisitorData);
|
||||||
|
|
||||||
SendVisitorData.$inject = [];
|
SendVisitorData.$inject = [];
|
||||||
|
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
|
|
@ -243,7 +243,6 @@
|
||||||
|
|
||||||
//Run controller functionality
|
//Run controller functionality
|
||||||
scope.openDeleteModal();
|
scope.openDeleteModal();
|
||||||
console.log(scope.deleteModal);
|
|
||||||
expect(scope.deleteModal.opened).toEqual(true);
|
expect(scope.deleteModal.opened).toEqual(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -140,8 +140,6 @@
|
||||||
describe('Form Table Methods', function(){
|
describe('Form Table Methods', function(){
|
||||||
|
|
||||||
it('$scope.toggleAllCheckers should toggle all checkboxes in table', function(){
|
it('$scope.toggleAllCheckers should toggle all checkboxes in table', function(){
|
||||||
$httpBackend.flush();
|
|
||||||
|
|
||||||
//Run Controller Logic to Test
|
//Run Controller Logic to Test
|
||||||
scope.table.masterChecker = true;
|
scope.table.masterChecker = true;
|
||||||
scope.toggleAllCheckers();
|
scope.toggleAllCheckers();
|
||||||
|
@ -153,8 +151,6 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
it('$scope.isAtLeastOneChecked should return true when at least one checkbox is selected', function(){
|
it('$scope.isAtLeastOneChecked should return true when at least one checkbox is selected', function(){
|
||||||
$httpBackend.flush();
|
|
||||||
|
|
||||||
scope.table.masterChecker = true;
|
scope.table.masterChecker = true;
|
||||||
scope.toggleAllCheckers();
|
scope.toggleAllCheckers();
|
||||||
|
|
||||||
|
@ -165,8 +161,6 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
it('$scope.deleteSelectedSubmissions should delete all submissions that are selected', function(){
|
it('$scope.deleteSelectedSubmissions should delete all submissions that are selected', function(){
|
||||||
$httpBackend.flush();
|
|
||||||
|
|
||||||
scope.table.masterChecker = true;
|
scope.table.masterChecker = true;
|
||||||
scope.toggleAllCheckers();
|
scope.toggleAllCheckers();
|
||||||
|
|
||||||
|
|
|
@ -86,9 +86,7 @@
|
||||||
scope = el.isolateScope() || el.scope();
|
scope = el.isolateScope() || el.scope();
|
||||||
|
|
||||||
scope.update = function(updateImmediately, data, isDiffed, refreshAfterUpdate, cb){
|
scope.update = function(updateImmediately, data, isDiffed, refreshAfterUpdate, cb){
|
||||||
if(cb){
|
if(cb) cb();
|
||||||
cb();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
@ -153,53 +151,5 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
/*
|
|
||||||
describe('> Form Field Button >',function(){
|
|
||||||
|
|
||||||
it('$scope.addButton() should ADD a button to $scope.myform.startPage.buttons', function() {
|
|
||||||
|
|
||||||
var expectedStartPageBtn = {
|
|
||||||
bgColor:'#ddd',
|
|
||||||
color:'#ffffff',
|
|
||||||
text: 'Button'
|
|
||||||
};
|
|
||||||
|
|
||||||
//Run controller methods
|
|
||||||
scope.addButton();
|
|
||||||
var actualStartPageBtn = _.cloneDeep(_.last(scope.myform.startPage.buttons));
|
|
||||||
delete actualStartPageBtn._id;
|
|
||||||
|
|
||||||
expect(scope.myform.startPage.buttons.length).toEqual(sampleForm.startPage.buttons.length+1);
|
|
||||||
expect(actualStartPageBtn).toEqualData(expectedStartPageBtn);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('$scope.deleteButton() should DELETE a button from $scope.myform.startPage.buttons', function() {
|
|
||||||
//Run controller methods
|
|
||||||
scope.deleteButton(scope.myform.startPage.buttons[0]);
|
|
||||||
|
|
||||||
expect(scope.myform.startPage.buttons.length).toEqual(0);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('> Form Field Option >',function(){
|
|
||||||
it('$scope.addOption() should ADD a new option to a field.fieldOptions', function() {
|
|
||||||
var originalOptionLen = scope.myform.form_fields[1].fieldOptions.length;
|
|
||||||
|
|
||||||
//Run controller methods
|
|
||||||
scope.addOption(1);
|
|
||||||
|
|
||||||
expect(originalOptionLen+1).toEqual(scope.myform.form_fields[1].fieldOptions.length);
|
|
||||||
expect(scope.myform.form_fields[1].fieldOptions[0].option_title).toEqualData('Option 0');
|
|
||||||
expect(scope.myform.form_fields[1].fieldOptions[0].option_value).toEqualData('Option 0');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('$scope.deleteOption() should DELETE remove option from field.fieldOptions', function() {
|
|
||||||
//Run controller methods
|
|
||||||
scope.deleteOption(1, scope.myform.form_fields[1].fieldOptions[0]);
|
|
||||||
|
|
||||||
expect(scope.myform.form_fields[0].fieldOptions.length).toEqual(0);
|
|
||||||
expect(scope.myform.form_fields[0].fieldOptions[0]).not.toBeDefined();
|
|
||||||
});
|
|
||||||
});*/
|
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|
|
@ -65,7 +65,6 @@
|
||||||
|
|
||||||
// it('should be able to render entryPage in html', function() {
|
// it('should be able to render entryPage in html', function() {
|
||||||
// scope.myStartPage = _.cloneDeep(sampleStartPage);
|
// scope.myStartPage = _.cloneDeep(sampleStartPage);
|
||||||
// console.log(scope.myStartPage);
|
|
||||||
// var element = angular.element('<entry-page pageData="myStartPage" pageType="startPage"></entry-page>');
|
// var element = angular.element('<entry-page pageData="myStartPage" pageType="startPage"></entry-page>');
|
||||||
// $compile(element)(scope);
|
// $compile(element)(scope);
|
||||||
// scope.$digest();
|
// scope.$digest();
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should emit Custom "Finished" and "Started" events on ng-repeat', inject(function($compile, $rootScope) {
|
it('should emit Custom "Finished" and "Started" events on ng-repeat', inject(function($compile, $rootScope) {
|
||||||
|
|
||||||
scope.myfields = FormFields.types;
|
scope.myfields = FormFields.types;
|
||||||
|
|
||||||
$compile('<div><div ng-repeat="item in myfields" on-finish-render="editFormFields">{{item.name}}</div></div>')(scope);
|
$compile('<div><div ng-repeat="item in myfields" on-finish-render="editFormFields">{{item.name}}</div></div>')(scope);
|
||||||
|
@ -30,8 +29,6 @@
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should emit "ngRepeat Finished" and "ngRepeat Started" events on ng-repeat when attr is not set to string', inject(function($compile, $rootScope) {
|
it('should emit "ngRepeat Finished" and "ngRepeat Started" events on ng-repeat when attr is not set to string', inject(function($compile, $rootScope) {
|
||||||
|
|
||||||
// console.log(FormFields.types);
|
|
||||||
scope.myfields = FormFields.types;
|
scope.myfields = FormFields.types;
|
||||||
|
|
||||||
$compile('<div><div ng-repeat="item in myfields" on-finish-render>{{item.name}}</div></div>')(scope);
|
$compile('<div><div ng-repeat="item in myfields" on-finish-render>{{item.name}}</div></div>')(scope);
|
||||||
|
|
|
@ -169,7 +169,6 @@
|
||||||
expect(scope.myform.submitted).toBe(true);
|
expect(scope.myform.submitted).toBe(true);
|
||||||
expect(scope.error).toEqual('');
|
expect(scope.error).toEqual('');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('$scope.reloadForm() should reset and reload form', function(){
|
it('$scope.reloadForm() should reset and reload form', function(){
|
||||||
|
|
|
@ -12,7 +12,6 @@ angular.module('stateMock').service('$state', function($q){
|
||||||
}else{
|
}else{
|
||||||
throw Error('No more transitions were expected! Tried to transition to '+ stateName );
|
throw Error('No more transitions were expected! Tried to transition to '+ stateName );
|
||||||
}
|
}
|
||||||
console.log('Mock transition to: ' + stateName);
|
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
var promise = deferred.promise;
|
var promise = deferred.promise;
|
||||||
deferred.resolve();
|
deferred.resolve();
|
||||||
|
|
|
@ -1,170 +0,0 @@
|
||||||
// 'use strict';
|
|
||||||
|
|
||||||
// (function() {
|
|
||||||
|
|
||||||
|
|
||||||
// // Principal controller Spec for E2E Tests
|
|
||||||
// describe('AuthenticationController E2E Tests', function() {
|
|
||||||
|
|
||||||
// describe('/signup should work for a unique username', function() {
|
|
||||||
// beforeEach(function() {
|
|
||||||
// var ptor = protractor.getInstance();
|
|
||||||
// ptor.get('http://localhost:3000/#!/signup');
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('should show the signup panel on page load', function() {
|
|
||||||
// expect($('section > section.row.auth > .col-md-12.text-center')).toEqual('Signup with your email');
|
|
||||||
// });
|
|
||||||
|
|
||||||
|
|
||||||
// //Jasmine it statement : What "it" will do.
|
|
||||||
// it('Verify that the user is logged in', function() {
|
|
||||||
// //Delete all cookies
|
|
||||||
// browser.driver.manage().deleteAllCookies();
|
|
||||||
// //Enter UserName
|
|
||||||
// element.all(by.model('username')).get(0).sendKeys('abc@wingify.com');
|
|
||||||
// //Enter Password
|
|
||||||
// element(by.model('password')).sendKeys('test');
|
|
||||||
// //Click Submit button
|
|
||||||
// element(by.css('.login-form button[type="submit"]')).click();
|
|
||||||
// //Wait for the current URL to change to welcome
|
|
||||||
// browser.driver.wait(function() {
|
|
||||||
// return browser.driver.getCurrentUrl().then(function(url) {
|
|
||||||
// return (/welcome/).test(url);
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// var firstname = element(by.model('credentials.firstname')),
|
|
||||||
// lastname = element(by.model('credentials.lastname')),
|
|
||||||
// email = element(by.model('credentials.email')),
|
|
||||||
// password = element(by.model('credentials.password'));
|
|
||||||
|
|
||||||
// email.sendKeys('admin@app.com');
|
|
||||||
// firstname.sendKeys('admin_first');
|
|
||||||
// lastname.sendKeys('admin_last');
|
|
||||||
// password.sendKeys('1234');
|
|
||||||
|
|
||||||
// //Click signup button
|
|
||||||
// element(by.css('.btn.btn-large.btn-primary')).click().then(function () {
|
|
||||||
// expect(browser.getCurrentUrl()).toEqual('http://localhost:3000/#!/signup-success');
|
|
||||||
// });
|
|
||||||
|
|
||||||
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// // Principal controller Spec
|
|
||||||
// describe('AuthenticationController Unit Tests', function() {
|
|
||||||
// // Initialize global variables
|
|
||||||
// var AuthenticationController,
|
|
||||||
// scope,
|
|
||||||
// $httpBackend,
|
|
||||||
// $stateParams,
|
|
||||||
// $location;
|
|
||||||
|
|
||||||
// beforeEach(function() {
|
|
||||||
// jasmine.addMatchers({
|
|
||||||
// toEqualData: function(util, customEqualityTesters) {
|
|
||||||
// return {
|
|
||||||
// compare: function(actual, expected) {
|
|
||||||
// return {
|
|
||||||
// pass: angular.equals(actual, expected)
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
// // Load the main application module
|
|
||||||
// beforeEach(module(ApplicationConfiguration.applicationModuleName));
|
|
||||||
|
|
||||||
// // The injector ignores leading and trailing underscores here (i.e. _$httpBackend_).
|
|
||||||
// // This allows us to inject a service but then attach it to a variable
|
|
||||||
// // with the same name as the service.
|
|
||||||
// beforeEach(inject(function($controller, $rootScope, _$location_, _$stateParams_, _$httpBackend_) {
|
|
||||||
// // Set a new global scope
|
|
||||||
// scope = $rootScope.$new();
|
|
||||||
|
|
||||||
// // Point global variables to injected services
|
|
||||||
// $stateParams = _$stateParams_;
|
|
||||||
// $httpBackend = _$httpBackend_;
|
|
||||||
// $location = _$location_;
|
|
||||||
|
|
||||||
// // Initialize the Principal controller
|
|
||||||
// AuthenticationController = $controller('AuthenticationController', {
|
|
||||||
// $scope: scope
|
|
||||||
// });
|
|
||||||
// }));
|
|
||||||
|
|
||||||
|
|
||||||
// it('$scope.signin() should login with a correct user and password', function() {
|
|
||||||
// // Test expected GET request
|
|
||||||
// $httpBackend.when('POST', '/auth/signin').respond(200, 'Fred');
|
|
||||||
|
|
||||||
// scope.signin();
|
|
||||||
// $httpBackend.flush();
|
|
||||||
|
|
||||||
// // Test scope value
|
|
||||||
// expect(scope.authentication.user).toEqual('Fred');
|
|
||||||
// expect($location.url()).toEqual('/');
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('$scope.signin() should fail to log in with nothing', function() {
|
|
||||||
// // Test expected POST request
|
|
||||||
// $httpBackend.expectPOST('/auth/signin').respond(400, {
|
|
||||||
// 'message': 'Missing credentials'
|
|
||||||
// });
|
|
||||||
|
|
||||||
// scope.signin();
|
|
||||||
// $httpBackend.flush();
|
|
||||||
|
|
||||||
// // Test scope value
|
|
||||||
// expect(scope.error).toEqual('Missing credentials');
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('$scope.signin() should fail to log in with wrong credentials', function() {
|
|
||||||
// // Foo/Bar combo assumed to not exist
|
|
||||||
// scope.authentication.user = 'Foo';
|
|
||||||
// scope.credentials = 'Bar';
|
|
||||||
|
|
||||||
// // Test expected POST request
|
|
||||||
// $httpBackend.expectPOST('/auth/signin').respond(400, {
|
|
||||||
// 'message': 'Unknown user'
|
|
||||||
// });
|
|
||||||
|
|
||||||
// scope.signin();
|
|
||||||
// $httpBackend.flush();
|
|
||||||
|
|
||||||
// // Test scope value
|
|
||||||
// expect(scope.error).toEqual('Unknown user');
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('$scope.signup() should register with correct data', function() {
|
|
||||||
// // Test expected GET request
|
|
||||||
// scope.authentication.user = 'Fred';
|
|
||||||
// $httpBackend.when('POST', '/auth/signup').respond(200, 'Fred');
|
|
||||||
|
|
||||||
// scope.signup();
|
|
||||||
// $httpBackend.flush();
|
|
||||||
|
|
||||||
// // test scope value
|
|
||||||
// expect(scope.authentication.user).toBe('Fred');
|
|
||||||
// expect(scope.error).toEqual(undefined);
|
|
||||||
// expect($location.url()).toBe('/');
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it('$scope.signup() should fail to register with duplicate Username', function() {
|
|
||||||
// // Test expected POST request
|
|
||||||
// $httpBackend.when('POST', '/auth/signup').respond(400, {
|
|
||||||
// 'message': 'Username already exists'
|
|
||||||
// });
|
|
||||||
|
|
||||||
// scope.signup();
|
|
||||||
// $httpBackend.flush();
|
|
||||||
|
|
||||||
// // Test scope value
|
|
||||||
// expect(scope.error).toBe('Username already exists');
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// }());
|
|
|
@ -1,181 +1,181 @@
|
||||||
// 'use strict';
|
'use strict';
|
||||||
|
|
||||||
// (function() {
|
(function() {
|
||||||
// // Forms Controller Spec
|
// Forms Controller Spec
|
||||||
// describe('Authentication Controller Tests', function() {
|
describe('Authentication Controller Tests', function() {
|
||||||
// // Initialize global variables
|
// Initialize global variables
|
||||||
// var AuthenticationController,
|
var AuthenticationController,
|
||||||
// scope,
|
scope,
|
||||||
// $httpBackend,
|
$httpBackend,
|
||||||
// $stateParams,
|
$stateParams,
|
||||||
// $location,
|
$location,
|
||||||
// $state;
|
$state;
|
||||||
|
|
||||||
// var sampleUser = {
|
var sampleUser = {
|
||||||
// firstName: 'Full',
|
firstName: 'Full',
|
||||||
// lastName: 'Name',
|
lastName: 'Name',
|
||||||
// email: 'test@test.com',
|
email: 'test@test.com',
|
||||||
// username: 'test@test.com',
|
username: 'test@test.com',
|
||||||
// password: 'password',
|
password: 'password',
|
||||||
// provider: 'local',
|
provider: 'local',
|
||||||
// roles: ['user'],
|
roles: ['user'],
|
||||||
// _id: 'ed873933b1f1dea0ce12fab9'
|
_id: 'ed873933b1f1dea0ce12fab9'
|
||||||
// };
|
};
|
||||||
|
|
||||||
// var sampleForm = {
|
var sampleForm = {
|
||||||
// title: 'Form Title',
|
title: 'Form Title',
|
||||||
// admin: 'ed873933b1f1dea0ce12fab9',
|
admin: 'ed873933b1f1dea0ce12fab9',
|
||||||
// language: 'english',
|
language: 'english',
|
||||||
// form_fields: [
|
form_fields: [
|
||||||
// {fieldType:'textfield', title:'First Name', fieldValue: '', deletePreserved: false},
|
{fieldType:'textfield', title:'First Name', fieldValue: '', deletePreserved: false},
|
||||||
// {fieldType:'checkbox', title:'nascar', fieldValue: '', deletePreserved: false},
|
{fieldType:'checkbox', title:'nascar', fieldValue: '', deletePreserved: false},
|
||||||
// {fieldType:'checkbox', title:'hockey', fieldValue: '', deletePreserved: false}
|
{fieldType:'checkbox', title:'hockey', fieldValue: '', deletePreserved: false}
|
||||||
// ],
|
],
|
||||||
// _id: '525a8422f6d0f87f0e407a33'
|
_id: '525a8422f6d0f87f0e407a33'
|
||||||
// };
|
};
|
||||||
|
|
||||||
// var expectedForm = {
|
var expectedForm = {
|
||||||
// title: 'Form Title',
|
title: 'Form Title',
|
||||||
// admin: 'ed873933b1f1dea0ce12fab9',
|
admin: 'ed873933b1f1dea0ce12fab9',
|
||||||
// language: 'english',
|
language: 'english',
|
||||||
// form_fields: [
|
form_fields: [
|
||||||
// {fieldType:'textfield', title:'First Name', fieldValue: '', deletePreserved: false},
|
{fieldType:'textfield', title:'First Name', fieldValue: '', deletePreserved: false},
|
||||||
// {fieldType:'checkbox', title:'nascar', fieldValue: '', deletePreserved: false},
|
{fieldType:'checkbox', title:'nascar', fieldValue: '', deletePreserved: false},
|
||||||
// {fieldType:'checkbox', title:'hockey', fieldValue: '', deletePreserved: false}
|
{fieldType:'checkbox', title:'hockey', fieldValue: '', deletePreserved: false}
|
||||||
// ],
|
],
|
||||||
// visible_form_fields: [
|
visible_form_fields: [
|
||||||
// {fieldType:'textfield', title:'First Name', fieldValue: '', deletePreserved: false},
|
{fieldType:'textfield', title:'First Name', fieldValue: '', deletePreserved: false},
|
||||||
// {fieldType:'checkbox', title:'nascar', fieldValue: '', deletePreserved: false},
|
{fieldType:'checkbox', title:'nascar', fieldValue: '', deletePreserved: false},
|
||||||
// {fieldType:'checkbox', title:'hockey', fieldValue: '', deletePreserved: false}
|
{fieldType:'checkbox', title:'hockey', fieldValue: '', deletePreserved: false}
|
||||||
// ],
|
],
|
||||||
// _id: '525a8422f6d0f87f0e407a33'
|
_id: '525a8422f6d0f87f0e407a33'
|
||||||
// };
|
};
|
||||||
|
|
||||||
// var sampleCredentials = {
|
var sampleCredentials = {
|
||||||
// username: sampleUser.username,
|
username: sampleUser.username,
|
||||||
// password: sampleUser.password,
|
password: sampleUser.password,
|
||||||
// };
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// // The $resource service augments the response object with methods for updating and deleting the resource.
|
// The $resource service augments the response object with methods for updating and deleting the resource.
|
||||||
// // If we were to use the standard toEqual matcher, our tests would fail because the test values would not match
|
// If we were to use the standard toEqual matcher, our tests would fail because the test values would not match
|
||||||
// // the responses exactly. To solve the problem, we define a new toEqualData Jasmine matcher.
|
// the responses exactly. To solve the problem, we define a new toEqualData Jasmine matcher.
|
||||||
// // When the toEqualData matcher compares two objects, it takes only object properties into
|
// When the toEqualData matcher compares two objects, it takes only object properties into
|
||||||
// // account and ignores methods.
|
// account and ignores methods.
|
||||||
// beforeEach(function() {
|
beforeEach(function() {
|
||||||
// jasmine.addMatchers({
|
jasmine.addMatchers({
|
||||||
// toEqualData: function(util, customEqualityTesters) {
|
toEqualData: function(util, customEqualityTesters) {
|
||||||
// return {
|
return {
|
||||||
// compare: function(actual, expected) {
|
compare: function(actual, expected) {
|
||||||
// return {
|
return {
|
||||||
// pass: angular.equals(actual, expected)
|
pass: angular.equals(actual, expected)
|
||||||
// };
|
};
|
||||||
// }
|
}
|
||||||
// };
|
};
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
|
|
||||||
// // Load the main application module
|
// Load the main application module
|
||||||
// beforeEach(module(ApplicationConfiguration.applicationModuleName));
|
beforeEach(module(ApplicationConfiguration.applicationModuleName));
|
||||||
|
|
||||||
// beforeEach(module('stateMock'));
|
beforeEach(module('stateMock'));
|
||||||
|
|
||||||
// // Mock Users Service
|
// Mock Users Service
|
||||||
// beforeEach(module(function($provide) {
|
beforeEach(module(function($provide) {
|
||||||
// $provide.service('User', function($q) {
|
$provide.service('User', function($q) {
|
||||||
// return {
|
return {
|
||||||
// getCurrent: function() {
|
getCurrent: function() {
|
||||||
// var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
// deferred.resolve( JSON.stringify(sampleUser) );
|
deferred.resolve( JSON.stringify(sampleUser) );
|
||||||
// return deferred.promise;
|
return deferred.promise;
|
||||||
// },
|
},
|
||||||
// login: function(credentials) {
|
login: function(credentials) {
|
||||||
// var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
// if( credentials.password === sampleUser.password && credentials.username === sampleUser.username){
|
if( credentials.password === sampleUser.password && credentials.username === sampleUser.username){
|
||||||
// deferred.resolve( JSON.stringify(sampleUser) );
|
deferred.resolve( JSON.stringify(sampleUser) );
|
||||||
// }else {
|
}else {
|
||||||
// deferred.resolve('Error: User could not be loggedin');
|
deferred.resolve('Error: User could not be loggedin');
|
||||||
// }
|
}
|
||||||
|
|
||||||
// return deferred.promise;
|
return deferred.promise;
|
||||||
// },
|
},
|
||||||
// logout: function() {
|
logout: function() {
|
||||||
// var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
// deferred.resolve(null);
|
deferred.resolve(null);
|
||||||
// return deferred.promise;
|
return deferred.promise;
|
||||||
// },
|
},
|
||||||
// signup: function(credentials) {
|
signup: function(credentials) {
|
||||||
// var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
// if( credentials.password === sampleUser.password && credentials.username === sampleUser.username){
|
if( credentials.password === sampleUser.password && credentials.username === sampleUser.username){
|
||||||
// deferred.resolve( JSON.stringify(sampleUser) );
|
deferred.resolve( JSON.stringify(sampleUser) );
|
||||||
// }else {
|
}else {
|
||||||
// deferred.resolve('Error: User could not be signed up');
|
deferred.resolve('Error: User could not be signed up');
|
||||||
// }
|
}
|
||||||
|
|
||||||
// return deferred.promise;
|
return deferred.promise;
|
||||||
// }
|
}
|
||||||
// };
|
};
|
||||||
// });
|
});
|
||||||
// }));
|
}));
|
||||||
|
|
||||||
// // Mock Authentication Service
|
// Mock Authentication Service
|
||||||
// beforeEach(module(function($provide) {
|
beforeEach(module(function($provide) {
|
||||||
// $provide.service('Auth', function() {
|
$provide.service('Auth', function() {
|
||||||
// return {
|
return {
|
||||||
// ensureHasCurrentUser: function() {
|
ensureHasCurrentUser: function() {
|
||||||
// return sampleUser;
|
return sampleUser;
|
||||||
// },
|
},
|
||||||
// isAuthenticated: function() {
|
isAuthenticated: function() {
|
||||||
// return true;
|
return true;
|
||||||
// },
|
},
|
||||||
// getUserState: function() {
|
getUserState: function() {
|
||||||
// return true;
|
return true;
|
||||||
// }
|
}
|
||||||
// };
|
};
|
||||||
// });
|
});
|
||||||
// }));
|
}));
|
||||||
|
|
||||||
// // The injector ignores leading and trailing underscores here (i.e. _$httpBackend_).
|
// The injector ignores leading and trailing underscores here (i.e. _$httpBackend_).
|
||||||
// // This allows us to inject a service but then attach it to a variable
|
// This allows us to inject a service but then attach it to a variable
|
||||||
// // with the same name as the service.
|
// with the same name as the service.
|
||||||
// beforeEach(inject(function($controller, $rootScope, _$state_, _$location_, _$stateParams_, _$httpBackend_, CurrentForm, Forms) {
|
beforeEach(inject(function($controller, $rootScope, _$state_, _$location_, _$stateParams_, _$httpBackend_, CurrentForm, Forms) {
|
||||||
// // Set a new global scope
|
// Set a new global scope
|
||||||
// scope = $rootScope.$new();
|
scope = $rootScope.$new();
|
||||||
// scope.abc = 'hello';
|
scope.abc = 'hello';
|
||||||
|
|
||||||
// // Point global variables to injected services
|
// Point global variables to injected services
|
||||||
// $stateParams = _$stateParams_;
|
$stateParams = _$stateParams_;
|
||||||
// $httpBackend = _$httpBackend_;
|
$httpBackend = _$httpBackend_;
|
||||||
// $location = _$location_;
|
$location = _$location_;
|
||||||
// $state = _$state_;
|
$state = _$state_;
|
||||||
|
|
||||||
// // $httpBackend.whenGET(/\.html$/).respond('');
|
// $httpBackend.whenGET(/\.html$/).respond('');
|
||||||
// $httpBackend.whenGET('/users/me/').respond('');
|
$httpBackend.whenGET('/users/me/').respond('');
|
||||||
|
|
||||||
// // Initialize the Forms controller.
|
// Initialize the Forms controller.
|
||||||
// AuthenticationController = $controller('AuthenticationController', { $scope: scope });
|
AuthenticationController = $controller('AuthenticationController', { $scope: scope });
|
||||||
// }));
|
}));
|
||||||
|
|
||||||
// it('$scope.signin should sigin in user with valid credentials', inject(function(Auth) {
|
it('$scope.signin should sigin in user with valid credentials', inject(function(Auth) {
|
||||||
|
|
||||||
// //Set $state transition
|
//Set $state transition
|
||||||
// // $state.expectTransitionTo('listForms');
|
// $state.expectTransitionTo('listForms');
|
||||||
// //Set POST response
|
//Set POST response
|
||||||
// // $httpBackend.expect('POST', '/auth/signin', sampleCredentials).respond(200, sampleUser);
|
// $httpBackend.expect('POST', '/auth/signin', sampleCredentials).respond(200, sampleUser);
|
||||||
|
|
||||||
// scope.abc = 'sampleCredentials';
|
scope.abc = 'sampleCredentials';
|
||||||
// //Run Controller Logic to Test
|
//Run Controller Logic to Test
|
||||||
// scope.signin();
|
scope.signin();
|
||||||
|
|
||||||
// // $httpBackend.flush();
|
// $httpBackend.flush();
|
||||||
|
|
||||||
// // Test scope value
|
// Test scope value
|
||||||
// // expect(Auth.ensureHasCurrentUser()).toEqualData(sampleUser);
|
// expect(Auth.ensureHasCurrentUser()).toEqualData(sampleUser);
|
||||||
// }));
|
}));
|
||||||
|
|
||||||
|
|
||||||
// });
|
});
|
||||||
// }());
|
}());
|
|
@ -65,7 +65,6 @@
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('Auth.getUserState() should fetch current user state', function() {
|
it('Auth.getUserState() should fetch current user state', function() {
|
||||||
|
|
||||||
//Run Service Logic to Test
|
//Run Service Logic to Test
|
||||||
Auth.login(sampleUser);
|
Auth.login(sampleUser);
|
||||||
var currUserState = Auth.getUserState();
|
var currUserState = Auth.getUserState();
|
||||||
|
|
Loading…
Reference in a new issue