Resend your verification emailSignin to your account");
-}]);
-
-'use strict';
-
// Use Application configuration module to register a new module
ApplicationConfiguration.registerModule('core', ['users']);
@@ -1097,54 +773,6 @@ angular.module('core').service('Menus', [
'use strict';
-module.exports = function(grunt) {
- require('jit-grunt')(grunt);
-
- // Project Configuration
- grunt.initConfig({
- ngAnnotate: {
- production: {
- files: {
- 'dist/form.js': [
- 'config/**/*.js', 'controllers/**/*.js',
- 'directives/**/*.js', 'services/**/*.js',
- 'dist/template.js'
- ]
- }
- }
- },
- html2js: {
- options: {
- base: '',
- module: 'NodeForm.templates',
- singleModule: true,
- rename: function (moduleName) {
- return 'modules/forms/base/' + moduleName;
- }
- },
- form: {
- src: ['views/**/*.html'],
- dest: 'dist/template.js'
- }
- },
- cssmin: {
- combine: {
- files: {
- 'dist/form.css': 'css/**/*.css'
- }
- }
- },
- });
-
- // Making grunt default to force in order not to break the project.
- grunt.option('force', true);
-
- // Default task(s).
- grunt.registerTask('default', ['html2js:form', 'ngAnnotate', 'cssmin']);
-};
-
-'use strict';
-
// Configuring the Forms drop-down menus
angular.module('forms').run(['Menus',
function(Menus) {
@@ -1940,52 +1568,6 @@ angular.module('users').factory('Users', ['$resource',
]);
'use strict';
-(function() {
- describe('HeaderController', function() {
- //Initialize global variables
- var scope,
- HeaderController;
-
- // Load the main application module
- beforeEach(module(ApplicationConfiguration.applicationModuleName));
-
- beforeEach(inject(function($controller, $rootScope) {
- scope = $rootScope.$new();
-
- HeaderController = $controller('HeaderController', {
- $scope: scope
- });
- }));
-
- it('should expose the authentication service', function() {
- expect(scope.authentication).toBeTruthy();
- });
- });
-})();
-'use strict';
-
-(function() {
- describe('HomeController', function() {
- //Initialize global variables
- var scope,
- HomeController;
-
- // Load the main application module
- beforeEach(module(ApplicationConfiguration.applicationModuleName));
-
- beforeEach(inject(function($controller, $rootScope) {
- scope = $rootScope.$new();
-
- HomeController = $controller('HomeController', {
- $scope: scope
- });
- }));
-
- });
-})();
-
-'use strict';
-
// Forms controller
angular.module('forms').controller('AdminFormController', ['$rootScope', '$scope', '$stateParams', '$state', 'Forms', 'CurrentForm', '$http', '$uibModal', 'myForm',
function($rootScope, $scope, $stateParams, $state, Forms, CurrentForm, $http, $uibModal, myForm) {
@@ -2448,6 +2030,8 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
myform:'='
},
controller: ["$scope", function($scope){
+
+ console.log($scope.myform);
var field_ids = _($scope.myform.form_fields).pluck('_id');
for(var i=0; i= 0) {
- var templateUrl = 'modules/forms/views/directiveViews/field/';
+ var templateUrl = 'modules/forms/base/views/directiveViews/field/';
templateUrl = templateUrl+type+'.html';
- }
- return $templateCache.get(templateUrl);
+
+ console.log(templateUrl);
+ return $templateCache.get(templateUrl);
+ }
+ return null;
};
return {
@@ -3258,6 +2714,7 @@ angular.module('forms').directive('fieldDirective', ['$http', '$compile', '$root
fieldType = 'textfield';
}
var template = getTemplateUrl(fieldType);
+ console.log(template);
element.html(template).show();
var output = $compile(element.contents())(scope);
}
@@ -3375,7 +2832,8 @@ angular.module('forms').directive('onFinishRender', ["$rootScope", "$timeout", f
angular.module('forms').directive('submitFormDirective', ['$http', 'TimeCounter', '$filter', '$rootScope', 'Auth', 'SendVisitorData',
function ($http, TimeCounter, $filter, $rootScope, Auth, SendVisitorData) {
return {
- templateUrl: 'modules/forms/base/views/directiveViews/form/submit-form.client.view.html', restrict: 'E',
+ templateUrl: 'modules/forms/base/views/directiveViews/form/submit-form.client.view.html',
+ restrict: 'E',
scope: {
myform:'='
},
@@ -3708,2539 +3166,3 @@ angular.module('forms').service('TimeCounter', [
}
]);
-
-'use strict';
-
-(function() {
- // Forms Controller Spec
- describe('AdminForm Controller Tests', function() {
- // Initialize global variables
- var AdminFormController,
- createAdminFormController,
- scope,
- $httpBackend,
- $stateParams,
- $location,
- $state;
-
- var sampleUser = {
- firstName: 'Full',
- lastName: 'Name',
- email: 'test@test.com',
- username: 'test@test.com',
- password: 'password',
- provider: 'local',
- roles: ['user'],
- _id: 'ed873933b1f1dea0ce12fab9'
- };
-
- var sampleForm = {
- title: 'Form Title',
- admin: 'ed873933b1f1dea0ce12fab9',
- language: 'english',
- form_fields: [
- {fieldType:'textfield', title:'First Name', fieldValue: '', deletePreserved: false, _id:'56340745f59a6fc9e22028e9'},
- {fieldType:'checkbox', title:'nascar', fieldValue: '', deletePreserved: false, _id:'5c9e22028e907634f45f59a6'},
- {fieldType:'checkbox', title:'hockey', fieldValue: '', deletePreserved: false, _id:'56e90745f5934fc9e22028a6'}
- ],
- _id: '525a8422f6d0f87f0e407a33'
- };
-
- var expectedForm = {
- title: 'Form Title',
- admin: 'ed873933b1f1dea0ce12fab9',
- language: 'english',
- form_fields: [
- {fieldType:'textfield', title:'First Name', fieldValue: '', deletePreserved: false, _id:'56340745f59a6fc9e22028e9'},
- {fieldType:'checkbox', title:'nascar', fieldValue: '', deletePreserved: false, _id:'5c9e22028e907634f45f59a6'},
- {fieldType:'checkbox', title:'hockey', fieldValue: '', deletePreserved: false, _id:'56e90745f5934fc9e22028a6'}
- ],
- visible_form_fields: [
- {fieldType:'textfield', title:'First Name', fieldValue: '', deletePreserved: false, _id:'56340745f59a6fc9e22028e9'},
- {fieldType:'checkbox', title:'nascar', fieldValue: '', deletePreserved: false, _id:'5c9e22028e907634f45f59a6'},
- {fieldType:'checkbox', title:'hockey', fieldValue: '', deletePreserved: false, _id:'56e90745f5934fc9e22028a6'}
- ],
- _id: '525a8422f6d0f87f0e407a33'
- };
-
- var newFakeModal = function(){
- var result = {
- opened: true,
- result: {
- then: function(confirmCallback, cancelCallback) {
- //Store the callbacks for later when the user clicks on the OK or Cancel button of the dialog
- this.confirmCallBack = confirmCallback;
- this.cancelCallback = cancelCallback;
- }
- },
- close: function( item ) {
- //The user clicked OK on the modal dialog, call the stored confirm callback with the selected item
- this.opened = false;
- this.result.confirmCallBack( item );
- },
- dismiss: function( type ) {
- //The user clicked cancel on the modal dialog, call the stored cancel callback
- this.opened = false;
- this.result.cancelCallback( type );
- }
- };
- return result;
- };
-
- //Mock Users Service
- beforeEach(module(function($provide) {
- $provide.service('myForm', function($q) {
- return sampleForm;
- });
- }));
-
-
- // 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
- // 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
- // account and ignores methods.
- 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));
-
- beforeEach(module('stateMock'));
-
- //Mock Users Service
- beforeEach(module(function($provide) {
- $provide.service('User', function($q) {
- return {
- getCurrent: function() {
- var deferred = $q.defer();
- deferred.resolve( JSON.stringify(sampleUser) );
- return deferred.promise;
- },
- login: function(credentials) {
- var deferred = $q.defer();
- if( credentials.password === sampleUser.password && credentials.username === sampleUser.username){
- deferred.resolve( JSON.stringify(sampleUser) );
- }else {
- deferred.resolve('Error: User could not be loggedin');
- }
-
- return deferred.promise;
- },
- logout: function() {
- var deferred = $q.defer();
- deferred.resolve(null);
- return deferred.promise;
- },
- signup: function(credentials) {
- var deferred = $q.defer();
- if( credentials.password === sampleUser.password && credentials.username === sampleUser.username){
- deferred.resolve( JSON.stringify(sampleUser) );
- }else {
- deferred.resolve('Error: User could not be signed up');
- }
-
- return deferred.promise;
- }
- };
- });
- }));
-
- //Mock Authentication Service
- beforeEach(module(function($provide) {
- $provide.service('Auth', function() {
- return {
- ensureHasCurrentUser: function() {
- return sampleUser;
- },
- isAuthenticated: function() {
- return true;
- },
- getUserState: function() {
- return true;
- }
- };
- });
- }));
-
-
- //Mock $uibModal
- beforeEach(inject(function($uibModal) {
- var modal = newFakeModal();
- spyOn($uibModal, 'open').and.returnValue(modal);
- //spyOn($uibModal, 'close').and.callFake(modal.close());
- }));
-
- // 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, _$state_, _$location_, _$stateParams_, _$httpBackend_, CurrentForm, Forms) {
- // Set a new global scope
- scope = $rootScope.$new();
-
- //Set CurrentForm
- CurrentForm.setForm(sampleForm);
-
- // Point global variables to injected services
- $stateParams = _$stateParams_;
- $httpBackend = _$httpBackend_;
- $location = _$location_;
- $state = _$state_;
-
- $httpBackend.whenGET(/\.html$/).respond('');
- $httpBackend.whenGET('/users/me/').respond('');
-
- // Initialize the Forms controller.
- createAdminFormController = function(){
- return $controller('AdminFormController', { $scope: scope });
- };
- }));
-
- it('AdminFormController should fetch current Form when instantiated', function() {
- // Run controller functionality
- var controller = createAdminFormController();
-
- // Test scope value
- expect(scope.myform).toEqualData(sampleForm);
- });
-
- it('$scope.removeCurrentForm() with valid form data should send a DELETE request with the id of form', function() {
- var controller = createAdminFormController();
-
- //Set $state transition
- $state.expectTransitionTo('listForms');
-
- // Set DELETE response
- $httpBackend.expect('DELETE', /^(\/forms\/)([0-9a-fA-F]{24})$/).respond(200, sampleForm);
-
- //Run controller functionality
- scope.openDeleteModal();
- scope.removeCurrentForm();
-
- $httpBackend.flush();
- $state.ensureAllTransitionsHappened();
- });
-
- it('$scope.update() should send a PUT request with the id of form', function() {
- var controller = createAdminFormController();
-
- //Set PUT response
- $httpBackend.expect('PUT', /^(\/forms\/)([0-9a-fA-F]{24})$/).respond(200, sampleForm);
-
- //Run controller functionality
- scope.update(false, null);
-
- $httpBackend.flush();
- });
-
- it('$scope.openDeleteModal() should open scope.deleteModal', function() {
- var controller = createAdminFormController();
-
- //Run controller functionality
- scope.openDeleteModal();
- console.log(scope.deleteModal);
- expect(scope.deleteModal.opened).toEqual(true);
- });
-
- it('$scope.cancelDeleteModal() should close $scope.deleteModal', inject(function($uibModal) {
- var controller = createAdminFormController();
-
- //Run controller functionality
- scope.openDeleteModal();
-
- //Run controller functionality
- scope.cancelDeleteModal();
- expect( scope.deleteModal.opened ).toEqual(false);
- }));
- });
-}());
-'use strict';
-
-(function() {
- // Forms Controller Spec
- describe('ListForms Controller Tests', function() {
- // Initialize global variables
- var ListFormsController,
- createListFormsController,
- scope,
- $httpBackend,
- $stateParams,
- $location,
- $state;
-
- var sampleForm = {
- title: 'Form Title',
- admin: 'ed873933b1f1dea0ce12fab9',
- language: 'english',
- form_fields: [
- {fieldType:'textfield', title:'First Name', fieldValue: '', deletePreserved: false},
- {fieldType:'checkbox', title:'nascar', fieldValue: '', deletePreserved: false},
- {fieldType:'checkbox', title:'hockey', fieldValue: '', deletePreserved: false}
- ],
- _id: '525a8422f6d0f87f0e407a33'
- };
-
- var sampleFormList = [{
- title: 'Form Title1',
- admin: 'ed873933b1f1dea0ce12fab9',
- language: 'english',
- form_fields: [
- {fieldType:'textfield', title:'First Name', fieldValue: '', deletePreserved: false},
- {fieldType:'checkbox', title:'nascar', fieldValue: '', deletePreserved: false},
- {fieldType:'checkbox', title:'hockey', fieldValue: '', deletePreserved: false}
- ],
- _id: '525a8422f6d0f87f0e407a33'
- },{
- title: 'Form Title2',
- admin: '39223933b1f1dea0ce12fab9',
- language: 'english',
- form_fields: [
- {fieldType:'textfield', title:'First Name', fieldValue: '', deletePreserved: false},
- {fieldType:'checkbox', title:'nascar', fieldValue: '', deletePreserved: false},
- {fieldType:'checkbox', title:'hockey', fieldValue: '', deletePreserved: false}
- ],
- _id: '52f6d0f87f5a407a384220e3'
- },{
- title: 'Form Title3',
- admin: '2fab9ed873937f0e1dea0ce1',
- language: 'english',
- form_fields: [
- {fieldType:'textfield', title:'First Name', fieldValue: '', deletePreserved: false},
- {fieldType:'checkbox', title:'nascar', fieldValue: '', deletePreserved: false},
- {fieldType:'checkbox', title:'hockey', fieldValue: '', deletePreserved: false}
- ],
- _id: '922f6d0f87fed8730e4e1233'
- }
- ];
-
-
- // 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
- // 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
- // account and ignores methods.
- 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));
-
- beforeEach(module('stateMock'));
-
- //Mock Users Service
- beforeEach(module(function($provide) {
- $provide.service('myForm', function($q) {
- return sampleForm;
- });
- }));
-
-
- // 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, _$state_, _$location_, _$stateParams_, _$httpBackend_, CurrentForm, Forms) {
- // Set a new global scope
- scope = $rootScope.$new();
-
- //Set CurrentForm
- CurrentForm.setForm(sampleForm);
-
- // Point global variables to injected services
- $stateParams = _$stateParams_;
- $httpBackend = _$httpBackend_;
- $location = _$location_;
- $state = _$state_;
-
- $httpBackend.whenGET(/\.html$/).respond('');
- $httpBackend.whenGET('/users/me/').respond('');
-
- // Initialize the Forms controller.
- createListFormsController = function(){
- return $controller('ListFormsController', { $scope: scope });
- };
- }));
-
- it('$scope.findAll() should query all User\'s Forms', inject(function(Forms) {
-
- var controller = createListFormsController();
-
- // Set GET response
- $httpBackend.expectGET(/^(\/forms)$/).respond(200, sampleFormList);
-
- // Run controller functionality
- scope.findAll();
- $httpBackend.flush();
-
- // Test scope value
- expect( scope.myforms ).toEqualData(sampleFormList);
- }));
-
- it('$scope.duplicateForm() should duplicate a Form', inject(function(Forms) {
-
- var dupSampleForm = sampleFormList[2],
- dupSampleForm_index = 3,
- newSampleFormList = _.clone(sampleFormList);
- dupSampleForm._id = 'a02df75b44c1d26b6a5e05b8';
- newSampleFormList.splice(3, 0, dupSampleForm);
-
- var controller = createListFormsController();
-
- // Set GET response
- $httpBackend.expectGET(/^(\/forms)$/).respond(200, sampleFormList);
- // Run controller functionality
- scope.findAll();
- $httpBackend.flush();
-
- // Set GET response
- $httpBackend.expect('POST', '/forms').respond(200, dupSampleForm);
- // Run controller functionality
- scope.duplicateForm(2);
- $httpBackend.flush();
-
- // Test scope value
- expect( scope.myforms.length ).toEqual(newSampleFormList.length);
- for(var i=0; i');
- $compile(el)(tmp_scope);
- $rootScope.$digest();
-
- // Point global variables to injected services
- $httpBackend = _$httpBackend_;
-
- // $httpBackend.whenGET(/.+\.html$/).respond('');
- $httpBackend.whenGET('/users/me/').respond('');
-
- //Grab controller instance
- controller = el.controller();
-
- //Grab scope. Depends on type of scope.
- //See angular.element documentation.
- scope = el.isolateScope() || el.scope();
-
- }));
-
- it('$scope.uploadPDF() should upload a pdf file', function() {
- // expect(scope.isInitialized).toBeDefined()
- // expect(scope.log).toEqual('');
-
- expect(scope.pdfLoading).toBe(false);
-
- //Set POST response
- $httpBackend.when('POST', '/upload/pdf').respond(pdfObj);
-
- var files = [{}];
- scope.uploadPDF(files);
-
- $httpBackend.flush();
- expect(scope.myform.pdf).toEqualData(pdfObj);
- });
-
- it('$scope.removePDF() should removed uploaded pdf file', function() {
- // expect(scope.isInitialized).toBeDefined()
- // expect(scope.log).toEqual('');
-
- scope.myform.pdf = pdfObj;
- scope.myform.isGenerated = true;
- scope.myform.autofillPDFs = true;
-
- scope.removePDF();
-
- expect(scope.myform.pdf).toEqual(null);
- expect(scope.myform.isGenerated).toBe(false);
- expect(scope.myform.autofillPDFs).toBe(false);
- });
- });
-}());
-
-'use strict';
-
-(function() {
- // Forms Controller Spec
- describe('EditSubmissions Directive-Controller Tests', function() {
- // Initialize global variables
- var el, scope, controller, $httpBackend;
-
- var sampleUser = {
- firstName: 'Full',
- lastName: 'Name',
- email: 'test@test.com',
- username: 'test@test.com',
- password: 'password',
- provider: 'local',
- roles: ['user'],
- _id: 'ed873933b1f1dea0ce12fab9'
- };
-
- var pdfObj = {
- fieldname:'file',
- originalname:'test.pdf',
- name:'1440112660375.pdf',
- encoding:'7bit',
- mimetype:'application/pdf',
- path:'uploads/tmp/test@test.com/1440112660375.pdf',
- extension:'pdf',
- size:56223,
- truncated:false,
- buffer:null
- };
-
- var sampleForm = {
- title: 'Form Title',
- admin: 'ed873933b1f1dea0ce12fab9',
- language: 'english',
- form_fields: [
- {fieldType:'textfield', title:'First Name', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false, _id: 'ed873933b0ce121f1deafab9'},
- {fieldType:'checkbox', title:'nascar', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false, _id: 'ed83b0ce121f17393deafab9'},
- {fieldType:'checkbox', title:'hockey', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false, _id: 'ed8317393deab0ce121ffab9'}
- ],
- pdf: {},
- pdfFieldMap: {},
- startPage: {
- showStart: false
- },
- hideFooter: false,
- isGenerated: false,
- isLive: false,
- autofillPDFs: false,
- _id: '525a8422f6d0f87f0e407a33'
- };
-
- var sampleSubmission = {
- form_fields: [
- {fieldType:'textfield', title:'First Name', fieldValue: 'John Smith', deletePreserved: false},
- {fieldType:'checkbox', title:'nascar', fieldValue: 1, deletePreserved: false},
- {fieldType:'checkbox', title:'hockey', fieldValue: 0, deletePreserved: false}
- ],
- admin: sampleUser,
- form: sampleForm,
- timeElapsed: 17.55
- };
-
- var sampleSubmissions = [{
- form_fields: [
- {fieldType:'textfield', title:'First Name', fieldValue: 'The Terminator', deletePreserved: false},
- {fieldType:'checkbox', title:'nascar', fieldValue: 0, deletePreserved: false},
- {fieldType:'checkbox', title:'hockey', fieldValue: 1, deletePreserved: false}
- ],
- admin: sampleUser,
- form: sampleForm,
- timeElapsed: 10.33
- },
- {
- form_fields: [
- {fieldType:'textfield', title:'First Name', fieldValue: 'John Smith', deletePreserved: false},
- {fieldType:'checkbox', title:'nascar', fieldValue: 1, deletePreserved: false},
- {fieldType:'checkbox', title:'hockey', fieldValue: 0, deletePreserved: false}
- ],
- admin: sampleUser,
- form: sampleForm,
- timeElapsed: 2.33
- },
- {
- form_fields: [
- {fieldType:'textfield', title:'First Name', fieldValue: 'Jane Doe', deletePreserved: false},
- {fieldType:'checkbox', title:'nascar', fieldValue: 1, deletePreserved: false},
- {fieldType:'checkbox', title:'hockey', fieldValue: 1, deletePreserved: false}
- ],
- admin: sampleUser,
- form: sampleForm,
- timeElapsed: 11.11
- }];
-
- // 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
- // 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
- // account and ignores methods.
- 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));
- beforeEach(module('module-templates'));
- beforeEach(module('stateMock'));
-
- beforeEach(inject(function($compile, $controller, $rootScope, _$httpBackend_) {
-
- // Point global variables to injected services
- $httpBackend = _$httpBackend_;
-
- $httpBackend.whenGET('/users/me/').respond('');
- $httpBackend.whenGET(/^(\/forms\/)([0-9a-fA-F]{24})(\/submissions)$/).respond(200, sampleSubmissions);
-
- //Instantiate directive.
- var tmp_scope = $rootScope.$new();
- tmp_scope.myform = sampleForm;
- tmp_scope.user = sampleUser;
-
- //gotacha: Controller and link functions will execute.
- el = angular.element('');
- $compile(el)(tmp_scope);
- $rootScope.$digest();
-
- //Grab controller instance
- controller = el.controller();
-
- //Grab scope. Depends on type of scope.
- //See angular.element documentation.
- scope = el.isolateScope() || el.scope();
- }));
-
- it('$scope.initFormSubmissions() should fetch all relevant form submissions', function() {
- $httpBackend.expectGET(/^(\/forms\/)([0-9a-fA-F]{24})(\/submissions)$/).respond(200, sampleSubmissions);
- scope.initFormSubmissions();
- $httpBackend.flush();
- scope.$digest();
- });
-
- describe('Form Table Methods', function(){
-
- it('$scope.toggleAllCheckers should toggle all checkboxes in table', function(){
- scope.initFormSubmissions();
- $httpBackend.flush();
-
- //Run Controller Logic to Test
- scope.table.masterChecker = true;
- scope.toggleAllCheckers();
-
- for(var i=0; i');
- $compile(el)(tmp_scope);
- $rootScope.$digest();
-
- // Point global variables to injected services
- $httpBackend = _$httpBackend_;
-
- //$httpBackend.whenGET(/.+\.html$/).respond('');
- $httpBackend.whenGET('/users/me/').respond('');
-
- //Grab controller instance
- controller = el.controller();
-
- //Grab scope. Depends on type of scope.
- //See angular.element documentation.
- scope = el.isolateScope() || el.scope();
-
- }));
-
- describe('> Form Field >',function(){
-
- beforeEach(function(){
- scope.myform = _.cloneDeep(sampleForm);
- });
-
- it('$scope.addNewField() should ADD a new field to $scope.myform.form_fields', function() {
-
- //Run controller methods
- scope.addNewField(true, 'textfield');
-
- var expectedFormField = {
- title:'Short Text2',
- fieldType:'textfield',
- fieldValue: '',
- required: true,
- disabled: false,
- deletePreserved: false
- };
-
- var actualFormField = _.cloneDeep(_.last(scope.myform.form_fields));
- delete actualFormField._id;
-
- expect(scope.myform.form_fields.length).toEqual(sampleForm.form_fields.length+1);
- expect(actualFormField).toEqualData(expectedFormField);
- });
-
- it('$scope.deleteField() should DELETE a field to $scope.myform.form_fields', function() {
-
- //Run controller methods
- scope.deleteField(0);
-
- expect(scope.myform.form_fields.length).toEqual(sampleForm.form_fields.length-1);
- expect(_.first(scope.myform.form_fields)).toEqualData(sampleForm.form_fields[1]);
- });
-
- it('$scope.duplicateField() should DUPLICATE a field and update $scope.myform.form_fields', function() {
-
- //Run controller methods
- scope.duplicateField(0);
-
- var originalField = _.cloneDeep(scope.myform.form_fields[0]);
- originalField.title += ' copy';
-
- delete originalField._id;
- var copyField = _.cloneDeep(scope.myform.form_fields[1]);
- delete copyField._id;
-
- expect(scope.myform.form_fields.length).toEqual(sampleForm.form_fields.length+1);
- expect(originalField).toEqualData(copyField);
- });
-
- });
-
- 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();
- });
- });
- });
-}());
-// 'use strict';
-
-// (function() {
-// // Forms Controller Spec
-// describe('entryPage Directive Tests', function() {
-// // Initialize global variables
-// var scope,
-// $templateCache,
-// $httpBackend,
-// $compile;
-
-// var sampleStartPage = {
-// showStart: true,
-// introTitle: 'Welcome to Form',
-// introParagraph: 'Sample intro paragraph',
-// buttons:[
-// {
-// url: 'http://google.com',
-// action: '',
-// text: 'Google',
-// bgColor: '#ffffff',
-// color: '#000000',
-// },
-// {
-// url: 'http://facebook.com',
-// action: '',
-// text: 'Facebook',
-// bgColor: '#0000ff',
-// color: '#000000',
-// }
-// ]
-// };
-
-
-// // 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
-// // 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
-// // account and ignores methods.
-// 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));
-
-// beforeEach(inject(function($rootScope, _$compile_, _$httpBackend_) {
-// scope = $rootScope.$new();
-// $compile = _$compile_;
-
-// // Point global variables to injected services
-// $httpBackend = _$httpBackend_;
-// }));
-
-
-// it('should be able to render entryPage in html', function() {
-// scope.myStartPage = _.cloneDeep(sampleStartPage);
-// console.log(scope.myStartPage);
-// var element = angular.element('');
-// $compile(element)(scope);
-// scope.$digest();
-
-// // console.log(element.html());
-// expect(element.html()).not.toEqual('
Start Page
');
-// });
-
-// // it('exitStartPage should work for "startPage" type of entryPage', inject(function($rootScope) {
-// // scope.myPage = _.cloneDeep(sampleStartPage);
-// // var el = angular.element('');
-// // $compile(el)(scope);
-// // scope.$digest();
-
-// // $httpBackend.whenGET(/.+\.html$/).respond('');
-// // $httpBackend.whenGET('/users/me/').respond('');
-
-// // scope = el.isolateScope() || el.scope();
-
-// // scope.exitStartPage();
-// // // expect(scope.myStartPage.showStart).toBe(false);
-// // expect(el.html()).not.toEqual('
Start Page
');
-// // }));
-// });
-// }());
-'use strict';
-
-(function() {
- // Forms Controller Spec
- describe('FieldIcon Directive Tests', function() {
- // Initialize global variables
- var scope,
- FormFields,
- faClasses = {
- 'textfield': 'fa fa-pencil-square-o',
- 'dropdown': 'fa fa-th-list',
- 'date': 'fa fa-calendar',
- 'checkbox': 'fa fa-check-square-o',
- 'radio': 'fa fa-dot-circle-o',
- 'email': 'fa fa-envelope-o',
- 'textarea': 'fa fa-pencil-square',
- 'legal': 'fa fa-legal',
- 'file': 'fa fa-cloud-upload',
- 'rating': 'fa fa-star-half-o',
- 'link': 'fa fa-link',
- 'scale': 'fa fa-sliders',
- 'stripe': 'fa fa-credit-card',
- 'statement': 'fa fa-quote-left',
- 'yes_no': 'fa fa-toggle-on',
- 'number': 'fa fa-slack'
- };
-
- // Load the main application module
- beforeEach(module(ApplicationConfiguration.applicationModuleName));
-
- beforeEach(inject(function ($rootScope, _FormFields_) {
- scope = $rootScope.$new();
- FormFields = _FormFields_;
- }));
-
- it('should be able render all field-icon types', inject(function($compile) {
- var currType, currClass;
-
- for(var i=0; i')(scope);
- scope.$digest();
-
- expect(currClass).toBeDefined();
-
- expect(element.find('i')).not.toBe(null);
- expect(element.find('i').hasClass(currClass)).toBe(true);
- }
-
- }));
- });
-}());
-'use strict';
-
-(function() {
- // Forms Controller Spec
- describe('Field Directive Tests', function() {
- // Initialize global variables
- var scope,
- FormFields,
- $templateCache,
- $httpBackend,
- $compile;
-
- var sampleUser = {
- firstName: 'Full',
- lastName: 'Name',
- email: 'test@test.com',
- username: 'test@test.com',
- password: 'password',
- provider: 'local',
- roles: ['user'],
- _id: 'ed873933b1f1dea0ce12fab9',
- };
-
- var sampleFields = [
- {fieldType:'textfield', title:'First Name', fieldValue: 'AoeuName', deletePreserved: false, required: true, disabled: false},
- {fieldType:'email', title:'Email', fieldValue: 'aoeu@aoeu.com', deletePreserved: false, required: true, disabled: false},
- {fieldType:'yes_no', title:'Do you Play Hockey?', fieldValue: 'true', deletePreserved: false, required: true, disabled: false},
- {fieldType:'url', title:'Github Account', fieldValue: 'http://github.com/aoeu', deletePreserved: false, required: true, disabled: false},
- {fieldType:'textarea', title:'Bio', fieldValue: 'This is my bio.', deletePreserved: false, required: true, disabled: false},
- {fieldType:'number', title:'Phone #', fieldValue: 5325325325, deletePreserved: false, required: true, disabled: false},
- {fieldType:'legal', title:'You agree to terms and conditions', description:'By selecting \'I agree\' you are agreeing under Canadian law that you have read and accept terms and conditions outlayed below', fieldValue: '', deletePreserved: false, required: true, disabled: false},
- {fieldType:'dropdown', title:'Your Sex', fieldValue: '', fieldOptions:[ { 'option_id': 0, 'option_title': 'M', 'option_value': 'male' }, { 'option_id': 1, 'option_title': 'F', 'option_value': 'female' }], deletePreserved: false, required: true, disabled: false},
- {fieldType:'radio', title:'Your Sexual Orientation', fieldValue: '', fieldOptions:[ { 'option_id': 0, 'option_title': 'Heterosexual', 'option_value': 'hetero' }, { 'option_id': 1, 'option_title': 'Homosexual', 'option_value': 'homo' }, { 'option_id': 2, 'option_title': 'Bisexual', 'option_value': 'bi' }, { 'option_id': 3, 'option_title': 'Asexual', 'option_value': 'asex' }], deletePreserved: false, required: true, disabled: false},
- {fieldType:'rating', title:'Your Current Happiness', fieldValue: '0', deletePreserved: false, required: true, disabled: false},
- ];
-
-
- // 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
- // 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
- // account and ignores methods.
- beforeEach(function() {
- jasmine.addMatchers({
- toEqualData: function(util, customEqualityTesters) {
- return {
- compare: function(actual, expected) {
- return {
- pass: angular.equals(actual, expected)
- };
- }
- };
- }
- });
- });
-
- beforeEach(module(function ($sceProvider) {
- $sceProvider.enabled(false);
- }));
-
- // Load the main application module
- beforeEach(module(ApplicationConfiguration.applicationModuleName));
- beforeEach(module('stateMock'));
- beforeEach(module('module-templates'));
-
- beforeEach(module('ngSanitize', 'ui.select'));
-
- beforeEach(inject(function($rootScope, _FormFields_, _$compile_) {
- scope = $rootScope.$new();
- FormFields = _FormFields_;
-
- $compile = _$compile_;
- }));
-
- it('should be able to render all field types in html', inject(function($rootScope) {
- scope.fields = sampleFields;
-
- for(var i=0; i');
- $compile(element)(scope);
- scope.$digest();
-
- console.log('Actual: ');
- console.log(element.html());
-
- console.log('\nExpected: ');
-
- console.log('
'+field.title+'
');
- }
- }));
- });
-}());
-
-'use strict';
-
-(function() {
- // Forms Controller Spec
- describe('onFinishRender Directive Tests', function() {
- // Initialize global variables
- var scope,
- FormFields;
-
- // Load the main application module
- beforeEach(module(ApplicationConfiguration.applicationModuleName));
-
- beforeEach(inject(function ($rootScope, _FormFields_) {
- scope = $rootScope.$new();
- FormFields = _FormFields_;
- spyOn($rootScope, '$broadcast');
-
- }));
-
- it('should emit Custom "Finished" and "Started" events on ng-repeat', inject(function($compile, $rootScope) {
-
- scope.myfields = FormFields.types;
-
- var e = $compile('
{{item.name}}
')(scope);
- scope.$digest();
-
- //run code to test
- expect($rootScope.$broadcast).toHaveBeenCalledWith('editFormFields Started');
- expect(scope.$broadcast).toHaveBeenCalledWith('editFormFields Finished');
- }));
-
- 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;
-
- var e = $compile('
{{item.name}}
')(scope);
- scope.$digest();
-
- //run code to test
- expect($rootScope.$broadcast).toHaveBeenCalledWith('ngRepeat Started');
- expect(scope.$broadcast).toHaveBeenCalledWith('ngRepeat Finished');
- }));
-
- });
-}());
-'use strict';
-
-(function() {
- // Forms Controller Spec
- describe('SubmitForm Directive-Controller Tests', function() {
- // Initialize global variables
- var scope, controller, $httpBackend;
-
- var sampleUser = {
- firstName: 'Full',
- lastName: 'Name',
- email: 'test@test.com',
- username: 'test@test.com',
- password: 'password',
- provider: 'local',
- roles: ['user'],
- _id: 'ed873933b1f1dea0ce12fab9'
- };
-
- var pdfObj = {
- fieldname:'file',
- originalname:'test.pdf',
- name:'1440112660375.pdf',
- encoding:'7bit',
- mimetype:'application/pdf',
- path:'uploads/tmp/test@test.com/1440112660375.pdf',
- extension:'pdf',
- size:56223,
- truncated:false,
- buffer:null
- };
-
- var sampleForm = {
- title: 'Form Title',
- admin: 'ed873933b1f1dea0ce12fab9',
- language: 'english',
- form_fields: [
- {fieldType:'textfield', title:'First Name', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false, _id: 'ed873933b0ce121f1deafab9'},
- {fieldType:'checkbox', title:'nascar', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false, _id: 'ed83b0ce121f17393deafab9'},
- {fieldType:'checkbox', title:'hockey', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false, _id: 'ed8317393deab0ce121ffab9'} ],
- visible_form_fields: [
- {fieldType:'textfield', title:'First Name', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false, _id: 'ed873933b0ce121f1deafab9'},
- {fieldType:'checkbox', title:'nascar', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false, _id: 'ed83b0ce121f17393deafab9'},
- {fieldType:'checkbox', title:'hockey', fieldOptions: [], fieldValue: '', required: true, disabled: false, deletePreserved: false, _id: 'ed8317393deab0ce121ffab9'} ],
- pdf: {},
- pdfFieldMap: {},
- startPage: {
- showStart: false
- },
- hideFooter: false,
- isGenerated: false,
- isLive: false,
- autofillPDFs: false,
- _id: '525a8422f6d0f87f0e407a33'
- };
-
- var sampleSubmission = {
- form_fields: [
- {fieldType:'textfield', title:'First Name', fieldValue: 'John Smith', deletePreserved: false, _id: 'ed873933b0ce121f1deafab9'},
- {fieldType:'yes_no', title:'Do you like nascar', fieldValue: true, deletePreserved: false, _id: 'ed83b0ce121f17393deafab9'},
- {fieldType:'yes_no', title:'Do you like hockey', fieldValue: false, deletePreserved: false, _id: 'ed8317393deab0ce121ffab9'}
- ],
- admin: sampleUser,
- form: sampleForm,
- timeElapsed: 17.55
- };
-
- var sampleSubmissions = [{
- form_fields: [
- {fieldType:'textfield', title:'First Name', fieldValue: 'The Terminator', deletePreserved: false},
- {fieldType:'yes_no', title:'Do you like nascar', fieldValue: 'true', deletePreserved: false},
- {fieldType:'yes_no', title:'Do you like hockey', fieldValue: 'false', deletePreserved: false}
- ],
- admin: sampleUser,
- form: sampleForm,
- timeElapsed: 10.33
- },
- {
- form_fields: [
- {fieldType:'textfield', title:'First Name', fieldValue: 'John Smith', deletePreserved: false},
- {fieldType:'yes_no', title:'Do you like nascar', fieldValue: 'true', deletePreserved: false},
- {fieldType:'yes_no', title:'Do you like hockey', fieldValue: 'true', deletePreserved: false}
- ],
- admin: sampleUser,
- form: sampleForm,
- timeElapsed: 2.33
- },
- {
- form_fields: [
- {fieldType:'textfield', title:'First Name', fieldValue: 'Jane Doe', deletePreserved: false},
- {fieldType:'yes_no', title:'Do you like nascar', fieldValue: 'false', deletePreserved: false},
- {fieldType:'yes_no', title:'Do you like hockey', fieldValue: 'false', deletePreserved: false}
- ],
- admin: sampleUser,
- form: sampleForm,
- timeElapsed: 11.11
- }];
-
- // 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
- // 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
- // account and ignores methods.
- 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));
- beforeEach(module('module-templates'));
- beforeEach(module('stateMock'));
-
- beforeEach(inject(function($compile, $controller, $rootScope, _$httpBackend_) {
-
- // Point global variables to injected services
- $httpBackend = _$httpBackend_;
- $httpBackend.whenGET('/users/me/').respond('');
-
- //Instantiate directive.
- var tmp_scope = $rootScope.$new();
- tmp_scope.myform = sampleForm;
-
- //gotacha: Controller and link functions will execute.
- var el = angular.element('');
- $compile(el)(tmp_scope);
- tmp_scope.$digest();
- $rootScope.$digest();
-
- //Grab controller instance
- controller = el.controller();
-
- //Grab scope. Depends on type of scope.
- //See angular.element documentation.
- scope = el.isolateScope() || el.scope();
-
- console.log(scope);
- }));
-
- var Validator = (function() {
- return {
- hasMinimumFields: function(entry) {
- return !_.isEmpty(entry._id) && !_.isEmpty(entry.title);
- },
- isNewForm: function(entry) {
- return this.hasMinimumFields(entry);
- }
- };
- })();
-
-
- it('$scope.submitForm() should submit valid form', function(){
- //Initialize variables
- scope.myform.form_fields = sampleSubmissions[0].form_fields;
-
- var expectedForm = _.cloneDeep(sampleForm);
- expectedForm.form_fields = sampleSubmissions[0].form_fields;
- delete expectedForm.visible_form_fields;
-
- var data = function(data) {
- var form = angular.fromJson(data);
- var compareForm = _.cloneDeep(form);
- delete compareForm.timeElapsed;
- delete compareForm.percentageComplete;
-
- return Validator.isNewForm(form) && _.isEqual(compareForm, expectedForm);
- };
-
- //Set expected HTTP requests
- $httpBackend.expect('POST',/^(\/forms\/)([0-9a-fA-F]{24})$/, data).respond(200);
-
- //Run Controller Logic to Test
- scope.submitForm();
-
- $httpBackend.flush();
-
- setTimeout(function(){
- expect(scope.myform.submitted).toBe(true);
- expect(scope.error).toEqual('');
- }, 25);
- });
-
- it('$scope.reloadForm() should reset and reload form', function(){
- scope.submitForm();
- scope.reloadForm();
-
- expect(scope.myform.submitted).toBe(false);
- for(var i=0; i 0){
- var expectedState = this.expectedTransitions.shift();
- if(expectedState !== stateName){
- throw Error('Expected transition to state: ' + expectedState + ' but transitioned to ' + stateName );
- }
- }else{
- throw Error('No more transitions were expected! Tried to transition to '+ stateName );
- }
- console.log('Mock transition to: ' + stateName);
- var deferred = $q.defer();
- var promise = deferred.promise;
- deferred.resolve();
- return promise;
- };
-
- this.go = this.transitionTo;
- this.expectTransitionTo = function(stateName){
- this.expectedTransitions.push(stateName);
- };
-
- this.ensureAllTransitionsHappened = function(){
- if(this.expectedTransitions.length > 0){
- throw Error('Not all transitions happened!');
- }
- };
-}]);
-// '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');
-// });
-// });
-// }());
-// 'use strict';
-
-// (function() {
-// // Forms Controller Spec
-// describe('Authentication Controller Tests', function() {
-// // Initialize global variables
-// var AuthenticationController,
-// scope,
-// $httpBackend,
-// $stateParams,
-// $location,
-// $state;
-
-// var sampleUser = {
-// firstName: 'Full',
-// lastName: 'Name',
-// email: 'test@test.com',
-// username: 'test@test.com',
-// password: 'password',
-// provider: 'local',
-// roles: ['user'],
-// _id: 'ed873933b1f1dea0ce12fab9'
-// };
-
-// var sampleForm = {
-// title: 'Form Title',
-// admin: 'ed873933b1f1dea0ce12fab9',
-// language: 'english',
-// form_fields: [
-// {fieldType:'textfield', title:'First Name', fieldValue: '', deletePreserved: false},
-// {fieldType:'checkbox', title:'nascar', fieldValue: '', deletePreserved: false},
-// {fieldType:'checkbox', title:'hockey', fieldValue: '', deletePreserved: false}
-// ],
-// _id: '525a8422f6d0f87f0e407a33'
-// };
-
-// var expectedForm = {
-// title: 'Form Title',
-// admin: 'ed873933b1f1dea0ce12fab9',
-// language: 'english',
-// form_fields: [
-// {fieldType:'textfield', title:'First Name', fieldValue: '', deletePreserved: false},
-// {fieldType:'checkbox', title:'nascar', fieldValue: '', deletePreserved: false},
-// {fieldType:'checkbox', title:'hockey', fieldValue: '', deletePreserved: false}
-// ],
-// visible_form_fields: [
-// {fieldType:'textfield', title:'First Name', fieldValue: '', deletePreserved: false},
-// {fieldType:'checkbox', title:'nascar', fieldValue: '', deletePreserved: false},
-// {fieldType:'checkbox', title:'hockey', fieldValue: '', deletePreserved: false}
-// ],
-// _id: '525a8422f6d0f87f0e407a33'
-// };
-
- // var sampleCredentials = {
- // username: sampleUser.username,
- // password: sampleUser.password,
- // };
-
-
-
-// // 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
-// // 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
-// // account and ignores methods.
-// 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));
-
-// beforeEach(module('stateMock'));
-
-// // Mock Users Service
-// beforeEach(module(function($provide) {
-// $provide.service('User', function($q) {
-// return {
-// getCurrent: function() {
-// var deferred = $q.defer();
-// deferred.resolve( JSON.stringify(sampleUser) );
-// return deferred.promise;
-// },
-// login: function(credentials) {
-// var deferred = $q.defer();
-// if( credentials.password === sampleUser.password && credentials.username === sampleUser.username){
-// deferred.resolve( JSON.stringify(sampleUser) );
-// }else {
-// deferred.resolve('Error: User could not be loggedin');
-// }
-
-// return deferred.promise;
-// },
-// logout: function() {
-// var deferred = $q.defer();
-// deferred.resolve(null);
-// return deferred.promise;
-// },
-// signup: function(credentials) {
-// var deferred = $q.defer();
-// if( credentials.password === sampleUser.password && credentials.username === sampleUser.username){
-// deferred.resolve( JSON.stringify(sampleUser) );
-// }else {
-// deferred.resolve('Error: User could not be signed up');
-// }
-
-// return deferred.promise;
-// }
-// };
-// });
-// }));
-
-// // Mock Authentication Service
-// beforeEach(module(function($provide) {
-// $provide.service('Auth', function() {
-// return {
-// ensureHasCurrentUser: function() {
-// return sampleUser;
-// },
-// isAuthenticated: function() {
-// return true;
-// },
-// getUserState: function() {
-// return true;
-// }
-// };
-// });
-// }));
-
-// // 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, _$state_, _$location_, _$stateParams_, _$httpBackend_, CurrentForm, Forms) {
-// // Set a new global scope
-// scope = $rootScope.$new();
-// scope.abc = 'hello';
-
-// // Point global variables to injected services
-// $stateParams = _$stateParams_;
-// $httpBackend = _$httpBackend_;
-// $location = _$location_;
-// $state = _$state_;
-
-// // $httpBackend.whenGET(/\.html$/).respond('');
-// $httpBackend.whenGET('/users/me/').respond('');
-
-// // Initialize the Forms controller.
-// AuthenticationController = $controller('AuthenticationController', { $scope: scope });
-// }));
-
-// it('$scope.signin should sigin in user with valid credentials', inject(function(Auth) {
-
-// //Set $state transition
-// // $state.expectTransitionTo('listForms');
-// //Set POST response
-// // $httpBackend.expect('POST', '/auth/signin', sampleCredentials).respond(200, sampleUser);
-
-// scope.abc = 'sampleCredentials';
-// //Run Controller Logic to Test
-// scope.signin();
-
-// // $httpBackend.flush();
-
-// // Test scope value
-// // expect(Auth.ensureHasCurrentUser()).toEqualData(sampleUser);
-// }));
-
-
-// });
-// }());
-'use strict';
-
-(function() {
- // Forms Controller Spec
- describe('Auth Service Tests', function() {
- // Initialize global variables
- var Auth;
-
- var sampleUser = {
- firstName: 'Full',
- lastName: 'Name',
- email: 'test@test.com',
- username: 'test@test.com',
- password: 'password',
- provider: 'local',
- roles: ['user'],
- _id: 'ed873933b1f1dea0ce12fab9'
- };
-
-
- // 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
- // 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
- // account and ignores methods.
- 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(_Auth_) {
- Auth = _Auth_;
- }));
-
- it('Auth.login() should save user in Auth.currentUser', function() {
- //Run Service Logic to Test
- Auth.login(sampleUser);
- expect(Auth.currentUser).toEqualData(sampleUser);
- });
-
- it('Auth.logout() should remove saved user', inject(function($window) {
- //Run Service Logic to Test
- Auth.logout();
-
- expect($window.user).toEqual(null);
- expect(Auth.currentUser).toEqual(null);
- expect(Auth.isAuthenticated()).toBe(false);
- expect(Auth.getUserState().isLoggedIn).toBe(false);
- }));
-
- it('Auth.getUserState() should fetch current user state', function() {
-
- //Run Service Logic to Test
- Auth.login(sampleUser);
- var currUserState = Auth.getUserState();
-
- expect(currUserState.isLoggedIn).toBe(true);
-
- //Run Service Logic to Test
- Auth.logout();
- currUserState = Auth.getUserState();
-
- expect(currUserState.isLoggedIn).toBe(false);
- });
-
- it('Auth.ensureHasCurrentUser() should fetch most current user if it exists in $window, currentUser or fetch it from /users/me', function() {
- Auth.login(sampleUser);
-
- //Run Service Logic to Test
- var currUser = Auth.ensureHasCurrentUser(sampleUser);
-
- expect(currUser).not.toEqual(null);
- expect(currUser).toEqualData(sampleUser);
- });
-
- });
-}());
-'use strict';
-
-(function() {
- // Forms Controller Spec
- describe('Authorizer Service Tests', function() {
- // Initialize global variables
- var Authorizer;
-
- var sampleUser = {
- firstName: 'Full',
- lastName: 'Name',
- email: 'test@test.com',
- username: 'test@test.com',
- password: 'password',
- provider: 'local',
- roles: ['user'],
- _id: 'ed873933b1f1dea0ce12fab9'
- };
-
-
- // 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
- // 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
- // account and ignores methods.
- 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(_Authorizer_) {
- Authorizer = _Authorizer_;
- }));
-
- it('Authorizer.canAccess() should return expected values for \'admin\' and \'user\' accounts', function() {
- var sampleAdminUser = _.cloneDeep(sampleUser);
- sampleAdminUser.roles.push('admin');
-
- //Run Service Logic to Test
- var authenticatorUser = new Authorizer(sampleUser);
- var authenticatorAdmin = new Authorizer(sampleAdminUser);
-
- expect(authenticatorUser.canAccess('editForm')).toBe(true);
- expect(authenticatorUser.canAccess('editAdminSettings')).toBe(false);
- expect(authenticatorUser.canAccess('viewAdminSettings')).toBe(false);
-
- expect(authenticatorAdmin.canAccess('editForm')).toBe(true);
- expect(authenticatorAdmin.canAccess('editAdminSettings')).toBe(true);
- expect(authenticatorAdmin.canAccess('viewAdminSettings')).toBe(true);
- });
-
- });
-}());
-'use strict';
-
-(function() {
- // Forms Controller Spec
- describe('User Service Tests', function() {
- // Initialize global variables
- var User,
- $httpBackend;
-
- var sampleUser = {
- firstName: 'Full',
- lastName: 'Name',
- email: 'test@test.com',
- username: 'test@test.com',
- password: 'password',
- provider: 'local',
- roles: ['user'],
- _id: 'ed873933b1f1dea0ce12fab9'
- };
-
- var sampleVerifyToken = 'WyuAIchArQnstkq5erx0kiTcTbBbgixYeBGtThFmRpcAJNQ2';
- var sampleForgotToken = 'c2e8f74455cdccc454dfef941ff315fa4f7b1f0a';
- var sampleCredentials = {
- username: sampleUser.username,
- password: sampleUser.password,
- };
-
- var samplePasswordDetails = {
- newPassword: sampleUser.password,
- verifyPassword: sampleUser.password,
- };
-
- // 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
- // 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
- // account and ignores methods.
- 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));
-
- beforeEach(module('stateMock'));
-
- // 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(_$httpBackend_, _User_) {
- // Point global variables to injected services
- $httpBackend = _$httpBackend_;
- User = _User_;
- }));
-
- it('User.login() should send a POST request to /auth/signin', function() {
-
- //Set POST response
- $httpBackend.expect('POST', '/auth/signin', sampleCredentials).respond(200, sampleUser);
-
- //Run Service Logic to Test
- User.login(sampleCredentials);
-
- $httpBackend.flush();
- });
-
- it('User.logout() should logout user with /auth/signout', function() {
-
- //Set POST response
- $httpBackend.expect('GET', '/auth/signout').respond(200);
-
- //Run Service Logic to Test
- User.logout();
-
- $httpBackend.flush();
- });
-
- it('User.getCurrent() should fetch user from /users/me', function() {
-
- //Set POST response
- $httpBackend.expect('GET', '/users/me').respond(200, sampleUser);
-
- //Run Service Logic to Test
- User.getCurrent();
-
- $httpBackend.flush();
- });
-
-
- it('User.signup() should signup user with /auth/signup', function() {
-
- //Set POST response
- $httpBackend.expect('POST', '/auth/signup', sampleCredentials).respond(200);
-
- //Run Service Logic to Test
- User.signup(sampleCredentials);
-
- $httpBackend.flush();
- });
-
- it('User.resendVerifyEmail() should send POST request to /auth/verify', function() {
-
- //Set POST response
- $httpBackend.expect('POST', '/auth/verify', {email: sampleUser.email}).respond(200);
-
- //Run Service Logic to Test
- User.resendVerifyEmail(sampleUser.email);
-
- $httpBackend.flush();
- });
-
- it('User.validateVerifyToken() should send GET request to /auth/verify/:token', function() {
-
- //Set POST response
- $httpBackend.expect('GET', '/auth/verify/'+sampleVerifyToken).respond(200);
-
- //Run Service Logic to Test
- expect(function(){ User.validateVerifyToken(sampleVerifyToken); }).not.toThrow();
-
- $httpBackend.flush();
- });
-
- it('User.resetPassword() should send GET request to /auth/forgot/:token', function() {
-
- //Set POST response
- $httpBackend.expect('GET', '/auth/password/'+sampleForgotToken).respond(200);
-
- //Run Service Logic to Test
- User.resetPassword(samplePasswordDetails, sampleForgotToken);
-
- $httpBackend.flush();
- });
-
- it('User.askForPasswordReset() should send POST request to /auth/forgot', function() {
-
- //Set POST response
- $httpBackend.expect('POST', '/auth/forgot', sampleCredentials).respond(200, sampleUser);
-
- //Run Service Logic to Test
- User.askForPasswordReset(sampleCredentials);
-
- $httpBackend.flush();
- });
-
-
- });
-}());
\ No newline at end of file
diff --git a/public/dist/application.min.js b/public/dist/application.min.js
index a9f1a895..bb36d851 100644
--- a/public/dist/application.min.js
+++ b/public/dist/application.min.js
@@ -1,8 +1,4 @@
-function removeDateFieldsFunc(o){function eachObject(v,k){"lastModified"!==k&&"created"!==k||delete clone[k]}for(var clone=_.clone(o),i=0;i
Resend your verification emailSignin to your account')}]);var ApplicationConfiguration=function(){var applicationModuleName="NodeForm",applicationModuleVendorDependencies=["duScroll","ui.select","cgBusy","ngSanitize","vButton","ngResource","NodeForm.templates","ui.router","ui.bootstrap","ui.utils"],registerModule=function(moduleName,dependencies){angular.module(moduleName,dependencies||[]),angular.module(applicationModuleName).requires.push(moduleName)};return{applicationModuleName:applicationModuleName,applicationModuleVendorDependencies:applicationModuleVendorDependencies,registerModule:registerModule}}();angular.module(ApplicationConfiguration.applicationModuleName,ApplicationConfiguration.applicationModuleVendorDependencies),angular.module(ApplicationConfiguration.applicationModuleName).config(["$locationProvider",function($locationProvider){$locationProvider.hashPrefix("!")}]),angular.module(ApplicationConfiguration.applicationModuleName).constant("APP_PERMISSIONS",{viewAdminSettings:"viewAdminSettings",editAdminSettings:"editAdminSettings",editForm:"editForm",viewPrivateForm:"viewPrivateForm"}),angular.module(ApplicationConfiguration.applicationModuleName).constant("USER_ROLES",{admin:"admin",normal:"user",superuser:"superuser"}),angular.module(ApplicationConfiguration.applicationModuleName).constant("FORM_URL","/forms/:formId"),angular.module(ApplicationConfiguration.applicationModuleName).run(["$rootScope","Auth","$state","$stateParams",function($rootScope,Auth,$state,$stateParams){$rootScope.$state=$state,$rootScope.$stateParams=$stateParams,$rootScope.$on("$stateChangeSuccess",function(event,toState,toParams,fromState){$state.previous=fromState;var statesToIgnore=["home","signin","resendVerifyEmail","verify","signup","signup-success","forgot","reset-invalid","reset","reset-success"];statesToIgnore.indexOf(toState.name)>0?Auth.isAuthenticated()&&(event.preventDefault(),$state.go("listForms")):"access_denied"===toState.name||Auth.isAuthenticated()||"submitForm"===toState.name||(console.log("go to signup"),event.preventDefault(),$state.go("listForms"))})}]),angular.module(ApplicationConfiguration.applicationModuleName).run(["$rootScope","Auth","User","Authorizer","$state","$stateParams",function($rootScope,Auth,User,Authorizer,$state,$stateParams){$rootScope.$on("$stateChangeStart",function(event,next){var authenticator,permissions,user;permissions=next&&next.data&&next.data.permissions?next.data.permissions:null,Auth.ensureHasCurrentUser(User),user=Auth.currentUser,user&&(authenticator=new Authorizer(user),null!=permissions&&(authenticator.canAccess(permissions)||(event.preventDefault(),$state.go("access_denied"))))})}]),angular.element(document).ready(function(){"#_=_"===window.location.hash&&(window.location.hash="#!"),angular.bootstrap(document,[ApplicationConfiguration.applicationModuleName])}),angular.module("NodeForm.templates",[]).run(["$templateCache",function($templateCache){"use strict";$templateCache.put("../public/modules/core/views/header.client.view.html",'
Resend your verification emailSignin to your account')}]),ApplicationConfiguration.registerModule("core",["users"]),ApplicationConfiguration.registerModule("forms",["ngFileUpload","ui.router.tabs","ui.date","ui.sortable","angular-input-stars","users","pascalprecht.translate"]),ApplicationConfiguration.registerModule("users"),angular.module("core").config(["$stateProvider","$urlRouterProvider",function($stateProvider,$urlRouterProvider,Authorization){$urlRouterProvider.otherwise("/forms")}]),angular.module("core").controller("HeaderController",["$rootScope","$scope","Menus","$state","Auth","User","$window",function($rootScope,$scope,Menus,$state,Auth,User,$window){$rootScope.signupDisabled=$window.signupDisabled,$scope.user=$rootScope.user=Auth.ensureHasCurrentUser(User),$scope.authentication=$rootScope.authentication=Auth,$rootScope.languages=$scope.languages=["english","french","spanish"],$scope.isCollapsed=!1,$rootScope.hideNav=!1,$scope.menu=Menus.getMenu("topbar"),$scope.signout=function(){var promise=User.logout();promise.then(function(){Auth.logout(),Auth.ensureHasCurrentUser(User),$scope.user=$rootScope.user=null,$state.go("listForms")},function(reason){console.log("Logout Failed: "+reason)})},$scope.toggleCollapsibleMenu=function(){$scope.isCollapsed=!$scope.isCollapsed},$scope.$on("$stateChangeSuccess",function(event,toState,toParams,fromState,fromParams){$scope.isCollapsed=!1,$rootScope.hideNav=!1,angular.isDefined(toState.data)&&angular.isDefined(toState.data.hideNav)&&($rootScope.hideNav=toState.data.hideNav)})}]),angular.module("core").controller("HomeController",["$rootScope","$scope","User","$state",function($rootScope,$scope,User,$state){$scope=$rootScope}]),angular.module("core").service("Menus",[function(){this.defaultRoles=["*"],this.menus={};var shouldRender=function(user){if(!user)return this.isPublic;if(~this.roles.indexOf("*"))return!0;for(var userRoleIndex in user.roles)for(var roleIndex in this.roles)if(console.log(this.roles[roleIndex]),console.log(this.roles[roleIndex]===user.roles[userRoleIndex]),this.roles[roleIndex]===user.roles[userRoleIndex])return!0;return!1};this.validateMenuExistance=function(menuId){if(menuId&&menuId.length){if(this.menus[menuId])return!0;throw new Error("Menu does not exists")}throw new Error("MenuId was not provided")},this.getMenu=function(menuId){return this.validateMenuExistance(menuId),this.menus[menuId]},this.addMenu=function(menuId,isPublic,roles){return this.menus[menuId]={isPublic:isPublic||!1,roles:roles||this.defaultRoles,items:[],shouldRender:shouldRender},this.menus[menuId]},this.removeMenu=function(menuId){this.validateMenuExistance(menuId),delete this.menus[menuId]},this.addMenuItem=function(menuId,menuItemTitle,menuItemURL,menuItemType,menuItemUIRoute,isPublic,roles,position){return this.validateMenuExistance(menuId),this.menus[menuId].items.push({title:menuItemTitle,link:menuItemURL,menuItemType:menuItemType||"item",menuItemClass:menuItemType,uiRoute:menuItemUIRoute||"/"+menuItemURL,isPublic:null===isPublic||"undefined"==typeof isPublic?this.menus[menuId].isPublic:isPublic,roles:null===roles||"undefined"==typeof roles?this.menus[menuId].roles:roles,position:position||0,items:[],shouldRender:shouldRender}),this.menus[menuId]},this.addSubMenuItem=function(menuId,rootMenuItemURL,menuItemTitle,menuItemURL,menuItemUIRoute,isPublic,roles,position){this.validateMenuExistance(menuId);for(var itemIndex in this.menus[menuId].items)this.menus[menuId].items[itemIndex].link===rootMenuItemURL&&this.menus[menuId].items[itemIndex].items.push({title:menuItemTitle,link:menuItemURL,uiRoute:menuItemUIRoute||"/"+menuItemURL,isPublic:null===isPublic||"undefined"==typeof isPublic?this.menus[menuId].items[itemIndex].isPublic:isPublic,roles:null===roles||"undefined"==typeof roles?this.menus[menuId].items[itemIndex].roles:roles,position:position||0,shouldRender:shouldRender});return this.menus[menuId]},this.removeMenuItem=function(menuId,menuItemURL){this.validateMenuExistance(menuId);for(var itemIndex in this.menus[menuId].items)this.menus[menuId].items[itemIndex].link===menuItemURL&&this.menus[menuId].items.splice(itemIndex,1);return this.menus[menuId]},this.removeSubMenuItem=function(menuId,submenuItemURL){this.validateMenuExistance(menuId);for(var itemIndex in this.menus[menuId].items)for(var subitemIndex in this.menus[menuId].items[itemIndex].items)this.menus[menuId].items[itemIndex].items[subitemIndex].link===submenuItemURL&&this.menus[menuId].items[itemIndex].items.splice(subitemIndex,1);return this.menus[menuId]},this.addMenu("topbar",!1,["*"]),this.addMenu("bottombar",!1,["*"])}]),function(){"use strict";function Socket($timeout,$window){function connect(url){service.socket=io(url,{transports:["websocket","polling"]})}function emit(eventName,data){service.socket&&service.socket.emit(eventName,data)}function on(eventName,callback){service.socket&&service.socket.on(eventName,function(data){$timeout(function(){callback(data)})})}function removeListener(eventName){service.socket&&service.socket.removeListener(eventName)}var service={connect:connect,emit:emit,on:on,removeListener:removeListener,socket:null};return connect(window.location.protocol+"//"+window.location.hostname+":"+$window.socketPort),service}angular.module("core").factory("Socket",Socket),Socket.$inject=["$timeout","$window"]}(),module.exports=function(grunt){require("jit-grunt")(grunt),grunt.initConfig({ngAnnotate:{production:{files:{"dist/form.js":["config/**/*.js","controllers/**/*.js","directives/**/*.js","services/**/*.js","dist/template.js"]}}},html2js:{options:{base:"",module:"NodeForm.templates",singleModule:!0,rename:function(moduleName){return"modules/forms/base/"+moduleName}},form:{src:["views/**/*.html"],dest:"dist/template.js"}},cssmin:{combine:{files:{"dist/form.css":"css/**/*.css"}}}}),grunt.option("force",!0),grunt.registerTask("default",["html2js:form","ngAnnotate","cssmin"])},angular.module("forms").run(["Menus",function(Menus){Menus.addMenuItem("topbar","My Forms","forms","","/forms",!1)}]).filter("formValidity",function(){return function(formObj){if(formObj&&formObj.form_fields&&formObj.visible_form_fields){var formKeys=Object.keys(formObj),fields=(formKeys.filter(function(key){return"$"!==key[0]}),formObj.form_fields),valid_count=fields.filter(function(field){return"object"==typeof field&&"statement"!==field.fieldType&&"rating"!==field.fieldType?!!field.fieldValue:void 0}).length;return valid_count-(formObj.form_fields.length-formObj.visible_form_fields.length)}return 0}}).config(["$provide",function($provide){$provide.decorator("accordionDirective",["$delegate",function($delegate){var directive=$delegate[0];return directive.replace=!0,$delegate}])}]),angular.module("forms").config(["$stateProvider",function($stateProvider){$stateProvider.state("listForms",{url:"/forms",templateUrl:"modules/forms/admin/views/list-forms.client.view.html"}).state("submitForm",{url:"/forms/:formId",templateUrl:"modules/forms/base/views/submit-form.client.view.html",data:{hideNav:!0},resolve:{Forms:"Forms",myForm:["Forms","$stateParams",function(Forms,$stateParams){return Forms.get({formId:$stateParams.formId}).$promise}]},controller:"SubmitFormController",controllerAs:"ctrl"}).state("viewForm",{url:"/forms/:formId/admin",templateUrl:"modules/forms/admin/views/admin-form.client.view.html",data:{permissions:["editForm"]},resolve:{Forms:"Forms",myForm:["Forms","$stateParams",function(Forms,$stateParams){return Forms.get({formId:$stateParams.formId}).$promise}]},controller:"AdminFormController"}).state("viewForm.configure",{url:"/configure",templateUrl:"modules/forms/admin/views/adminTabs/configure.html"}).state("viewForm.design",{url:"/design",templateUrl:"modules/forms/admin/views/adminTabs/design.html"}).state("viewForm.analyze",{url:"/analyze",templateUrl:"modules/forms/admin/views/adminTabs/analyze.html"}).state("viewForm.create",{url:"/create",templateUrl:"modules/forms/admin/views/adminTabs/create.html"})}]),function(){"use strict";function SendVisitorData(Socket,$state){function send(form,lastActiveIndex,timeElapsed){var visitorData={referrer:document.referrer,isSubmitted:form.submitted,formId:form._id,lastActiveField:form.form_fields[lastActiveIndex]._id,timeElapsed:timeElapsed};Socket.emit("form-visitor-data",visitorData)}function init(){Socket.socket||Socket.connect()}var service={send:send};return init(),service}angular.module("forms").factory("SendVisitorData",SendVisitorData),SendVisitorData.$inject=["Socket","$state"]}(),angular.module("forms").directive("keyToOption",function(){return{restrict:"A",scope:{field:"="},link:function($scope,$element,$attrs,$select){$element.bind("keydown keypress",function(event){var keyCode=event.which||event.keyCode,index=parseInt(String.fromCharCode(keyCode))-1;index<$scope.field.fieldOptions.length&&(event.preventDefault(),$scope.$apply(function(){$scope.field.fieldValue=$scope.field.fieldOptions[index].option_value}))})}}}),angular.module("forms").directive("keyToTruthy",["$rootScope",function($rootScope){return{restrict:"A",scope:{field:"="},link:function($scope,$element,$attrs){$element.bind("keydown keypress",function(event){var keyCode=event.which||event.keyCode,truthyKeyCode=$attrs.keyCharTruthy.charCodeAt(0)-32,falseyKeyCode=$attrs.keyCharFalsey.charCodeAt(0)-32;keyCode===truthyKeyCode?(event.preventDefault(),$scope.$apply(function(){$scope.field.fieldValue="true"})):keyCode===falseyKeyCode&&(event.preventDefault(),$scope.$apply(function(){$scope.field.fieldValue="false"}))})}}}]),angular.module("users").config(["$httpProvider",function($httpProvider){$httpProvider.interceptors.push(["$q","$location",function($q,$location){return{responseError:function(response){return"/users/me"!==$location.path()&&response.config&&"/users/me"!==response.config.url&&(console.log("intercepted rejection of ",response.config.url,response.status),401===response.status?(console.log($location.path()),$location.nextAfterLogin=$location.path(),$location.path("/signin")):403===response.status&&$location.path("/access_denied")),$q.reject(response)}}}])}]),angular.module("users").config(["$stateProvider",function($stateProvider){var checkLoggedin=function($q,$timeout,$state,User,Auth){var deferred=$q.defer();return Auth.currentUser&&Auth.currentUser.email?$timeout(deferred.resolve):Auth.currentUser=User.getCurrent(function(){Auth.login(),$timeout(deferred.resolve())},function(){Auth.logout(),$timeout(deferred.reject()),$state.go("signin",{reload:!0})}),deferred.promise};checkLoggedin.$inject=["$q","$timeout","$state","User","Auth"];var checkSignupDisabled=function($window,$timeout,$q){var deferred=$q.defer();return $timeout($window.signupDisabled?deferred.reject():deferred.resolve()),deferred.promise};checkSignupDisabled.$inject=["$window","$timeout","$q"],$stateProvider.state("profile",{resolve:{loggedin:checkLoggedin},url:"/settings/profile",templateUrl:"modules/users/views/settings/edit-profile.client.view.html"}).state("password",{resolve:{loggedin:checkLoggedin},url:"/settings/password",templateUrl:"modules/users/views/settings/change-password.client.view.html"}).state("accounts",{resolve:{loggedin:checkLoggedin},url:"/settings/accounts",templateUrl:"modules/users/views/settings/social-accounts.client.view.html"}).state("signup",{resolve:{isDisabled:checkSignupDisabled},url:"/signup",templateUrl:"modules/users/views/authentication/signup.client.view.html"}).state("signup-success",{resolve:{isDisabled:checkSignupDisabled},url:"/signup-success",templateUrl:"modules/users/views/authentication/signup-success.client.view.html"}).state("signin",{url:"/signin",templateUrl:"modules/users/views/authentication/signin.client.view.html"}).state("access_denied",{url:"/access_denied",templateUrl:"modules/users/views/authentication/access-denied.client.view.html"}).state("verify",{resolve:{isDisabled:checkSignupDisabled},url:"/verify/:token",templateUrl:"modules/users/views/verify/verify-account.client.view.html"}).state("resendVerifyEmail",{resolve:{isDisabled:checkSignupDisabled},url:"/verify",templateUrl:"modules/users/views/verify/resend-verify-email.client.view.html"}).state("forgot",{url:"/password/forgot",templateUrl:"modules/users/views/password/forgot-password.client.view.html"}).state("reset-invalid",{url:"/password/reset/invalid",templateUrl:"modules/users/views/password/reset-password-invalid.client.view.html"}).state("reset-success",{url:"/password/reset/success",templateUrl:"modules/users/views/password/reset-password-success.client.view.html"}).state("reset",{url:"/password/reset/:token",templateUrl:"modules/users/views/password/reset-password.client.view.html"})}]),angular.module("users").controller("AuthenticationController",["$scope","$location","$state","$rootScope","User","Auth",function($scope,$location,$state,$rootScope,User,Auth){$scope=$rootScope,$scope.credentials={},$scope.error="",$scope.signin=function(){$scope.credentials.email=$scope.credentials.username,User.login($scope.credentials).then(function(response){Auth.login(response),$scope.user=$rootScope.user=Auth.ensureHasCurrentUser(User),"home"!==$state.previous.name&&"verify"!==$state.previous.name&&""!==$state.previous.name?$state.go($state.previous.name):$state.go("listForms")},function(error){$rootScope.user=Auth.ensureHasCurrentUser(User),$scope.user=$rootScope.user,$scope.error=error,console.log("loginError: "+error)})},$scope.signup=function(){console.log($scope.credentials),User.signup($scope.credentials).then(function(response){console.log("signup-success"),$state.go("signup-success")},function(error){console.log("Error: "),console.log(error),error?($scope.error=error,console.log(error)):console.log("No response received")})}}]),angular.module("users").controller("PasswordController",["$scope","$stateParams","$state","User",function($scope,$stateParams,$state,User){$scope.error="",$scope.askForPasswordReset=function(){User.askForPasswordReset($scope.credentials).then(function(response){$scope.success=response.message,$scope.credentials=null},function(error){$scope.error=error,$scope.credentials=null})},$scope.resetUserPassword=function(){$scope.success=$scope.error=null,User.resetPassword($scope.passwordDetails,$stateParams.token).then(function(response){$scope.success=response.message,$scope.passwordDetails=null,$state.go("reset-success")},function(error){$scope.error=error.message||error,$scope.passwordDetails=null})}}]),angular.module("users").controller("SettingsController",["$scope","$rootScope","$http","$state","Users",function($scope,$rootScope,$http,$state,Users){$scope.user=$rootScope.user,$scope.hasConnectedAdditionalSocialAccounts=function(provider){for(var i in $scope.user.additionalProvidersData)return!0;return!1},$scope.isConnectedSocialAccount=function(provider){return $scope.user.provider===provider||$scope.user.additionalProvidersData&&$scope.user.additionalProvidersData[provider]},$scope.removeUserSocialAccount=function(provider){$scope.success=$scope.error=null,$http["delete"]("/users/accounts",{params:{provider:provider}}).success(function(response){$scope.success=!0,$scope.user=response}).error(function(response){$scope.error=response.message})},$scope.updateUserProfile=function(isValid){if(isValid){$scope.success=$scope.error=null;var user=new Users($scope.user);user.$update(function(response){$scope.success=!0,$scope.user=response},function(response){$scope.error=response.data.message})}else $scope.submitted=!0},$scope.changeUserPassword=function(){$scope.success=$scope.error=null,$http.post("/users/password",$scope.passwordDetails).success(function(response){$scope.success=!0,$scope.passwordDetails=null}).error(function(response){$scope.error=response.message})}}]),angular.module("users").controller("VerifyController",["$scope","$state","$rootScope","User","Auth","$stateParams",function($scope,$state,$rootScope,User,Auth,$stateParams){$scope.isResetSent=!1,$scope.credentials={},$scope.error="",$scope.resendVerifyEmail=function(){User.resendVerifyEmail($scope.credentials.email).then(function(response){console.log(response),$scope.success=response.message,$scope.credentials=null,$scope.isResetSent=!0},function(error){$scope.error=error,$scope.credentials.email=null,$scope.isResetSent=!1})},$scope.validateVerifyToken=function(){$stateParams.token&&(console.log($stateParams.token),User.validateVerifyToken($stateParams.token).then(function(response){console.log("Success: "+response.message),$scope.success=response.message,$scope.isResetSent=!0,$scope.credentials.email=null},function(error){console.log("Error: "+error.message),$scope.isResetSent=!1,$scope.error=error,$scope.credentials.email=null}))}}]),angular.module("users").factory("Auth",["$window",function($window){var userState={isLoggedIn:!1},service={_currentUser:null,get currentUser(){return this._currentUser},ensureHasCurrentUser:function(User){return service._currentUser&&service._currentUser.username?service._currentUser:$window.user?(service._currentUser=$window.user,service._currentUser):void User.getCurrent().then(function(user){return service._currentUser=user,userState.isLoggedIn=!0,$window.user=service._currentUser,service._currentUser},function(response){return userState.isLoggedIn=!1,service._currentUser=null,$window.user=null,console.log("User.getCurrent() err",response),null})},isAuthenticated:function(){return!!service._currentUser},getUserState:function(){return userState},login:function(new_user){userState.isLoggedIn=!0,service._currentUser=new_user},logout:function(){$window.user=null,userState.isLoggedIn=!1,service._currentUser=null}};return service}]),angular.module("users").service("Authorizer",["APP_PERMISSIONS","USER_ROLES",function(APP_PERMISSIONS,USER_ROLES){return function(user){return{canAccess:function(permissions){var i,len,permission;for(angular.isArray(permissions)||(permissions=[permissions]),i=0,len=permissions.length;len>i;i++){if(permission=permissions[i],null===APP_PERMISSIONS[permission])throw"Bad permission value";if(!user||!user.roles)return!1;switch(permission){case APP_PERMISSIONS.viewAdminSettings:case APP_PERMISSIONS.editAdminSettings:return user.roles.indexOf(USER_ROLES.admin)>-1;case APP_PERMISSIONS.viewPrivateForm:case APP_PERMISSIONS.editForm:return user.roles.indexOf(USER_ROLES.admin)>-1||user.roles.indexOf(USER_ROLES.normal)>-1}}return!1}}}}]),angular.module("users").factory("User",["$window","$q","$timeout","$http","$state",function($window,$q,$timeout,$http,$state){var userService={getCurrent:function(){var deferred=$q.defer();return $http.get("/users/me").success(function(response){deferred.resolve(response)}).error(function(){deferred.reject("User's session has expired")}),deferred.promise},login:function(credentials){
-var deferred=$q.defer();return $http.post("/auth/signin",credentials).success(function(response){deferred.resolve(response)}).error(function(error){deferred.reject(error.message||error)}),deferred.promise},logout:function(){var deferred=$q.defer();return $http.get("/auth/signout").success(function(response){deferred.resolve(null)}).error(function(error){deferred.reject(error.message||error)}),deferred.promise},signup:function(credentials){var deferred=$q.defer();return $http.post("/auth/signup",credentials).success(function(response){deferred.resolve(response)}).error(function(error){deferred.reject(error.message||error)}),deferred.promise},resendVerifyEmail:function(_email){var deferred=$q.defer();return $http.post("/auth/verify",{email:_email}).success(function(response){deferred.resolve(response)}).error(function(error){deferred.reject(error.message||error)}),deferred.promise},validateVerifyToken:function(token){var validTokenRe=/^([A-Za-z0-9]{48})$/g;if(!validTokenRe.test(token))throw new Error("Error token: "+token+" is not a valid verification token");var deferred=$q.defer();return $http.get("/auth/verify/"+token).success(function(response){deferred.resolve(response)}).error(function(error){deferred.reject(error)}),deferred.promise},resetPassword:function(passwordDetails,token){var deferred=$q.defer();return $http.get("/auth/password/"+token,passwordDetails).success(function(response){deferred.resolve()}).error(function(error){deferred.reject(error.message||error)}),deferred.promise},askForPasswordReset:function(credentials){var deferred=$q.defer();return $http.post("/auth/forgot",credentials).success(function(response){deferred.resolve(response)}).error(function(error){deferred.reject(error.message||error)}),deferred.promise}};return userService}]),angular.module("users").factory("Users",["$resource",function($resource){return $resource("users",{},{update:{method:"PUT"}})}]),function(){describe("HeaderController",function(){var scope,HeaderController;beforeEach(module(ApplicationConfiguration.applicationModuleName)),beforeEach(inject(function($controller,$rootScope){scope=$rootScope.$new(),HeaderController=$controller("HeaderController",{$scope:scope})})),it("should expose the authentication service",function(){expect(scope.authentication).toBeTruthy()})})}(),function(){describe("HomeController",function(){var scope,HomeController;beforeEach(module(ApplicationConfiguration.applicationModuleName)),beforeEach(inject(function($controller,$rootScope){scope=$rootScope.$new(),HomeController=$controller("HomeController",{$scope:scope})}))})}(),angular.module("forms").controller("AdminFormController",["$rootScope","$scope","$stateParams","$state","Forms","CurrentForm","$http","$uibModal","myForm",function($rootScope,$scope,$stateParams,$state,Forms,CurrentForm,$http,$uibModal,myForm){$scope=$rootScope,$scope.animationsEnabled=!0,$scope.myform=myForm,$rootScope.saveInProgress=!1,CurrentForm.setForm($scope.myform),$scope.tabData=[{heading:"Create",route:"viewForm.create"},{heading:"Design",route:"viewForm.design"},{heading:"Configure",route:"viewForm.configure"},{heading:"Analyze",route:"viewForm.analyze"}],$scope.setForm=function(form){$scope.myform=form},$rootScope.resetForm=function(){$scope.myform=Forms.get({formId:$stateParams.formId})},$scope.openDeleteModal=function(){$scope.deleteModal=$uibModal.open({animation:$scope.animationsEnabled,templateUrl:"myModalContent.html",controller:"AdminFormController",resolve:{myForm:function(){return $scope.myform}}}),$scope.deleteModal.result.then(function(selectedItem){$scope.selected=selectedItem},function(){console.log("Modal dismissed at: "+new Date)})},$scope.cancelDeleteModal=function(){$scope.deleteModal&&$scope.deleteModal.dismiss("cancel")},$scope.removeCurrentForm=function(){if($scope.deleteModal&&$scope.deleteModal.opened){$scope.deleteModal.close();var form_id=$scope.myform._id;if(!form_id)throw new Error("Error - removeCurrentForm(): $scope.myform._id does not exist");$http["delete"]("/forms/"+form_id).success(function(data,status,headers){console.log("form deleted successfully"),$state.go("listForms",{},{reload:!0})}).error(function(error){console.log("ERROR: Form could not be deleted."),console.error(error)})}},$scope.update=$rootScope.update=function(updateImmediately,cb){var continueUpdate=!0;if(updateImmediately||(continueUpdate=!$rootScope.saveInProgress),continueUpdate){var err=null;updateImmediately||($rootScope.saveInProgress=!0),$scope.updatePromise=$http.put("/forms/"+$scope.myform._id,{form:$scope.myform}).then(function(response){$rootScope.myform=$scope.myform=response.data})["catch"](function(response){console.log("Error occured during form UPDATE.\n"),err=response.data})["finally"](function(){return updateImmediately||($rootScope.saveInProgress=!1),"function"==typeof cb?cb(err):void 0})}}}]),angular.module("forms").controller("ListFormsController",["$rootScope","$scope","$stateParams","$state","Forms","CurrentForm","$http",function($rootScope,$scope,$stateParams,$state,Forms,CurrentForm,$http){$scope=$rootScope,$scope.forms={},$scope.showCreateModal=!1,$scope.findAll=function(){Forms.query(function(_forms){$scope.myforms=_forms})},$scope.openCreateModal=function(){$scope.showCreateModal||($scope.showCreateModal=!0)},$scope.closeCreateModal=function(){$scope.showCreateModal&&($scope.showCreateModal=!1)},$scope.setForm=function(form){$scope.myform=form},$scope.goToWithId=function(route,id){$state.go(route,{formId:id},{reload:!0})},$scope.duplicateForm=function(form_index){var form=_.cloneDeep($scope.myforms[form_index]);delete form._id,$http.post("/forms",{form:form}).success(function(data,status,headers){$scope.myforms.splice(form_index+1,0,data)}).error(function(errorResponse){console.error(errorResponse),null===errorResponse&&($scope.error=errorResponse.data.message)})},$scope.createNewForm=function(){var form={};form.title=$scope.forms.createForm.title.$modelValue,form.language=$scope.forms.createForm.language.$modelValue,$scope.forms.createForm.$valid&&$scope.forms.createForm.$dirty&&$http.post("/forms",{form:form}).success(function(data,status,headers){console.log("new form created"),$scope.goToWithId("viewForm.create",data._id+"")}).error(function(errorResponse){console.error(errorResponse),$scope.error=errorResponse.data.message})},$scope.removeForm=function(form_index){if(form_index>=$scope.myforms.length||0>form_index)throw new Error("Error: form_index in removeForm() must be between 0 and "+$scope.myforms.length-1);$http["delete"]("/forms/"+$scope.myforms[form_index]._id).success(function(data,status,headers){console.log("form deleted successfully"),$scope.myforms.splice(form_index,1)}).error(function(error){console.log("ERROR: Form could not be deleted."),console.error(error)})}}]),_.mixin({removeDateFields:removeDateFieldsFunc}),angular.module("forms").directive("autoSaveForm",["$rootScope","$timeout",function($rootScope,$timeout){return{require:["^form"],restrict:"AE",link:function($scope,$element,$attrs,$ctrls){angular.element(document).ready(function(){var $formCtrl=$ctrls[0],savePromise=null;$rootScope.finishedRender=!1,$scope.$on("editFormFields Started",function(ngRepeatFinishedEvent){$rootScope.finishedRender=!1}),$scope.$on("editFormFields Finished",function(ngRepeatFinishedEvent){$rootScope.finishedRender=!0}),$scope.anyDirtyAndTouched=function(form){var propCount=0;for(var prop in form)if(form.hasOwnProperty(prop)&&"$"!==prop[0]&&(propCount++,form[prop].$touched&&form[prop].$dirty))return!0;return!1};var debounceSave=function(){$rootScope.saveInProgress=!0,$rootScope[$attrs.autoSaveCallback](!0,function(err){err?(console.error("Error form data NOT persisted"),console.error(err)):($formCtrl.$setPristine(),$formCtrl.$setUntouched())})};$scope.$watch(function(newValue,oldValue){$rootScope.finishedRender&&$scope.anyDirtyAndTouched($scope.editForm)&&!$rootScope.saveInProgress&&debounceSave()}),$scope.$watch($attrs.autoSaveWatch,function(newValue,oldValue){newValue=angular.copy(newValue),oldValue=angular.copy(oldValue),newValue.form_fields=_.removeDateFields(newValue.form_fields),oldValue.form_fields=_.removeDateFields(oldValue.form_fields);var changedFields=!_.isEqual(oldValue.form_fields,newValue.form_fields)||!_.isEqual(oldValue.startPage,newValue.startPage),changedFieldMap=!1;oldValue.hasOwnProperty("plugins.oscarhost.settings.fieldMap")&&(changedFieldMap=!!oldValue.plugins.oscarhost.settings.fieldMap&&!_.isEqual(oldValue.plugins.oscarhost.settings.fieldMap,newValue.plugins.oscarhost.settings.fieldMap)),(newValue||oldValue)&&oldValue&&(0===oldValue.form_fields.length&&($rootScope.finishedRender=!0),$rootScope.finishedRender&&(changedFields&&!$formCtrl.$dirty||changedFieldMap)&&!$rootScope.saveInProgress?(savePromise&&($timeout.cancel(savePromise),savePromise=null),savePromise=$timeout(function(){debounceSave()})):$rootScope.finishedRender&&$rootScope.saveInProgress&&($rootScope.saveInProgress=!1))},!0)})}}}]),angular.module("forms").directive("configureFormDirective",["$rootScope","$http","Upload","CurrentForm",function($rootScope,$http,Upload,CurrentForm){return{templateUrl:"modules/forms/admin/views/directiveViews/form/configure-form.client.view.html",restrict:"E",scope:{myform:"=",user:"=",pdfFields:"@",formFields:"@"},controller:["$scope",function($scope){console.log($scope.myform),CurrentForm.getForm().plugins?CurrentForm.getForm().plugins.oscarhost.baseUrl&&($scope.oscarhostAPI=!0):$scope.oscarhostAPI=!1,$scope.log="",$scope.pdfLoading=!1,$scope.languages=$rootScope.languages,this._current_upload=null,$scope.resetForm=$rootScope.resetForm,$scope.update=$rootScope.update,this._unbindedPdfFields=$scope.pdfFields,$scope.cancelUpload=function(){this._current_upload.abort(),$scope.pdfLoading=!1,$scope.removePDF()},$scope.removePDF=function(){$scope.myform.pdf=null,$scope.myform.isGenerated=!1,$scope.myform.autofillPDFs=!1,console.log("form.pdf: "+$scope.myform.pdf+" REMOVED")},$scope.uploadPDF=function(file){file&&(console.log(file),Upload.upload({url:"/upload/pdf",data:{user:$scope.user,file:file}}).then(function(resp){var data=resp.data;$scope.log="file "+data.originalname+" uploaded as "+data.filename+". JSON: "+JSON.stringify(data)+"\n"+$scope.log,$scope.myform.pdf=angular.fromJson(angular.toJson(data)),$scope.pdfLoading=!1,console.log($scope.log),$scope.$$phase||$scope.$digest||$scope.$apply()},function(resp){$scope.pdfLoading=!1,console.log("Error occured during upload.\n"),console.log(resp.status)},function(evt){var progressPercentage=parseInt(100*evt.loaded/evt.total,10);$scope.log="progress: "+progressPercentage+"% "+evt.config.data.file.name+"\n"+$scope.log,console.log($scope.log),$scope.pdfLoading=!0}))}}]}}]),angular.module("forms").directive("editFormDirective",["$rootScope","FormFields",function($rootScope,FormFields){return{templateUrl:"modules/forms/admin/views/directiveViews/form/edit-form.client.view.html",restrict:"E",scope:{myform:"="},controller:["$scope",function($scope){for(var field_ids=_($scope.myform.form_fields).pluck("_id"),i=0;i0){$scope.myform.plugins.oscarhost.settings.fieldMap||($scope.myform.plugins.oscarhost.settings.fieldMap={});var oscarhostFields=$scope.myform.plugins.oscarhost.settings.validFields,currentFields=_($scope.myform.plugins.oscarhost.settings.fieldMap).invert().keys().value();return $scope.myform.plugins.oscarhost.settings.fieldMap.hasOwnProperty(field_id)&&(currentFields=_(currentFields).difference($scope.myform.plugins.oscarhost.settings.fieldMap[field_id])),_(oscarhostFields).difference(currentFields).value()}return[]},$scope.dropzone={handle:".handle",containment:".dropzoneContainer",cursor:"grabbing"},$scope.addNewField=function(modifyForm,fieldType){$scope.addField.lastAddedID++;for(var fieldTitle,i=0;i<$scope.addField.types.length;i++)if($scope.addField.types[i].name===fieldType){$scope.addField.types[i].lastAddedID++,fieldTitle=$scope.addField.types[i].value+$scope.addField.types[i].lastAddedID;break}var newField={title:fieldTitle,fieldType:fieldType,fieldValue:"",required:!0,disabled:!1,deletePreserved:!1};return $scope.showAddOptions(newField)&&(newField.fieldOptions=[],newField.fieldOptions.push({option_id:Math.floor(1e5*Math.random()),option_title:"Option 0",option_value:"Option 0"})),modifyForm&&$scope.myform.form_fields.push(newField),newField},$scope.deleteField=function(field_index){var currFieldId=$scope.myform.form_fields[field_index]._id;$scope.myform.hasOwnProperty("plugins.oscarhost.baseUrl")&&delete $scope.myform.plugins.oscarhost.settings.fieldMap[currFieldId],$scope.myform.form_fields.splice(field_index,1)},$scope.duplicateField=function(field_index){var currField=_.cloneDeep($scope.myform.form_fields[field_index]);currField._id="cloned"+_.uniqueId(),currField.title+=" copy",$scope.myform.form_fields.splice(field_index+1,0,currField)},$scope.addButton=function(){var newButton={};newButton.bgColor="#ddd",newButton.color="#ffffff",newButton.text="Button",newButton._id=Math.floor(1e5*Math.random()),$scope.myform.startPage.buttons.push(newButton)},$scope.deleteButton=function(button){for(var currID,i=0;i<$scope.myform.startPage.buttons.length;i++)if(currID=$scope.myform.startPage.buttons[i]._id,console.log(currID),currID===button._id){$scope.myform.startPage.buttons.splice(i,1);break}},$scope.addOption=function(field_index){var currField=$scope.myform.form_fields[field_index];if("checkbox"===currField.fieldType||"dropdown"===currField.fieldType||"radio"===currField.fieldType){currField.fieldOptions||($scope.myform.form_fields[field_index].fieldOptions=[]);var lastOptionID=$scope.myform.form_fields[field_index].fieldOptions.length+1,newOption={option_id:Math.floor(1e5*Math.random()),option_title:"Option "+lastOptionID,option_value:"Option "+lastOptionID};$scope.myform.form_fields[field_index].fieldOptions.push(newOption)}},$scope.deleteOption=function(field_index,option){var currField=$scope.myform.form_fields[field_index];if("checkbox"===currField.fieldType||"dropdown"===currField.fieldType||"radio"===currField.fieldType)for(var i=0;i',restrict:"E",scope:{typeName:"@"},controller:["$scope",function($scope){var iconTypeMap={textfield:"fa fa-pencil-square-o",dropdown:"fa fa-th-list",date:"fa fa-calendar",checkbox:"fa fa-check-square-o",radio:"fa fa-dot-circle-o",email:"fa fa-envelope-o",textarea:"fa fa-pencil-square",legal:"fa fa-legal",file:"fa fa-cloud-upload",rating:"fa fa-star-half-o",link:"fa fa-link",scale:"fa fa-sliders",stripe:"fa fa-credit-card",statement:"fa fa-quote-left",yes_no:"fa fa-toggle-on",number:"fa fa-slack"};$scope.typeIcon=iconTypeMap[$scope.typeName]}]}});var __indexOf=[].indexOf||function(item){for(var i=0,l=this.length;l>i;i++)if(i in this&&this[i]===item)return i;return-1};angular.module("forms").directive("fieldDirective",["$http","$compile","$rootScope","$templateCache","supportedFields",function($http,$compile,$rootScope,$templateCache,supportedFields){var getTemplateUrl=function(fieldType){var type=fieldType,supported_fields=["textfield","textarea","date","dropdown","hidden","password","radio","legal","statement","rating","yes_no","number","natural"];if(__indexOf.call(supported_fields,type)>=0){var templateUrl="modules/forms/views/directiveViews/field/";templateUrl=templateUrl+type+".html"}return $templateCache.get(templateUrl)};return{template:"
{{field.title}}
",restrict:"E",scope:{field:"=",required:"&",design:"=",index:"=",forms:"="},link:function(scope,element){$rootScope.chooseDefaultOption=scope.chooseDefaultOption=function(type){"yes_no"===type?scope.field.fieldValue="true":"rating"===type?scope.field.fieldValue=0:"radio"===scope.field.fieldType?(console.log(scope.field),scope.field.fieldValue=scope.field.fieldOptions[0].option_value,console.log(scope.field.fieldValue)):"legal"===type&&(scope.field.fieldValue="true",$rootScope.nextField())},scope.setActiveField=$rootScope.setActiveField,"date"===scope.field.fieldType&&(scope.dateOptions={changeYear:!0,changeMonth:!0,altFormat:"mm/dd/yyyy",yearRange:"1900:-0",defaultDate:0});var fieldType=scope.field.fieldType;if("number"===scope.field.fieldType||"textfield"===scope.field.fieldType||"email"===scope.field.fieldType||"link"===scope.field.fieldType){switch(scope.field.fieldType){case"textfield":scope.field.input_type="text";break;case"email":scope.field.input_type="email",scope.field.placeholder="joesmith@example.com";break;case"number":scope.field.input_type="text",scope.field.validateRegex=/^-?\d+$/;break;default:scope.field.input_type="url",scope.field.placeholder="http://example.com"}fieldType="textfield"}var template=getTemplateUrl(fieldType);element.html(template).show();$compile(element.contents())(scope)}}}]),angular.module("forms").directive("onEnterKey",["$rootScope",function($rootScope){return{restrict:"A",link:function($scope,$element,$attrs){$element.bind("keydown keypress",function(event){var keyCode=event.which||event.keyCode,onEnterKeyDisabled=!1;null!==$attrs.onEnterKeyDisabled&&(onEnterKeyDisabled=$attrs.onEnterKeyDisabled),13!==keyCode||event.shiftKey||onEnterKeyDisabled||(event.preventDefault(),$rootScope.$apply(function(){$rootScope.$eval($attrs.onEnterKey)}))})}}}]).directive("onTabKey",["$rootScope",function($rootScope){return{restrict:"A",link:function($scope,$element,$attrs){$element.bind("keydown keypress",function(event){var keyCode=event.which||event.keyCode;9!==keyCode||event.shiftKey||(event.preventDefault(),$rootScope.$apply(function(){$rootScope.$eval($attrs.onTabKey)}))})}}}]).directive("onEnterOrTabKey",["$rootScope",function($rootScope){return{restrict:"A",link:function($scope,$element,$attrs){$element.bind("keydown keypress",function(event){var keyCode=event.which||event.keyCode;13!==keyCode&&9!==keyCode||event.shiftKey||(event.preventDefault(),$rootScope.$apply(function(){$rootScope.$eval($attrs.onEnterOrTabKey)}))})}}}]).directive("onTabAndShiftKey",["$rootScope",function($rootScope){return{restrict:"A",link:function($scope,$element,$attrs){$element.bind("keydown keypress",function(event){var keyCode=event.which||event.keyCode;9===keyCode&&event.shiftKey&&(event.preventDefault(),$rootScope.$apply(function(){$rootScope.$eval($attrs.onTabAndShiftKey)}))})}}}]),angular.module("forms").directive("onFinishRender",["$rootScope","$timeout",function($rootScope,$timeout){return{restrict:"A",link:function(scope,element,attrs){if(element.attr("ng-repeat")||element.attr("data-ng-repeat")){var broadcastMessage=attrs.onFinishRender||"ngRepeat";scope.$first&&!scope.$last?scope.$evalAsync(function(){$rootScope.$broadcast(broadcastMessage+" Started")}):scope.$last&&scope.$evalAsync(function(){$rootScope.$broadcast(broadcastMessage+" Finished")})}}}}]),angular.module("forms").directive("submitFormDirective",["$http","TimeCounter","$filter","$rootScope","Auth","SendVisitorData",function($http,TimeCounter,$filter,$rootScope,Auth,SendVisitorData){return{templateUrl:"modules/forms/base/views/directiveViews/form/submit-form.client.view.html",restrict:"E",scope:{myform:"="},controller:["$document","$window","$scope",function($document,$window,$scope){$scope.authentication=$rootScope.authentication,$scope.noscroll=!1,$scope.forms={};var form_fields_count=$scope.myform.visible_form_fields.filter(function(field){return"statement"!==field.fieldType&&"rating"!==field.fieldType}).length,nb_valid=$filter("formValidity")($scope.myform);$scope.translateAdvancementData={done:nb_valid,total:form_fields_count,answers_not_completed:form_fields_count-nb_valid},$scope.reloadForm=function(){$scope.myform.submitted=!1,$scope.myform.form_fields=_.chain($scope.myform.visible_form_fields).map(function(field){return field.fieldValue="",field}).value(),$scope.loading=!1,$scope.error="",$scope.selected={_id:"",index:0},$scope.setActiveField($scope.myform.visible_form_fields[0]._id,0,!1),TimeCounter.restartClock()},$window.onscroll=function(){$scope.scrollPos=document.body.scrollTop||document.documentElement.scrollTop||0;var elemBox=document.getElementsByClassName("activeField")[0].getBoundingClientRect();$scope.fieldTop=elemBox.top,$scope.fieldBottom=elemBox.bottom;var field_id,field_index;$scope.noscroll||($scope.selected.index===$scope.myform.visible_form_fields.length-1&&$scope.fieldBottom<200?(field_index=$scope.selected.index+1,field_id="submit_field",$scope.setActiveField(field_id,field_index,!1)):$scope.selected.index===$scope.myform.visible_form_fields.length?$scope.fieldTop>200&&(field_index=$scope.selected.index-1,field_id=$scope.myform.visible_form_fields[field_index]._id,$scope.setActiveField(field_id,field_index,!1)):$scope.fieldBottom<0?(field_index=$scope.selected.index+1,field_id=$scope.myform.visible_form_fields[field_index]._id,$scope.setActiveField(field_id,field_index,!1)):0!==$scope.selected.index&&$scope.fieldTop>0&&(field_index=$scope.selected.index-1,field_id=$scope.myform.visible_form_fields[field_index]._id,$scope.setActiveField(field_id,field_index,!1)),$scope.$apply())};var getActiveField=function(){if(null===$scope.selected)throw console.error("current active field is null"),new Error("current active field is null");return"submit_field"===$scope.selected._id?$scope.myform.form_fields.length-1:$scope.selected.index};$scope.setActiveField=$rootScope.setActiveField=function(field_id,field_index,animateScroll){if(null!==$scope.selected&&$scope.selected._id!==field_id){$scope.selected._id=field_id,$scope.selected.index=field_index;var nb_valid=$filter("formValidity")($scope.myform);$scope.translateAdvancementData={done:nb_valid,total:form_fields_count,answers_not_completed:form_fields_count-nb_valid},animateScroll?($scope.noscroll=!0,setTimeout(function(){$document.scrollToElement(angular.element(".activeField"),-10,200).then(function(){$scope.noscroll=!1,setTimeout(function(){document.querySelectorAll(".activeField .focusOn").length?document.querySelectorAll(".activeField .focusOn")[0].focus():document.querySelectorAll(".activeField input").length?document.querySelectorAll(".activeField input")[0].focus():document.querySelectorAll(".activeField .selectize-input")[0].focus()})})})):setTimeout(function(){document.querySelectorAll(".activeField .focusOn")[0]?document.querySelectorAll(".activeField .focusOn")[0].focus():document.querySelectorAll(".activeField input")[0].focus()}),SendVisitorData.send($scope.myform,getActiveField(),TimeCounter.getTimeElapsed())}},$rootScope.nextField=$scope.nextField=function(){var selected_index,selected_id;$scope.selected.index<$scope.myform.visible_form_fields.length-1?(selected_index=$scope.selected.index+1,selected_id=$scope.myform.visible_form_fields[selected_index]._id,$rootScope.setActiveField(selected_id,selected_index,!0)):$scope.selected.index===$scope.myform.visible_form_fields.length-1&&(selected_index=$scope.selected.index+1,selected_id="submit_field",$rootScope.setActiveField(selected_id,selected_index,!0))},$rootScope.prevField=$scope.prevField=function(){if($scope.selected.index>0){var selected_index=$scope.selected.index-1,selected_id=$scope.myform.visible_form_fields[selected_index]._id;$scope.setActiveField(selected_id,selected_index,!0)}},$scope.exitStartPage=function(){$scope.myform.startPage.showStart=!1,$scope.myform.visible_form_fields.length>0&&($scope.selected._id=$scope.myform.visible_form_fields[0]._id)},$rootScope.goToInvalid=$scope.goToInvalid=function(){document.querySelectorAll(".ng-invalid.focusOn")[0].focus()},$rootScope.submitForm=$scope.submitForm=function(){var _timeElapsed=TimeCounter.stopClock();$scope.loading=!0;var form=_.cloneDeep($scope.myform);form.timeElapsed=_timeElapsed,form.percentageComplete=$filter("formValidity")($scope.myform)/$scope.myform.visible_form_fields.length*100,
-delete form.visible_form_fields;for(var i=0;i<$scope.myform.form_fields.length;i++)"dropdown"!==$scope.myform.form_fields[i].fieldType||$scope.myform.form_fields[i].deletePreserved||($scope.myform.form_fields[i].fieldValue=$scope.myform.form_fields[i].fieldValue.option_value);setTimeout(function(){$scope.submitPromise=$http.post("/forms/"+$scope.myform._id,form).success(function(data,status,headers){console.log($scope.myform.form_fields[0]),$scope.myform.submitted=!0,$scope.loading=!1,SendVisitorData.send($scope.myform,getActiveField(),_timeElapsed)}).error(function(error){$scope.loading=!1,console.error(error),$scope.error=error.message})},500)},$scope.reloadForm()}]}}]),angular.module("forms").service("CurrentForm",function(){var _form={};this.getForm=function(){return _form},this.setForm=function(form){_form=form}}),angular.module("forms").factory("Forms",["$resource","FORM_URL",function($resource,FORM_URL){return $resource(FORM_URL,{formId:"@_id"},{query:{method:"GET",isArray:!0},get:{method:"GET",transformResponse:function(data,header){var form=angular.fromJson(data);return form.visible_form_fields=_.filter(form.form_fields,function(field){return field.deletePreserved===!1}),form}},update:{method:"PUT"},save:{method:"POST"}})}]),angular.module("forms").service("TimeCounter",[function(){var _startTime,_endTime=null;this.timeSpent=0,this.restartClock=function(){_startTime=Date.now(),_endTime=null},this.getTimeElapsed=function(){return _startTime?Math.abs(Date.now().valueOf()-_startTime.valueOf())/1e3:void 0},this.stopClock=function(){return _startTime&&null===_endTime?(_endTime=Date.now(),this.timeSpent=Math.abs(_endTime.valueOf()-_startTime.valueOf())/1e3,this._startTime=this._endTime=null,this.timeSpent):new Error("Clock has not been started")},this.clockStarted=function(){return!!this._startTime}}]),function(){describe("AdminForm Controller Tests",function(){var createAdminFormController,scope,$httpBackend,$stateParams,$location,$state,sampleUser={firstName:"Full",lastName:"Name",email:"test@test.com",username:"test@test.com",password:"password",provider:"local",roles:["user"],_id:"ed873933b1f1dea0ce12fab9"},sampleForm={title:"Form Title",admin:"ed873933b1f1dea0ce12fab9",language:"english",form_fields:[{fieldType:"textfield",title:"First Name",fieldValue:"",deletePreserved:!1,_id:"56340745f59a6fc9e22028e9"},{fieldType:"checkbox",title:"nascar",fieldValue:"",deletePreserved:!1,_id:"5c9e22028e907634f45f59a6"},{fieldType:"checkbox",title:"hockey",fieldValue:"",deletePreserved:!1,_id:"56e90745f5934fc9e22028a6"}],_id:"525a8422f6d0f87f0e407a33"},newFakeModal=function(){var result={opened:!0,result:{then:function(confirmCallback,cancelCallback){this.confirmCallBack=confirmCallback,this.cancelCallback=cancelCallback}},close:function(item){this.opened=!1,this.result.confirmCallBack(item)},dismiss:function(type){this.opened=!1,this.result.cancelCallback(type)}};return result};beforeEach(module(function($provide){$provide.service("myForm",function($q){return sampleForm})})),beforeEach(function(){jasmine.addMatchers({toEqualData:function(util,customEqualityTesters){return{compare:function(actual,expected){return{pass:angular.equals(actual,expected)}}}}})}),beforeEach(module(ApplicationConfiguration.applicationModuleName)),beforeEach(module("stateMock")),beforeEach(module(function($provide){$provide.service("User",function($q){return{getCurrent:function(){var deferred=$q.defer();return deferred.resolve(JSON.stringify(sampleUser)),deferred.promise},login:function(credentials){var deferred=$q.defer();return credentials.password===sampleUser.password&&credentials.username===sampleUser.username?deferred.resolve(JSON.stringify(sampleUser)):deferred.resolve("Error: User could not be loggedin"),deferred.promise},logout:function(){var deferred=$q.defer();return deferred.resolve(null),deferred.promise},signup:function(credentials){var deferred=$q.defer();return credentials.password===sampleUser.password&&credentials.username===sampleUser.username?deferred.resolve(JSON.stringify(sampleUser)):deferred.resolve("Error: User could not be signed up"),deferred.promise}}})})),beforeEach(module(function($provide){$provide.service("Auth",function(){return{ensureHasCurrentUser:function(){return sampleUser},isAuthenticated:function(){return!0},getUserState:function(){return!0}}})})),beforeEach(inject(function($uibModal){var modal=newFakeModal();spyOn($uibModal,"open").and.returnValue(modal)})),beforeEach(inject(function($controller,$rootScope,_$state_,_$location_,_$stateParams_,_$httpBackend_,CurrentForm,Forms){scope=$rootScope.$new(),CurrentForm.setForm(sampleForm),$stateParams=_$stateParams_,$httpBackend=_$httpBackend_,$location=_$location_,$state=_$state_,$httpBackend.whenGET(/\.html$/).respond(""),$httpBackend.whenGET("/users/me/").respond(""),createAdminFormController=function(){return $controller("AdminFormController",{$scope:scope})}})),it("AdminFormController should fetch current Form when instantiated",function(){createAdminFormController();expect(scope.myform).toEqualData(sampleForm)}),it("$scope.removeCurrentForm() with valid form data should send a DELETE request with the id of form",function(){createAdminFormController();$state.expectTransitionTo("listForms"),$httpBackend.expect("DELETE",/^(\/forms\/)([0-9a-fA-F]{24})$/).respond(200,sampleForm),scope.openDeleteModal(),scope.removeCurrentForm(),$httpBackend.flush(),$state.ensureAllTransitionsHappened()}),it("$scope.update() should send a PUT request with the id of form",function(){createAdminFormController();$httpBackend.expect("PUT",/^(\/forms\/)([0-9a-fA-F]{24})$/).respond(200,sampleForm),scope.update(!1,null),$httpBackend.flush()}),it("$scope.openDeleteModal() should open scope.deleteModal",function(){createAdminFormController();scope.openDeleteModal(),console.log(scope.deleteModal),expect(scope.deleteModal.opened).toEqual(!0)}),it("$scope.cancelDeleteModal() should close $scope.deleteModal",inject(function($uibModal){createAdminFormController();scope.openDeleteModal(),scope.cancelDeleteModal(),expect(scope.deleteModal.opened).toEqual(!1)}))})}(),function(){describe("ListForms Controller Tests",function(){var createListFormsController,scope,$httpBackend,$stateParams,$location,$state,sampleForm={title:"Form Title",admin:"ed873933b1f1dea0ce12fab9",language:"english",form_fields:[{fieldType:"textfield",title:"First Name",fieldValue:"",deletePreserved:!1},{fieldType:"checkbox",title:"nascar",fieldValue:"",deletePreserved:!1},{fieldType:"checkbox",title:"hockey",fieldValue:"",deletePreserved:!1}],_id:"525a8422f6d0f87f0e407a33"},sampleFormList=[{title:"Form Title1",admin:"ed873933b1f1dea0ce12fab9",language:"english",form_fields:[{fieldType:"textfield",title:"First Name",fieldValue:"",deletePreserved:!1},{fieldType:"checkbox",title:"nascar",fieldValue:"",deletePreserved:!1},{fieldType:"checkbox",title:"hockey",fieldValue:"",deletePreserved:!1}],_id:"525a8422f6d0f87f0e407a33"},{title:"Form Title2",admin:"39223933b1f1dea0ce12fab9",language:"english",form_fields:[{fieldType:"textfield",title:"First Name",fieldValue:"",deletePreserved:!1},{fieldType:"checkbox",title:"nascar",fieldValue:"",deletePreserved:!1},{fieldType:"checkbox",title:"hockey",fieldValue:"",deletePreserved:!1}],_id:"52f6d0f87f5a407a384220e3"},{title:"Form Title3",admin:"2fab9ed873937f0e1dea0ce1",language:"english",form_fields:[{fieldType:"textfield",title:"First Name",fieldValue:"",deletePreserved:!1},{fieldType:"checkbox",title:"nascar",fieldValue:"",deletePreserved:!1},{fieldType:"checkbox",title:"hockey",fieldValue:"",deletePreserved:!1}],_id:"922f6d0f87fed8730e4e1233"}];beforeEach(function(){jasmine.addMatchers({toEqualData:function(util,customEqualityTesters){return{compare:function(actual,expected){return{pass:angular.equals(actual,expected)}}}}})}),beforeEach(module(ApplicationConfiguration.applicationModuleName)),beforeEach(module("stateMock")),beforeEach(module(function($provide){$provide.service("myForm",function($q){return sampleForm})})),beforeEach(inject(function($controller,$rootScope,_$state_,_$location_,_$stateParams_,_$httpBackend_,CurrentForm,Forms){scope=$rootScope.$new(),CurrentForm.setForm(sampleForm),$stateParams=_$stateParams_,$httpBackend=_$httpBackend_,$location=_$location_,$state=_$state_,$httpBackend.whenGET(/\.html$/).respond(""),$httpBackend.whenGET("/users/me/").respond(""),createListFormsController=function(){return $controller("ListFormsController",{$scope:scope})}})),it("$scope.findAll() should query all User's Forms",inject(function(Forms){createListFormsController();$httpBackend.expectGET(/^(\/forms)$/).respond(200,sampleFormList),scope.findAll(),$httpBackend.flush(),expect(scope.myforms).toEqualData(sampleFormList)})),it("$scope.duplicateForm() should duplicate a Form",inject(function(Forms){var dupSampleForm=sampleFormList[2],dupSampleForm_index=3,newSampleFormList=_.clone(sampleFormList);dupSampleForm._id="a02df75b44c1d26b6a5e05b8",newSampleFormList.splice(3,0,dupSampleForm);createListFormsController();$httpBackend.expectGET(/^(\/forms)$/).respond(200,sampleFormList),scope.findAll(),$httpBackend.flush(),$httpBackend.expect("POST","/forms").respond(200,dupSampleForm),scope.duplicateForm(2),$httpBackend.flush(),expect(scope.myforms.length).toEqual(newSampleFormList.length);for(var i=0;i"),$compile(el)(tmp_scope),$rootScope.$digest(),$httpBackend=_$httpBackend_,$httpBackend.whenGET("/users/me/").respond(""),controller=el.controller(),scope=el.isolateScope()||el.scope()})),it("$scope.uploadPDF() should upload a pdf file",function(){expect(scope.pdfLoading).toBe(!1),$httpBackend.when("POST","/upload/pdf").respond(pdfObj);var files=[{}];scope.uploadPDF(files),$httpBackend.flush(),expect(scope.myform.pdf).toEqualData(pdfObj)}),it("$scope.removePDF() should removed uploaded pdf file",function(){scope.myform.pdf=pdfObj,scope.myform.isGenerated=!0,scope.myform.autofillPDFs=!0,scope.removePDF(),expect(scope.myform.pdf).toEqual(null),expect(scope.myform.isGenerated).toBe(!1),expect(scope.myform.autofillPDFs).toBe(!1)})})}(),function(){describe("EditSubmissions Directive-Controller Tests",function(){var el,scope,controller,$httpBackend,sampleUser={firstName:"Full",lastName:"Name",email:"test@test.com",username:"test@test.com",password:"password",provider:"local",roles:["user"],_id:"ed873933b1f1dea0ce12fab9"},sampleForm={title:"Form Title",admin:"ed873933b1f1dea0ce12fab9",language:"english",form_fields:[{fieldType:"textfield",title:"First Name",fieldOptions:[],fieldValue:"",required:!0,disabled:!1,deletePreserved:!1,_id:"ed873933b0ce121f1deafab9"},{fieldType:"checkbox",title:"nascar",fieldOptions:[],fieldValue:"",required:!0,disabled:!1,deletePreserved:!1,_id:"ed83b0ce121f17393deafab9"},{fieldType:"checkbox",title:"hockey",fieldOptions:[],fieldValue:"",required:!0,disabled:!1,deletePreserved:!1,_id:"ed8317393deab0ce121ffab9"}],pdf:{},pdfFieldMap:{},startPage:{showStart:!1},hideFooter:!1,isGenerated:!1,isLive:!1,autofillPDFs:!1,_id:"525a8422f6d0f87f0e407a33"},sampleSubmissions=[{form_fields:[{fieldType:"textfield",title:"First Name",fieldValue:"The Terminator",deletePreserved:!1},{fieldType:"checkbox",title:"nascar",fieldValue:0,deletePreserved:!1},{fieldType:"checkbox",title:"hockey",fieldValue:1,deletePreserved:!1}],admin:sampleUser,form:sampleForm,timeElapsed:10.33},{form_fields:[{fieldType:"textfield",title:"First Name",fieldValue:"John Smith",deletePreserved:!1},{fieldType:"checkbox",title:"nascar",fieldValue:1,deletePreserved:!1},{fieldType:"checkbox",title:"hockey",fieldValue:0,deletePreserved:!1}],admin:sampleUser,form:sampleForm,timeElapsed:2.33},{form_fields:[{fieldType:"textfield",title:"First Name",fieldValue:"Jane Doe",deletePreserved:!1},{fieldType:"checkbox",title:"nascar",fieldValue:1,deletePreserved:!1},{fieldType:"checkbox",title:"hockey",fieldValue:1,deletePreserved:!1}],admin:sampleUser,form:sampleForm,timeElapsed:11.11}];beforeEach(function(){jasmine.addMatchers({toEqualData:function(util,customEqualityTesters){return{compare:function(actual,expected){return{pass:angular.equals(actual,expected)}}}}})}),beforeEach(module(ApplicationConfiguration.applicationModuleName)),beforeEach(module("module-templates")),beforeEach(module("stateMock")),beforeEach(inject(function($compile,$controller,$rootScope,_$httpBackend_){$httpBackend=_$httpBackend_,$httpBackend.whenGET("/users/me/").respond(""),$httpBackend.whenGET(/^(\/forms\/)([0-9a-fA-F]{24})(\/submissions)$/).respond(200,sampleSubmissions);var tmp_scope=$rootScope.$new();tmp_scope.myform=sampleForm,tmp_scope.user=sampleUser,el=angular.element(""),$compile(el)(tmp_scope),$rootScope.$digest(),controller=el.controller(),scope=el.isolateScope()||el.scope()})),it("$scope.initFormSubmissions() should fetch all relevant form submissions",function(){$httpBackend.expectGET(/^(\/forms\/)([0-9a-fA-F]{24})(\/submissions)$/).respond(200,sampleSubmissions),scope.initFormSubmissions(),$httpBackend.flush(),scope.$digest()}),describe("Form Table Methods",function(){it("$scope.toggleAllCheckers should toggle all checkboxes in table",function(){scope.initFormSubmissions(),$httpBackend.flush(),scope.table.masterChecker=!0,scope.toggleAllCheckers();for(var i=0;i"),$compile(el)(tmp_scope),$rootScope.$digest(),$httpBackend=_$httpBackend_,$httpBackend.whenGET("/users/me/").respond(""),controller=el.controller(),scope=el.isolateScope()||el.scope()})),describe("> Form Field >",function(){beforeEach(function(){scope.myform=_.cloneDeep(sampleForm)}),it("$scope.addNewField() should ADD a new field to $scope.myform.form_fields",function(){scope.addNewField(!0,"textfield");var expectedFormField={title:"Short Text2",fieldType:"textfield",fieldValue:"",required:!0,disabled:!1,deletePreserved:!1},actualFormField=_.cloneDeep(_.last(scope.myform.form_fields));delete actualFormField._id,expect(scope.myform.form_fields.length).toEqual(sampleForm.form_fields.length+1),expect(actualFormField).toEqualData(expectedFormField)}),it("$scope.deleteField() should DELETE a field to $scope.myform.form_fields",function(){scope.deleteField(0),expect(scope.myform.form_fields.length).toEqual(sampleForm.form_fields.length-1),expect(_.first(scope.myform.form_fields)).toEqualData(sampleForm.form_fields[1])}),it("$scope.duplicateField() should DUPLICATE a field and update $scope.myform.form_fields",function(){scope.duplicateField(0);var originalField=_.cloneDeep(scope.myform.form_fields[0]);originalField.title+=" copy",delete originalField._id;var copyField=_.cloneDeep(scope.myform.form_fields[1]);delete copyField._id,expect(scope.myform.form_fields.length).toEqual(sampleForm.form_fields.length+1),expect(originalField).toEqualData(copyField)})}),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"};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(){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;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(){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()})})})}(),function(){describe("FieldIcon Directive Tests",function(){var scope,FormFields,faClasses={textfield:"fa fa-pencil-square-o",dropdown:"fa fa-th-list",date:"fa fa-calendar",checkbox:"fa fa-check-square-o",radio:"fa fa-dot-circle-o",email:"fa fa-envelope-o",textarea:"fa fa-pencil-square",legal:"fa fa-legal",file:"fa fa-cloud-upload",rating:"fa fa-star-half-o",link:"fa fa-link",scale:"fa fa-sliders",stripe:"fa fa-credit-card",statement:"fa fa-quote-left",yes_no:"fa fa-toggle-on",number:"fa fa-slack"};beforeEach(module(ApplicationConfiguration.applicationModuleName)),beforeEach(inject(function($rootScope,_FormFields_){scope=$rootScope.$new(),FormFields=_FormFields_})),it("should be able render all field-icon types",inject(function($compile){for(var currType,currClass,i=0;i')(scope);scope.$digest(),expect(currClass).toBeDefined(),expect(element.find("i")).not.toBe(null),expect(element.find("i").hasClass(currClass)).toBe(!0)}}))})}(),function(){describe("Field Directive Tests",function(){var scope,FormFields,$compile,sampleFields=[{fieldType:"textfield",title:"First Name",fieldValue:"AoeuName",deletePreserved:!1,required:!0,disabled:!1},{fieldType:"email",title:"Email",fieldValue:"aoeu@aoeu.com",deletePreserved:!1,required:!0,disabled:!1},{fieldType:"yes_no",title:"Do you Play Hockey?",fieldValue:"true",deletePreserved:!1,required:!0,disabled:!1},{fieldType:"url",title:"Github Account",fieldValue:"http://github.com/aoeu",deletePreserved:!1,required:!0,disabled:!1},{fieldType:"textarea",title:"Bio",fieldValue:"This is my bio.",deletePreserved:!1,required:!0,disabled:!1},{fieldType:"number",title:"Phone #",fieldValue:5325325325,deletePreserved:!1,required:!0,disabled:!1},{fieldType:"legal",title:"You agree to terms and conditions",description:"By selecting 'I agree' you are agreeing under Canadian law that you have read and accept terms and conditions outlayed below",fieldValue:"",deletePreserved:!1,required:!0,disabled:!1},{fieldType:"dropdown",title:"Your Sex",fieldValue:"",fieldOptions:[{option_id:0,option_title:"M",option_value:"male"},{option_id:1,option_title:"F",option_value:"female"}],deletePreserved:!1,required:!0,disabled:!1},{fieldType:"radio",title:"Your Sexual Orientation",fieldValue:"",fieldOptions:[{option_id:0,option_title:"Heterosexual",option_value:"hetero"},{option_id:1,option_title:"Homosexual",option_value:"homo"},{option_id:2,option_title:"Bisexual",option_value:"bi"},{option_id:3,option_title:"Asexual",option_value:"asex"}],deletePreserved:!1,required:!0,disabled:!1},{fieldType:"rating",title:"Your Current Happiness",fieldValue:"0",deletePreserved:!1,required:!0,disabled:!1}];beforeEach(function(){jasmine.addMatchers({toEqualData:function(util,customEqualityTesters){return{compare:function(actual,expected){return{pass:angular.equals(actual,expected)}}}}})}),beforeEach(module(function($sceProvider){$sceProvider.enabled(!1)})),beforeEach(module(ApplicationConfiguration.applicationModuleName)),beforeEach(module("stateMock")),beforeEach(module("module-templates")),beforeEach(module("ngSanitize","ui.select")),beforeEach(inject(function($rootScope,_FormFields_,_$compile_){scope=$rootScope.$new(),FormFields=_FormFields_,$compile=_$compile_})),it("should be able to render all field types in html",inject(function($rootScope){scope.fields=sampleFields;for(var i=0;i');$compile(element)(scope),scope.$digest(),console.log("Actual: "),console.log(element.html()),console.log("\nExpected: "),console.log('
"),expect(element.html()).not.toEqual('
")}}))})}(),function(){describe("onFinishRender Directive Tests",function(){var scope,FormFields;beforeEach(module(ApplicationConfiguration.applicationModuleName)),beforeEach(inject(function($rootScope,_FormFields_){scope=$rootScope.$new(),FormFields=_FormFields_,spyOn($rootScope,"$broadcast")})),it('should emit Custom "Finished" and "Started" events on ng-repeat',inject(function($compile,$rootScope){scope.myfields=FormFields.types;$compile('
{{item.name}}
')(scope);scope.$digest(),expect($rootScope.$broadcast).toHaveBeenCalledWith("editFormFields Started"),expect(scope.$broadcast).toHaveBeenCalledWith("editFormFields Finished")})),it('should emit "ngRepeat Finished" and "ngRepeat Started" events on ng-repeat when attr is not set to string',inject(function($compile,$rootScope){scope.myfields=FormFields.types;$compile('
{{item.name}}
')(scope);scope.$digest(),expect($rootScope.$broadcast).toHaveBeenCalledWith("ngRepeat Started"),expect(scope.$broadcast).toHaveBeenCalledWith("ngRepeat Finished")}))})}(),function(){describe("SubmitForm Directive-Controller Tests",function(){var scope,controller,$httpBackend,sampleUser={firstName:"Full",lastName:"Name",email:"test@test.com",username:"test@test.com",password:"password",provider:"local",roles:["user"],_id:"ed873933b1f1dea0ce12fab9"},sampleForm={title:"Form Title",admin:"ed873933b1f1dea0ce12fab9",language:"english",form_fields:[{fieldType:"textfield",title:"First Name",fieldOptions:[],fieldValue:"",required:!0,disabled:!1,deletePreserved:!1,_id:"ed873933b0ce121f1deafab9"},{fieldType:"checkbox",title:"nascar",fieldOptions:[],fieldValue:"",required:!0,disabled:!1,deletePreserved:!1,_id:"ed83b0ce121f17393deafab9"},{fieldType:"checkbox",title:"hockey",fieldOptions:[],fieldValue:"",required:!0,disabled:!1,deletePreserved:!1,_id:"ed8317393deab0ce121ffab9"}],visible_form_fields:[{fieldType:"textfield",title:"First Name",fieldOptions:[],fieldValue:"",required:!0,disabled:!1,deletePreserved:!1,_id:"ed873933b0ce121f1deafab9"},{fieldType:"checkbox",title:"nascar",fieldOptions:[],fieldValue:"",required:!0,disabled:!1,deletePreserved:!1,_id:"ed83b0ce121f17393deafab9"},{fieldType:"checkbox",title:"hockey",fieldOptions:[],fieldValue:"",required:!0,disabled:!1,deletePreserved:!1,_id:"ed8317393deab0ce121ffab9"
-}],pdf:{},pdfFieldMap:{},startPage:{showStart:!1},hideFooter:!1,isGenerated:!1,isLive:!1,autofillPDFs:!1,_id:"525a8422f6d0f87f0e407a33"},sampleSubmissions=[{form_fields:[{fieldType:"textfield",title:"First Name",fieldValue:"The Terminator",deletePreserved:!1},{fieldType:"yes_no",title:"Do you like nascar",fieldValue:"true",deletePreserved:!1},{fieldType:"yes_no",title:"Do you like hockey",fieldValue:"false",deletePreserved:!1}],admin:sampleUser,form:sampleForm,timeElapsed:10.33},{form_fields:[{fieldType:"textfield",title:"First Name",fieldValue:"John Smith",deletePreserved:!1},{fieldType:"yes_no",title:"Do you like nascar",fieldValue:"true",deletePreserved:!1},{fieldType:"yes_no",title:"Do you like hockey",fieldValue:"true",deletePreserved:!1}],admin:sampleUser,form:sampleForm,timeElapsed:2.33},{form_fields:[{fieldType:"textfield",title:"First Name",fieldValue:"Jane Doe",deletePreserved:!1},{fieldType:"yes_no",title:"Do you like nascar",fieldValue:"false",deletePreserved:!1},{fieldType:"yes_no",title:"Do you like hockey",fieldValue:"false",deletePreserved:!1}],admin:sampleUser,form:sampleForm,timeElapsed:11.11}];beforeEach(function(){jasmine.addMatchers({toEqualData:function(util,customEqualityTesters){return{compare:function(actual,expected){return{pass:angular.equals(actual,expected)}}}}})}),beforeEach(module(ApplicationConfiguration.applicationModuleName)),beforeEach(module("module-templates")),beforeEach(module("stateMock")),beforeEach(inject(function($compile,$controller,$rootScope,_$httpBackend_){$httpBackend=_$httpBackend_,$httpBackend.whenGET("/users/me/").respond("");var tmp_scope=$rootScope.$new();tmp_scope.myform=sampleForm;var el=angular.element("");$compile(el)(tmp_scope),tmp_scope.$digest(),$rootScope.$digest(),controller=el.controller(),scope=el.isolateScope()||el.scope(),console.log(scope)}));var Validator=function(){return{hasMinimumFields:function(entry){return!_.isEmpty(entry._id)&&!_.isEmpty(entry.title)},isNewForm:function(entry){return this.hasMinimumFields(entry)}}}();it("$scope.submitForm() should submit valid form",function(){scope.myform.form_fields=sampleSubmissions[0].form_fields;var expectedForm=_.cloneDeep(sampleForm);expectedForm.form_fields=sampleSubmissions[0].form_fields,delete expectedForm.visible_form_fields;var data=function(data){var form=angular.fromJson(data),compareForm=_.cloneDeep(form);return delete compareForm.timeElapsed,delete compareForm.percentageComplete,Validator.isNewForm(form)&&_.isEqual(compareForm,expectedForm)};$httpBackend.expect("POST",/^(\/forms\/)([0-9a-fA-F]{24})$/,data).respond(200),scope.submitForm(),$httpBackend.flush(),setTimeout(function(){expect(scope.myform.submitted).toBe(!0),expect(scope.error).toEqual("")},25)}),it("$scope.reloadForm() should reset and reload form",function(){scope.submitForm(),scope.reloadForm(),expect(scope.myform.submitted).toBe(!1);for(var i=0;i0))throw Error("No more transitions were expected! Tried to transition to "+stateName);var expectedState=this.expectedTransitions.shift();if(expectedState!==stateName)throw Error("Expected transition to state: "+expectedState+" but transitioned to "+stateName);console.log("Mock transition to: "+stateName);var deferred=$q.defer(),promise=deferred.promise;return deferred.resolve(),promise},this.go=this.transitionTo,this.expectTransitionTo=function(stateName){this.expectedTransitions.push(stateName)},this.ensureAllTransitionsHappened=function(){if(this.expectedTransitions.length>0)throw Error("Not all transitions happened!")}}]),function(){describe("Auth Service Tests",function(){var Auth,sampleUser={firstName:"Full",lastName:"Name",email:"test@test.com",username:"test@test.com",password:"password",provider:"local",roles:["user"],_id:"ed873933b1f1dea0ce12fab9"};beforeEach(function(){jasmine.addMatchers({toEqualData:function(util,customEqualityTesters){return{compare:function(actual,expected){return{pass:angular.equals(actual,expected)}}}}})}),beforeEach(module(ApplicationConfiguration.applicationModuleName)),beforeEach(inject(function(_Auth_){Auth=_Auth_})),it("Auth.login() should save user in Auth.currentUser",function(){Auth.login(sampleUser),expect(Auth.currentUser).toEqualData(sampleUser)}),it("Auth.logout() should remove saved user",inject(function($window){Auth.logout(),expect($window.user).toEqual(null),expect(Auth.currentUser).toEqual(null),expect(Auth.isAuthenticated()).toBe(!1),expect(Auth.getUserState().isLoggedIn).toBe(!1)})),it("Auth.getUserState() should fetch current user state",function(){Auth.login(sampleUser);var currUserState=Auth.getUserState();expect(currUserState.isLoggedIn).toBe(!0),Auth.logout(),currUserState=Auth.getUserState(),expect(currUserState.isLoggedIn).toBe(!1)}),it("Auth.ensureHasCurrentUser() should fetch most current user if it exists in $window, currentUser or fetch it from /users/me",function(){Auth.login(sampleUser);var currUser=Auth.ensureHasCurrentUser(sampleUser);expect(currUser).not.toEqual(null),expect(currUser).toEqualData(sampleUser)})})}(),function(){describe("Authorizer Service Tests",function(){var Authorizer,sampleUser={firstName:"Full",lastName:"Name",email:"test@test.com",username:"test@test.com",password:"password",provider:"local",roles:["user"],_id:"ed873933b1f1dea0ce12fab9"};beforeEach(function(){jasmine.addMatchers({toEqualData:function(util,customEqualityTesters){return{compare:function(actual,expected){return{pass:angular.equals(actual,expected)}}}}})}),beforeEach(module(ApplicationConfiguration.applicationModuleName)),beforeEach(inject(function(_Authorizer_){Authorizer=_Authorizer_})),it("Authorizer.canAccess() should return expected values for 'admin' and 'user' accounts",function(){var sampleAdminUser=_.cloneDeep(sampleUser);sampleAdminUser.roles.push("admin");var authenticatorUser=new Authorizer(sampleUser),authenticatorAdmin=new Authorizer(sampleAdminUser);expect(authenticatorUser.canAccess("editForm")).toBe(!0),expect(authenticatorUser.canAccess("editAdminSettings")).toBe(!1),expect(authenticatorUser.canAccess("viewAdminSettings")).toBe(!1),expect(authenticatorAdmin.canAccess("editForm")).toBe(!0),expect(authenticatorAdmin.canAccess("editAdminSettings")).toBe(!0),expect(authenticatorAdmin.canAccess("viewAdminSettings")).toBe(!0)})})}(),function(){describe("User Service Tests",function(){var User,$httpBackend,sampleUser={firstName:"Full",lastName:"Name",email:"test@test.com",username:"test@test.com",password:"password",provider:"local",roles:["user"],_id:"ed873933b1f1dea0ce12fab9"},sampleVerifyToken="WyuAIchArQnstkq5erx0kiTcTbBbgixYeBGtThFmRpcAJNQ2",sampleForgotToken="c2e8f74455cdccc454dfef941ff315fa4f7b1f0a",sampleCredentials={username:sampleUser.username,password:sampleUser.password},samplePasswordDetails={newPassword:sampleUser.password,verifyPassword:sampleUser.password};beforeEach(function(){jasmine.addMatchers({toEqualData:function(util,customEqualityTesters){return{compare:function(actual,expected){return{pass:angular.equals(actual,expected)}}}}})}),beforeEach(module(ApplicationConfiguration.applicationModuleName)),beforeEach(module("stateMock")),beforeEach(inject(function(_$httpBackend_,_User_){$httpBackend=_$httpBackend_,User=_User_})),it("User.login() should send a POST request to /auth/signin",function(){$httpBackend.expect("POST","/auth/signin",sampleCredentials).respond(200,sampleUser),User.login(sampleCredentials),$httpBackend.flush()}),it("User.logout() should logout user with /auth/signout",function(){$httpBackend.expect("GET","/auth/signout").respond(200),User.logout(),$httpBackend.flush()}),it("User.getCurrent() should fetch user from /users/me",function(){$httpBackend.expect("GET","/users/me").respond(200,sampleUser),User.getCurrent(),$httpBackend.flush()}),it("User.signup() should signup user with /auth/signup",function(){$httpBackend.expect("POST","/auth/signup",sampleCredentials).respond(200),User.signup(sampleCredentials),$httpBackend.flush()}),it("User.resendVerifyEmail() should send POST request to /auth/verify",function(){$httpBackend.expect("POST","/auth/verify",{email:sampleUser.email}).respond(200),User.resendVerifyEmail(sampleUser.email),$httpBackend.flush()}),it("User.validateVerifyToken() should send GET request to /auth/verify/:token",function(){$httpBackend.expect("GET","/auth/verify/"+sampleVerifyToken).respond(200),expect(function(){User.validateVerifyToken(sampleVerifyToken)}).not.toThrow(),$httpBackend.flush()}),it("User.resetPassword() should send GET request to /auth/forgot/:token",function(){$httpBackend.expect("GET","/auth/password/"+sampleForgotToken).respond(200),User.resetPassword(samplePasswordDetails,sampleForgotToken),$httpBackend.flush()}),it("User.askForPasswordReset() should send POST request to /auth/forgot",function(){$httpBackend.expect("POST","/auth/forgot",sampleCredentials).respond(200,sampleUser),User.askForPasswordReset(sampleCredentials),$httpBackend.flush()})})}();
\ No newline at end of file
+$templateCache.put("modules/users/views/settings/edit-profile.client.view.html",'