Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed bug where multiple calls are made on same callback
- Loading branch information
1 parent
2e7732a
commit 2f3be4f
Showing
3 changed files
with
75 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require('../cupoftea'); | ||
var fs = require('fs'); | ||
var assert = require('assert'); | ||
var _ = require('underscore'); | ||
|
||
spec('set', function () { | ||
var set = {}; | ||
|
||
spec('adding item', function () { | ||
set[0] = true; | ||
|
||
spec('and retrieving it', function () { | ||
assert.ok(set[0]); | ||
}); | ||
|
||
spec('and then unsetting it', function () { | ||
set[0] = undefined; | ||
assert.ok(!set[0]); | ||
}); | ||
}); | ||
|
||
spec('can add items and enumerate items', function () { | ||
set[0] = true; | ||
set[2] = true; | ||
delete set[2]; | ||
set[3] = true; | ||
|
||
var keys = _.keys(set); | ||
assert.ok(_(keys).contains('0')); | ||
assert.ok(_(keys).contains('3')); | ||
assert.equal(keys.length, 2); | ||
}); | ||
|
||
spec('getting item not set', function () { | ||
assert.ok(!set[0]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require('../cupoftea'); | ||
var fs = require('fs'); | ||
var assert = require('assert'); | ||
|
||
spec('multiple callbacks', function () { | ||
var i = 1; | ||
setInterval(shouldCall(function () { | ||
console.log('first'); | ||
}), 100); | ||
|
||
setTimeout(shouldCall(function () { | ||
console.log('second'); | ||
}), 1000); | ||
}); |