aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2015-02-22 14:27:45 +0100
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2015-02-22 14:27:45 +0100
commit4b2e055187f2f33d14f9e7573ce34b9333b553a3 (patch)
tree747caedf93b1e3b98c34d8efbc7d28aa50494e71 /spec
parent6bb7b47b00205509917237c6c175c8cf0d5bcd71 (diff)
downloadsvg.js-4b2e055187f2f33d14f9e7573ce34b9333b553a3.tar.gz
svg.js-4b2e055187f2f33d14f9e7573ce34b9333b553a3.zip
Fixed Custom Events with data #317
Keeps the `registerEvent`-function only for consistency
Diffstat (limited to 'spec')
-rw-r--r--spec/spec/event.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/spec/spec/event.js b/spec/spec/event.js
index 45db382..403c795 100644
--- a/spec/spec/event.js
+++ b/spec/spec/event.js
@@ -1,9 +1,11 @@
describe('Event', function() {
var rect, context
, toast = null
- , action = function() {
+ , fruitsInDetail,
+ action = function(e) {
toast = 'ready'
context = this
+ fruitsInDetail = e.detail
}
beforeEach(function() {
@@ -287,7 +289,8 @@ describe('Event', function() {
})
}
-
+/* This function is no longer needed and only exists for compatibility issues */
+/*
describe('registerEvent()', function() {
it('creates a new custom event and stores it in the events object', function() {
expect(SVG.events['my:event']).toBeUndefined()
@@ -295,7 +298,7 @@ describe('Event', function() {
expect(SVG.events['my:event'] instanceof CustomEvent).toBeTruthy()
})
})
-
+*/
describe('on()', function() {
beforeEach(function() {
@@ -369,12 +372,19 @@ describe('Event', function() {
expect(toast).toBeNull()
rect.fire('my:event')
expect(toast).toBe('ready')
+ expect(fruitsInDetail).toBe(null)
})
it('returns the called element', function() {
expect(rect.fire('my:event')).toBe(rect)
})
-
+ it('fires event with additional data', function() {
+ expect(fruitsInDetail).toBeNull()
+ rect.fire('my:event', {apple:1})
+ expect(fruitsInDetail).not.toBe(null)
+ expect(fruitsInDetail.apple).toBe(1)
+ })
})
+
})