From 4b2e055187f2f33d14f9e7573ce34b9333b553a3 Mon Sep 17 00:00:00 2001 From: Ulrich-Matthias Schäfer Date: Sun, 22 Feb 2015 14:27:45 +0100 Subject: Fixed Custom Events with data #317 Keeps the `registerEvent`-function only for consistency --- spec/spec/event.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'spec') 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) + }) }) + }) -- cgit v1.2.3