fixed field directive tests

This commit is contained in:
David Baldwynn 2017-10-29 12:16:34 -07:00
parent ebcc0c63cd
commit f427092144
2 changed files with 65 additions and 8 deletions

View File

@ -5,7 +5,6 @@
describe('FieldIcon Directive Tests', function() {
// Initialize global variables
var scope,
FormFields,
faClasses = {
'textfield': 'fa fa-pencil-square-o',
'dropdown': 'fa fa-th-list',
@ -25,6 +24,10 @@
'number': 'fa fa-slack'
};
// Load the main application module
beforeEach(module(ApplicationConfiguration.applicationModuleName));
//Mock FormFields Service
var FormFields = {
types: [
{
@ -77,11 +80,6 @@
}
]
};
// Load the main application module
beforeEach(module(ApplicationConfiguration.applicationModuleName));
//Mock FormFields Service
beforeEach(module(function($provide) {
$provide.service('FormFields', function() {
return FormFields;

View File

@ -5,11 +5,63 @@
describe('Field Directive Tests', function() {
// Initialize global variables
var scope,
FormFields,
$templateCache,
$httpBackend,
$compile;
var FormFields = {
types: [
{
name : 'textfield',
value : 'Short Text'
},
{
name : 'email',
value : 'Email'
},
{
name : 'radio',
value : 'Muliple Choice'
},
{
name : 'dropdown',
value : 'Dropdown'
},
{
name : 'date',
value : 'Date'
},
{
name : 'textarea',
value : 'Paragraph',
},
{
name : 'yes_no',
value : 'Yes/No',
},
{
name : 'legal',
value : 'Legal',
},
{
name : 'rating',
value : 'Rating',
},
{
name : 'link',
value : 'Link',
},
{
name : 'number',
value : 'Numbers',
},
{
name : 'statement',
value : 'Statement'
}
]
};
var sampleUser = {
firstName: 'Full',
lastName: 'Name',
@ -65,9 +117,15 @@
beforeEach(module('ngSanitize', 'ui.select'));
//Mock FormFields Service
beforeEach(module(function($provide) {
$provide.service('FormFields', function() {
return FormFields;
});
}));
beforeEach(inject(function($rootScope, _FormFields_, _$compile_, _$httpBackend_) {
scope = $rootScope.$new();
FormFields = _FormFields_;
// Point global variables to injected services
$httpBackend = _$httpBackend_;
@ -76,6 +134,7 @@
$compile = _$compile_;
}));
it('should be able to render all field types in html', inject(function($rootScope) {
scope.fields = sampleFields;