diff options
Diffstat (limited to 'test/service/formFactorySpec.js')
| -rw-r--r-- | test/service/formFactorySpec.js | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/test/service/formFactorySpec.js b/test/service/formFactorySpec.js index 5223cede..23b8ae0a 100644 --- a/test/service/formFactorySpec.js +++ b/test/service/formFactorySpec.js @@ -1,23 +1,23 @@ 'use strict'; -describe('$formFactory', function(){ +describe('$formFactory', function() { var rootScope; var formFactory; - beforeEach(function(){ + beforeEach(function() { rootScope = angular.scope(); formFactory = rootScope.$service('$formFactory'); }); - it('should have global form', function(){ + it('should have global form', function() { expect(formFactory.rootForm).toBeTruthy(); expect(formFactory.rootForm.$createWidget).toBeTruthy(); }); - describe('new form', function(){ + describe('new form', function() { var form; var scope; var log; @@ -25,7 +25,7 @@ describe('$formFactory', function(){ function WidgetCtrl($formFactory){ this.$formFactory = $formFactory; log += '<init>'; - this.$render = function(){ + this.$render = function() { log += '$render();'; }; this.$on('$validate', function(e){ @@ -41,13 +41,13 @@ describe('$formFactory', function(){ } }; - beforeEach(function(){ + beforeEach(function() { log = ''; scope = rootScope.$new(); form = formFactory(scope); }); - describe('$createWidget', function(){ + describe('$createWidget', function() { var widget; beforeEach(function() { @@ -55,19 +55,20 @@ describe('$formFactory', function(){ scope:scope, model:'text', alias:'text', - controller:WidgetCtrl}); + controller:WidgetCtrl + }); }); - describe('data flow', function(){ - it('should have status properties', function(){ + describe('data flow', function() { + it('should have status properties', function() { expect(widget.$error).toEqual({}); expect(widget.$valid).toBe(true); expect(widget.$invalid).toBe(false); }); - it('should update view when model changes', function(){ + it('should update view when model changes', function() { scope.text = 'abc'; scope.$digest(); expect(log).toEqual('<init>$validate();$render();'); @@ -80,14 +81,14 @@ describe('$formFactory', function(){ }); - it('should have controller prototype methods', function(){ + it('should have controller prototype methods', function() { expect(widget.getFormFactory()).toEqual(formFactory); }); }); - describe('validation', function(){ - it('should update state on error', function(){ + describe('validation', function() { + it('should update state on error', function() { widget.$emit('$invalid', 'E'); expect(widget.$valid).toEqual(false); expect(widget.$invalid).toEqual(true); @@ -98,9 +99,9 @@ describe('$formFactory', function(){ }); - it('should have called the model setter before the validation', function(){ + it('should have called the model setter before the validation', function() { var modelValue; - widget.$on('$validate', function(){ + widget.$on('$validate', function() { modelValue = scope.text; }); widget.$emit('$viewChange', 'abc'); @@ -108,8 +109,8 @@ describe('$formFactory', function(){ }); - describe('form', function(){ - it('should invalidate form when widget is invalid', function(){ + describe('form', function() { + it('should invalidate form when widget is invalid', function() { expect(form.$error).toEqual({}); expect(form.$valid).toEqual(true); expect(form.$invalid).toEqual(false); @@ -147,8 +148,8 @@ describe('$formFactory', function(){ }); - describe('id assignment', function(){ - it('should default to name expression', function(){ + describe('id assignment', function() { + it('should default to name expression', function() { expect(form.text).toEqual(widget); }); @@ -201,7 +202,7 @@ describe('$formFactory', function(){ }); - it('should remove invalid fields from errors, when child widget removed', function(){ + it('should remove invalid fields from errors, when child widget removed', function() { widget.$emit('$invalid', 'MyError'); expect(form.$error.MyError).toEqual([widget]); |
