diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/helpers/matchers.js | 9 | ||||
| -rw-r--r-- | test/jqLiteSpec.js | 14 | ||||
| -rw-r--r-- | test/ng/animateSpec.js | 12 |
3 files changed, 34 insertions, 1 deletions
diff --git a/test/helpers/matchers.js b/test/helpers/matchers.js index 57bf35c7..14430b37 100644 --- a/test/helpers/matchers.js +++ b/test/helpers/matchers.js @@ -31,7 +31,14 @@ beforeEach(function() { } function isNgElementHidden(element) { - return angular.element(element).hasClass('ng-hide'); + // we need to check element.getAttribute for SVG nodes + var hidden = true; + forEach(angular.element(element), function (element) { + if ((' ' +(element.getAttribute('class') || '') + ' ').indexOf(' ng-hide ') === -1) { + hidden = false; + } + }); + return hidden; }; this.addMatchers({ diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js index 79c0d0c6..e6e3a2ac 100644 --- a/test/jqLiteSpec.js +++ b/test/jqLiteSpec.js @@ -479,6 +479,20 @@ describe('jqLite', function() { describe('class', function() { + it('should properly do with SVG elements', function() { + // this is a jqLite & SVG only test (jquery doesn't behave this way right now, which is a bug) + if (!window.SVGElement || !_jqLiteMode) return; + var svg = jqLite('<svg><rect></rect></svg>'); + var rect = svg.children(); + + expect(rect.hasClass('foo-class')).toBe(false); + rect.addClass('foo-class'); + expect(rect.hasClass('foo-class')).toBe(true); + rect.removeClass('foo-class'); + expect(rect.hasClass('foo-class')).toBe(false); + }); + + describe('hasClass', function() { it('should check class', function() { var selector = jqLite([a, b]); diff --git a/test/ng/animateSpec.js b/test/ng/animateSpec.js index 79115c1e..e982862a 100644 --- a/test/ng/animateSpec.js +++ b/test/ng/animateSpec.js @@ -40,6 +40,18 @@ describe("$animate", function() { expect(element).toBeHidden(); })); + it("should add and remove classes on SVG elements", inject(function($animate) { + if (!window.SVGElement) return; + var svg = jqLite('<svg><rect></rect></svg>'); + var rect = svg.children(); + $animate.enabled(false); + expect(rect).toBeShown(); + $animate.addClass(rect, 'ng-hide'); + expect(rect).toBeHidden(); + $animate.removeClass(rect, 'ng-hide'); + expect(rect).not.toBeHidden(); + })); + it("should throw error on wrong selector", function() { module(function($animateProvider) { expect(function() { |
