diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-09-09 15:57:10 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-09-09 15:57:18 +0200 |
commit | 2824b43b7332e847810f042c4183ce95ee90e852 (patch) | |
tree | 9a10f31c8acbf01d72336d3d065f8c8fda4b83c5 /js/vendor/angular-ui/modules/directives/showhide/test/showhideSpec.js | |
parent | f0abeddd07fcf21e30c95d58885416ef40d65391 (diff) |
use bower for managing deps
Diffstat (limited to 'js/vendor/angular-ui/modules/directives/showhide/test/showhideSpec.js')
-rw-r--r-- | js/vendor/angular-ui/modules/directives/showhide/test/showhideSpec.js | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/js/vendor/angular-ui/modules/directives/showhide/test/showhideSpec.js b/js/vendor/angular-ui/modules/directives/showhide/test/showhideSpec.js new file mode 100644 index 000000000..6f9959911 --- /dev/null +++ b/js/vendor/angular-ui/modules/directives/showhide/test/showhideSpec.js @@ -0,0 +1,104 @@ +/*global beforeEach, describe, it, inject, expect, module, spyOn*/ + +(function () { + 'use strict'; + + describe('uiShow', function () { + + var scope, $compile; + beforeEach(module('ui.directives')); + beforeEach(inject(function (_$rootScope_, _$compile_) { + scope = _$rootScope_.$new(); + $compile = _$compile_; + })); + + describe('linking the directive', function () { + it('should call scope.$watch', function () { + spyOn(scope, '$watch'); + $compile('<div ui-show="foo"></div>')(scope); + expect(scope.$watch).toHaveBeenCalled(); + }); + }); + + describe('executing the watcher', function () { + it('should add the ui-show class if true', function () { + var element = $compile('<div ui-show="foo"></div>')(scope); + scope.foo = true; + scope.$apply(); + expect(element.hasClass('ui-show')).toBe(true); + }); + it('should remove the ui-show class if false', function () { + var element = $compile('<div ui-show="foo"></div>')(scope); + scope.foo = false; + scope.$apply(); + expect(element.hasClass('ui-show')).toBe(false); + }); + }); + }); + + describe('uiHide', function () { + + var scope, $compile; + beforeEach(module('ui.directives')); + beforeEach(inject(function (_$rootScope_, _$compile_) { + scope = _$rootScope_.$new(); + $compile = _$compile_; + })); + + describe('when the directive is linked', function () { + it('should call scope.$watch', function () { + spyOn(scope, '$watch'); + $compile('<div ui-hide="foo"></div>')(scope); + expect(scope.$watch).toHaveBeenCalled(); + }); + }); + + describe('executing the watcher', function () { + it('should add the ui-hide class if true', function () { + var element = $compile('<div ui-hide="foo"></div>')(scope); + scope.foo = true; + scope.$apply(); + expect(element.hasClass('ui-hide')).toBe(true); + }); + it('should remove the ui-hide class if false', function () { + var element = $compile('<div ui-hide="foo"></div>')(scope); + scope.foo = false; + scope.$apply(); + expect(element.hasClass('ui-hide')).toBe(false); + }); + }); + }); + + describe('uiToggle', function () { + + var scope, $compile; + beforeEach(module('ui.directives')); + beforeEach(inject(function (_$rootScope_, _$compile_) { + scope = _$rootScope_.$new(); + $compile = _$compile_; + })); + + describe('when the directive is linked', function () { + it('should call scope.$watch', function () { + spyOn(scope, '$watch'); + $compile('<div ui-toggle="foo"></div>')(scope); + expect(scope.$watch).toHaveBeenCalled(); + }); + }); + + describe('executing the watcher', function () { + it('should remove the ui-hide class and add the ui-show class if true', function () { + var element = $compile('<div ui-toggle="foo"></div>')(scope); + scope.foo = true; + scope.$apply(); + expect(element.hasClass('ui-show') && !element.hasClass('ui-hide')).toBe(true); + }); + it('should remove the ui-hide class and add the ui-show class if false', function () { + var element = $compile('<div ui-toggle="foo"></div>')(scope); + scope.foo = false; + scope.$apply(); + expect(!element.hasClass('ui-show') && element.hasClass('ui-hide')).toBe(true); + }); + }); + }); +})(); |