diff options
Diffstat (limited to 'js/vendor/angular-ui/modules/directives/mask/test/maskSpec.js')
-rw-r--r-- | js/vendor/angular-ui/modules/directives/mask/test/maskSpec.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/js/vendor/angular-ui/modules/directives/mask/test/maskSpec.js b/js/vendor/angular-ui/modules/directives/mask/test/maskSpec.js new file mode 100644 index 000000000..afbdbfb1e --- /dev/null +++ b/js/vendor/angular-ui/modules/directives/mask/test/maskSpec.js @@ -0,0 +1,47 @@ +xdescribe('uiMask', function () { + + var inputHtml = "<input ui-mask=\"'(9)9'\" ng-model='x'>"; + var $compile, $rootScope, element; + + beforeEach(module('ui.directives')); + beforeEach(inject(function (_$rootScope_, _$compile_) { + $rootScope = _$rootScope_; + $compile = _$compile_; + })); + + describe('ui changes on model changes', function () { + it('should update ui valid model value', function () { + $rootScope.x = undefined; + element = $compile(inputHtml)($rootScope); + $rootScope.$digest(); + expect(element.val()).toBe(''); + $rootScope.$apply(function () { + $rootScope.x = 12; + }); + expect(element.val()).toBe('(1)2'); + }); + it('should wipe out ui on invalid model value', function () { + $rootScope.x = 12; + element = $compile(inputHtml)($rootScope); + $rootScope.$digest(); + expect(element.val()).toBe('(1)2'); + $rootScope.$apply(function () { + $rootScope.x = 1; + }); + expect(element.val()).toBe(''); + }); + }); + + describe('model binding on ui change', function () { + //TODO: was having har time writing those tests, will open a separate issue for those + }); + + describe('should fail', function() { + it('errors on missing quotes', function() { + $rootScope.x = 42; + var errorInputHtml = "<input ui-mask=\"(9)9\" ng-model='x'>"; + element = $compile(errorInputHtml)($rootScope); + expect($rootScope.$digest).toThrow('The Mask widget is not correctly set up'); + }); + }); +});
\ No newline at end of file |