diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2017-03-09 10:07:50 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2017-03-09 10:07:50 +0100 |
commit | 761623033b6fd2af16abb2fe194f24d6e00d4024 (patch) | |
tree | c98e3d8ee18a1be207da19163c6c80b3bcaab783 /spec | |
parent | 4f4f098c8026d1a42356555088eaa0b67ceabfa8 (diff) | |
download | svg.js-761623033b6fd2af16abb2fe194f24d6e00d4024.tar.gz svg.js-761623033b6fd2af16abb2fe194f24d6e00d4024.zip |
make events cancelable by default (#550) - version 5
Diffstat (limited to 'spec')
-rw-r--r-- | spec/spec/event.js | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/spec/spec/event.js b/spec/spec/event.js index 29512f4..7354e6f 100644 --- a/spec/spec/event.js +++ b/spec/spec/event.js @@ -451,7 +451,6 @@ describe('Event', function() { } expect(SVG.handlerMap[SVG.handlerMap.indexOf(rect.node)]).toBe(undefined) - }) }) @@ -481,13 +480,27 @@ describe('Event', function() { rect.fire(new CustomEvent('event')) expect(toast).toBe('ready') }) + it('makes the event cancelable', function() { + rect.on('event', function(e) { + e.preventDefault() + }) + rect.fire('event') + expect(rect._event.defaultPrevented).toBe(true) + }) }) + describe('event()', function() { + it('returns null when no event was fired', function() { + expect(rect.event()).toBe(null) + }) + it('returns the last fired event', function() { + var event = new CustomEvent('foo') + rect.fire(event) + expect(rect.event()).toBe(event) + event = new CustomEvent('bar') + rect.fire(event) + expect(rect.event()).toBe(event) + }) + }) }) - - - - - - |