From 52a55ec61895951999cb0d74e706725b965e9c9f Mon Sep 17 00:00:00 2001 From: Braden Shepherdson Date: Fri, 12 Apr 2013 14:03:36 -0400 Subject: feat(ngTap): Add a CSS class while the element is held down. --- test/ngMobile/directive/ngClickSpec.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/ngMobile/directive/ngClickSpec.js b/test/ngMobile/directive/ngClickSpec.js index 2f42662d..dd7ffed0 100644 --- a/test/ngMobile/directive/ngClickSpec.js +++ b/test/ngMobile/directive/ngClickSpec.js @@ -82,7 +82,7 @@ describe('ngClick (mobile)', function() { it('should not click if a touchmove comes before touchend', inject(function($rootScope, $compile, $rootElement) { - element = $compile('
')($rootScope); + element = $compile('')($rootScope); $rootElement.append(element); $rootScope.$digest(); @@ -95,6 +95,22 @@ describe('ngClick (mobile)', function() { expect($rootScope.tapped).toBeUndefined(); })); + it('should add the CSS class while the element is held down, and then remove it', inject(function($rootScope, $compile, $rootElement) { + element = $compile('')($rootScope); + $rootElement.append(element); + $rootScope.$digest(); + expect($rootScope.tapped).toBeUndefined(); + + var CSS_CLASS = 'ng-click-active'; + + expect(element.hasClass(CSS_CLASS)).toBe(false); + browserTrigger(element, 'touchstart', 10, 10); + expect(element.hasClass(CSS_CLASS)).toBe(true); + browserTrigger(element, 'touchend', 10, 10); + expect(element.hasClass(CSS_CLASS)).toBe(false); + expect($rootScope.tapped).toBe(true); + })); + describe('the clickbuster', function() { var element1, element2; @@ -292,4 +308,6 @@ describe('ngClick (mobile)', function() { expect($rootScope.event).toBeDefined(); })); }); + + }); -- cgit v1.2.3