summaryrefslogtreecommitdiffstats
path: root/js/vendor/angular-ui/modules/directives/showhide/test/showhideSpec.js
diff options
context:
space:
mode:
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.js104
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);
+ });
+ });
+ });
+})();