From abd94a7f5a50f43c797a11b53549ae48fff667c3 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 10 Oct 2016 03:43:44 +0200 Subject: add node_modules to address #4364 --- .../glob-watcher/test/fixtures/test.coffee | 1 + node_modules/glob-watcher/test/main.js | 87 ++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 node_modules/glob-watcher/test/fixtures/test.coffee create mode 100644 node_modules/glob-watcher/test/main.js (limited to 'node_modules/glob-watcher/test') diff --git a/node_modules/glob-watcher/test/fixtures/test.coffee b/node_modules/glob-watcher/test/fixtures/test.coffee new file mode 100644 index 000000000..4be3c4508 --- /dev/null +++ b/node_modules/glob-watcher/test/fixtures/test.coffee @@ -0,0 +1 @@ +test test \ No newline at end of file diff --git a/node_modules/glob-watcher/test/main.js b/node_modules/glob-watcher/test/main.js new file mode 100644 index 000000000..2903e8f8a --- /dev/null +++ b/node_modules/glob-watcher/test/main.js @@ -0,0 +1,87 @@ +var watch = require('../'); +var should = require('should'); +var path = require('path'); +var fs = require('fs'); +var rimraf = require('rimraf'); +var mkdirp = require('mkdirp'); + +require('mocha'); + +describe('glob-watcher', function() { + it('should return a valid file struct via EE', function(done) { + var expectedName = path.join(__dirname, "./fixtures/stuff/temp.coffee"); + var fname = path.join(__dirname, "./fixtures/**/temp.coffee"); + mkdirp.sync(path.dirname(expectedName)); + fs.writeFileSync(expectedName, "testing"); + + var watcher = watch(fname); + watcher.on('change', function(evt) { + should.exist(evt); + should.exist(evt.path); + should.exist(evt.type); + evt.type.should.equal('changed'); + evt.path.should.equal(expectedName); + watcher.end(); + }); + watcher.on('end', function(){ + rimraf.sync(expectedName); + done(); + }); + setTimeout(function(){ + fs.writeFileSync(expectedName, "test test"); + }, 125); + }); + + it('should emit nomatch via EE', function(done) { + var fname = path.join(__dirname, "./doesnt_exist_lol/temp.coffee"); + + var watcher = watch(fname); + watcher.on('nomatch', function() { + done(); + }); + }); + + it('should return a valid file struct via callback', function(done) { + var expectedName = path.join(__dirname, "./fixtures/stuff/test.coffee"); + var fname = path.join(__dirname, "./fixtures/**/test.coffee"); + mkdirp.sync(path.dirname(expectedName)); + fs.writeFileSync(expectedName, "testing"); + + var watcher = watch(fname, function(evt) { + should.exist(evt); + should.exist(evt.path); + should.exist(evt.type); + evt.type.should.equal('changed'); + evt.path.should.equal(expectedName); + watcher.end(); + }); + + watcher.on('end', function(){ + rimraf.sync(expectedName); + done(); + }); + setTimeout(function(){ + fs.writeFileSync(expectedName, "test test"); + }, 200); + }); + + it('should not return a non-matching file struct via callback', function(done) { + var expectedName = path.join(__dirname, "./fixtures/test123.coffee"); + var fname = path.join(__dirname, "./fixtures/**/test.coffee"); + mkdirp.sync(path.dirname(expectedName)); + fs.writeFileSync(expectedName, "testing"); + + var watcher = watch(fname, function(evt) { + throw new Error("Should not have been called! "+evt.path); + }); + + setTimeout(function(){ + fs.writeFileSync(expectedName, "test test"); + }, 200); + + setTimeout(function(){ + rimraf.sync(expectedName); + done(); + }, 1500); + }); +}); \ No newline at end of file -- cgit v1.2.3