Skip to content

Commit c423aae

Browse files
committed
tests: add spec for .watch(pattern, fn)
1 parent d033358 commit c423aae

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
"pro": "protractor test/protractor/config.single.js",
3030
"pro-local": "node test/protractor/setup.js",
3131
"unit": "mocha --recursive test/specs --timeout 10000",
32-
"cover": "npm run env && npm run _cover",
33-
"_cover": "istanbul cover _mocha -- --timeout 10000 --recursive ./test/specs && istanbul-coveralls",
32+
"cover": "npm run env && npm run cover-local && npm run coveralls",
33+
"cover-local": "istanbul cover _mocha -- --timeout 10000 --recursive ./test/specs",
34+
"coveralls": "istanbul-coveralls",
3435
"pre-release": "npm test && npm run pro-local && npm run pro"
3536
},
3637
"dependencies": {

test/specs/api/watch.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,27 @@ var writeFileWait = function (name, content, cb) {
2121

2222
describe("API: .watch() - Public watch method", function () {
2323

24+
25+
it("Should allow arbitrary watchers with callback fn + no options when not connected to running instance", function (done) {
26+
27+
browserSync.reset();
28+
29+
var tempFile = path.join(outpath, "watch-func.txt");
30+
var bs = browserSync.create("test");
31+
32+
fs.writeFile(tempFile, tempFileContent, function () {
33+
34+
var watcher = bs.watch(tempFile, function (event, file) {
35+
assert.equal(event, "add");
36+
assert.equal(file, tempFile);
37+
watcher.close();
38+
done();
39+
});
40+
41+
writeFileWait(tempFile, tempFileContent + " changed");
42+
});
43+
});
44+
2445
it("Should allow arbitrary watchers with callback fn when not connected to running instance", function (done) {
2546

2647
browserSync.reset();

0 commit comments

Comments
 (0)