Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update unit test case.

  • Loading branch information...
commit b598f06ac9575409d97cf9a8c3aa75c6b79ccecd 1 parent 9cefd08
@JacksonTian authored
Showing with 30 additions and 2 deletions.
  1. +1 −1  package.json
  2. +15 −1 test/eventproxy.test.js
  3. +14 −0 test/test.js
View
2  package.json
@@ -20,5 +20,5 @@
"url": "git://github.com/JacksonTian/eventproxy.git"
},
"main" : "eventproxy.js",
- "version" : "0.1.0"
+ "version" : "0.1.1"
}
View
16 test/eventproxy.test.js 100644 → 100755
@@ -167,7 +167,21 @@ module.exports = {
ep.trigger('event', n);
assert.deepEqual(counter, 1, 'counter should have only been incremented once.');
},
-
+
+ 'after, 1 time': function() {
+ var ep = EventProxy.create();
+
+ var counter = 0;
+ ep.after('event', 1, function(data) {
+ assert.deepEqual(data.length, 1);
+ assert.deepEqual(data[0], "1 time");
+ counter += 1;
+ });
+
+ ep.trigger('event', "1 time");
+ assert.deepEqual(counter, 1, 'counter should have only been incremented once.');
+ },
+
'after, 0 time': function () {
var obj = new EventProxy();
var counter = 0;
View
14 test/test.js
@@ -126,6 +126,20 @@ test("EventProxy - after, 5 times", function () {
equals(counter, 1, 'counter should have only been incremented once.');
});
+test("EventProxy - after, 1 time", function() {
+ var obj = EventProxy.create();
+
+ var counter = 0;
+ obj.after('event', 1, function(data) {
+ equals(data.length, 1, "The data length should be 1.");
+ equals(data[0], "1 time", "The item should be 1 time.");
+ counter += 1;
+ });
+
+ obj.trigger('event', "1 time");
+ equals(counter, 1, 'counter should have only been incremented once.');
+})
+
test("EventProxy - after, 0 time", function () {
var obj = new EventProxy();
var counter = 0;
Please sign in to comment.
Something went wrong with that request. Please try again.