diff options
| author | Igor Minar | 2012-11-24 01:47:52 +0100 | 
|---|---|---|
| committer | Igor Minar | 2012-11-26 15:45:04 +0100 | 
| commit | 650fd933df614ac733cd43fe31d81d622a2ce2bc (patch) | |
| tree | b57e97e5c6c5ac9bc105b0a54860084335e3d95d /test/jqLiteSpec.js | |
| parent | e249502880974cd7bc34a065d23f4d0bfdec6353 (diff) | |
| download | angular.js-650fd933df614ac733cd43fe31d81d622a2ce2bc.tar.bz2 | |
feat(jqLite): add triggerHandler()
we need triggerHandler() to become jQuery 1.8.x compatible.
this is not fully featured triggerHandler() implementation - it doesn't
bother creating new DOM events and passing them into the event handlers.
this is intentional, we don't need access to the native DOM event for our
own purposes and creating these event objects is really tricky.
Diffstat (limited to 'test/jqLiteSpec.js')
| -rw-r--r-- | test/jqLiteSpec.js | 27 | 
1 files changed, 27 insertions, 0 deletions
| diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js index 1a56a343..76a2c5a8 100644 --- a/test/jqLiteSpec.js +++ b/test/jqLiteSpec.js @@ -1091,6 +1091,33 @@ describe('jqLite', function() {    }); +  describe('triggerHandler', function() { +    it('should trigger all registered handlers for an event', function() { +      var element = jqLite('<span>poke</span>'), +          pokeSpy = jasmine.createSpy('poke'), +          clickSpy1 = jasmine.createSpy('clickSpy1'), +          clickSpy2 = jasmine.createSpy('clickSpy2'); + +      element.bind('poke', pokeSpy); +      element.bind('click', clickSpy1); +      element.bind('click', clickSpy2); + +      expect(pokeSpy).not.toHaveBeenCalled(); +      expect(clickSpy1).not.toHaveBeenCalled(); +      expect(clickSpy2).not.toHaveBeenCalled(); + +      element.triggerHandler('poke'); +      expect(pokeSpy).toHaveBeenCalledOnce(); +      expect(clickSpy1).not.toHaveBeenCalled(); +      expect(clickSpy2).not.toHaveBeenCalled(); + +      element.triggerHandler('click'); +      expect(clickSpy1).toHaveBeenCalledOnce(); +      expect(clickSpy2).toHaveBeenCalledOnce(); +    }); +  }); + +    describe('camelCase', function() {     it('should leave non-dashed strings alone', function() { | 
