summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2015-06-17 15:55:32 +0200
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2015-06-17 15:55:32 +0200
commit0d6459729c2508d2631894b004d74961fe99d334 (patch)
treee8b2ec0b40c48f72e385efc8b2f8c29cdd2c20f4 /spec
parent71c984a986e1c0980ce0a6eb5626dda989cfa428 (diff)
downloadsvg.js-0d6459729c2508d2631894b004d74961fe99d334.tar.gz
svg.js-0d6459729c2508d2631894b004d74961fe99d334.zip
Events, Spec update, readme
Events can now be detached with only specifying the namespace (`el.off('.namespace')`) `el.fire()` now accepts event-objects as parameter (like mouseevents)
Diffstat (limited to 'spec')
-rw-r--r--spec/spec/event.js16
-rw-r--r--spec/spec/fx.js3
2 files changed, 16 insertions, 3 deletions
diff --git a/spec/spec/event.js b/spec/spec/event.js
index cb6c4ef..678c7b9 100644
--- a/spec/spec/event.js
+++ b/spec/spec/event.js
@@ -394,9 +394,18 @@ describe('Event', function() {
expect(SVG.listeners[SVG.handlerMap.indexOf(rect.node)]['event']['namespace'][action]).toBeUndefined()
})
+ it('detaches all listeners for a specific namespace', function() {
+ rect.on('event', action)
+ rect.on('event.namespace', function() { butter = 'melting'; })
+ rect.off('.namespace')
+
+ dispatchEvent(rect, 'event')
+ expect(toast).toBe('ready')
+ expect(butter).toBeNull()
+ })
it('detaches all listeners for an event without a listener given', function() {
rect.on('event', action)
- rect.on('event.namespace', function() { butter = 'melting'; console.log('called'); })
+ rect.on('event.namespace', function() { butter = 'melting'; })
rect.off('event')
dispatchEvent(rect, 'event')
@@ -440,6 +449,11 @@ describe('Event', function() {
expect(fruitsInDetail).not.toBe(null)
expect(fruitsInDetail.apple).toBe(1)
})
+ it('fires my own event', function() {
+ toast = null
+ rect.fire(new CustomEvent('event'))
+ expect(toast).toBe('ready')
+ })
})
diff --git a/spec/spec/fx.js b/spec/spec/fx.js
index 2ae372d..f1171f5 100644
--- a/spec/spec/fx.js
+++ b/spec/spec/fx.js
@@ -46,13 +46,12 @@ describe('FX', function() {
setTimeout(function(){
var ctm = rect.ctm();
- console.log(ctm);
expect(ctm.a).toBeLessThan(1)
expect(ctm.b).toBeGreaterThan(0)
expect(ctm.c).toBeLessThan(0)
expect(ctm.d).toBeGreaterThan(0)
expect(ctm.e).toBeGreaterThan(0)
- expect(ctm.f).toBeGreatherThan(0)
+ expect(ctm.f).toBeGreaterThan(0)
}, 250)
})