Skip to content

Instantly share code, notes, and snippets.

@magnars
Created June 1, 2011 06:24
Show Gist options
  • Save magnars/1001874 to your computer and use it in GitHub Desktop.
Save magnars/1001874 to your computer and use it in GitHub Desktop.
Reporting too few assertions?
watchForChanges: ....
1 test case, 4 tests, 1 assertion, 0 failures, 0 errors, 0 timeouts
/*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