vigil
Version:
Simple, efficient file watching.
71 lines (63 loc) • 1.88 kB
JavaScript
// Generated by CoffeeScript 1.10.0
var fs, os, request, should, vigil;
fs = require('fs');
os = require('os');
request = require('request');
should = (require('chai')).should();
vigil = require('../lib');
describe('vigil', function() {
describe('#walk', function() {
return it('should find all files and directories in test dir', function(done) {
var found;
found = 0;
return vigil.walk('./test/assets', function(filename, stats) {
if (++found === 5) {
return done();
}
});
});
});
describe('#vm', function() {
return it('should find modules as they are required by node', function(done) {
var found;
found = 0;
vigil.vm(function(filename, stats) {
if (++found === 2) {
return done();
}
});
return require('../test/assets/test-module');
});
});
describe('#watch', function() {
return it('should detect filechanges', function(done) {
var found;
found = 0;
vigil.watch('./test/assets', function(filename, stats, isModule) {
if (os.platform() === 'darwin') {
if (++found === 2) {
return done();
}
} else {
return done();
}
});
require('../test/assets/test-module-2');
fs.writeFileSync('./test/assets/test-module-2', '');
return fs.writeFileSync('./test/assets/2/3', '');
});
});
return describe('#run', function() {
return it('should run a server module and reload on changes', function(done) {
return vigil.run(function() {
return require('./test/assets/test-server');
}, function() {
return request('http://localhost:3333', function(err, res, body) {
body.should.equal('test');
return done();
});
});
});
});
});
//# sourceMappingURL=vigil.js.map