Created
June 1, 2011 06:24
-
-
Save magnars/1001874 to your computer and use it in GitHub Desktop.
Reporting too few assertions?
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
watchForChanges: .... | |
1 test case, 4 tests, 1 assertion, 0 failures, 0 errors, 0 timeouts |
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
/*jslint indent: 2, onevar: false, undef: true */ | |
/*globals module, require */ | |
var buster = require("buster"); | |
var assert = buster.assert; | |
var watchForChanges = require('watch_for_changes'); | |
var fs = require('fs'); | |
var now = new Date(1); | |
var later = new Date(2); | |
buster.testCase("watchForChanges", { | |
setUp: function () { | |
this.stub(fs, 'watchFile'); | |
}, | |
"should be function": function () { | |
assert.isFunction(watchForChanges); | |
}, | |
"should use fs.watchFile": function () { | |
watchForChanges('file.txt'); | |
assert.calledWith(fs.watchFile, 'file.txt'); | |
}, | |
"should callback when changed": function () { | |
fs.watchFile.yields({mtime: now}, {mtime: later}); | |
var callback = this.stub(); | |
watchForChanges('', callback); | |
assert.called(callback); | |
}, | |
"should ignore when mtime is equal": function () { | |
fs.watchFile.yields({mtime: now}, {mtime: now}); | |
var callback = this.stub(); | |
watchForChanges('', callback); | |
assert.notCalled(callback); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment