ngraph.events
Advanced tools
Comparing version 0.0.3 to 0.0.4
{ | ||
"name": "ngraph.events", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Basic events supoort for ngraph.js ", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "tap test/*.js" | ||
"test": "tap test/*.js", | ||
"cover": "istanbul cover --dir reports/coverage node_modules/argg test/*.js" | ||
}, | ||
@@ -23,4 +24,6 @@ "repository": { | ||
"devDependencies": { | ||
"tap": "~0.4.4" | ||
"argg": "0.0.2", | ||
"istanbul": "^0.4.2", | ||
"tap": "^5.7.0" | ||
} | ||
} |
@@ -52,3 +52,3 @@ ngraph.events | ||
install | ||
Install | ||
======= | ||
@@ -55,0 +55,0 @@ |
@@ -7,3 +7,3 @@ var test = require('tap').test, | ||
try { | ||
var subject = eventify({ | ||
eventify({ | ||
on: "I'm a dummy string, please don't wipe me out" | ||
@@ -16,1 +16,22 @@ }); | ||
}); | ||
test('Eventify does not allow falsy objects', function(t) { | ||
t.plan(1); | ||
try { | ||
eventify(false); | ||
} catch (e) { | ||
t.ok(true, 'Eventify should thrown an exception to protect your object'); | ||
} | ||
t.end(); | ||
}); | ||
test('Eventify does not allow to subscribe without function', function(t) { | ||
t.plan(1); | ||
var subject = eventify({}); | ||
try { | ||
subject.on('foo') | ||
} catch (e) { | ||
t.ok(true, 'Eventify should thrown an exception: no function is specified'); | ||
} | ||
t.end(); | ||
}); |
@@ -44,2 +44,3 @@ var test = require('tap').test, | ||
}); | ||
test('fire passes all arguments', function(t) { | ||
@@ -132,3 +133,2 @@ t.plan(2); | ||
var subject = eventify({}); | ||
var context = {}; | ||
var onFoo = function (){ | ||
@@ -146,2 +146,34 @@ t.ok(false, "off() did not properly removed the handler"); | ||
test('"off" does not harm when no such event', function(t) { | ||
t.plan(1); | ||
var subject = eventify({}); | ||
var onFoo = function () { | ||
t.ok(true, "off() called just one"); | ||
}; | ||
subject.on('foo', onFoo); | ||
subject.off('bar', onFoo); | ||
subject.fire('foo'); | ||
subject.fire('bar'); | ||
}); | ||
test('"off" can remove by function', function(t) { | ||
t.plan(1); | ||
var subject = eventify({}); | ||
var onFooYes = function () { | ||
t.ok(true, "off() called just one"); | ||
}; | ||
var onFooNo = function () { | ||
t.ok(false, "off() should not be called"); | ||
}; | ||
subject.on('foo', onFooYes); | ||
subject.on('foo', onFooNo); | ||
subject.off('foo', onFooNo); | ||
subject.fire('foo'); | ||
}); | ||
test('eventify can chain', function(t) { | ||
@@ -148,0 +180,0 @@ var subject = {}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
11258
250
3