Files
archived-nodemon/test/lib/require.test.js
Remy Sharp 13770da9f3 Fixed nodemon.once. Add config.run. Tests not 100% passing
Something weird is happening with required nodemon and re-running lots of times, that somehow resets the config. I know it's due to my tests, but I'm unsure which one is actually causing the damn issue. Anyway, bed for me, it's almost 2am. Sod this for a game of cricket.
2014-01-05 01:42:37 +00:00

59 lines
1.5 KiB
JavaScript

'use strict';
/*global describe:true, it: true, afterEach: true */
var nodemon = require('../../lib/'),
assert = require('assert'),
path = require('path'),
touch = require('touch'),
appjs = path.resolve(__dirname, '..', 'fixtures', 'app.js');
describe('require-able', function () {
afterEach(function (done) {
nodemon.once('exit', function () {
nodemon.reset();
done();
}).emit('quit');
});
it('should know nodemon has been required', function () {
assert(nodemon.config.required, 'nodemon has required property');
});
it('should restart on file change', function (done) {
var restarted = false;
nodemon({ script: appjs, verbose: true }).on('start', function () {
setTimeout(function () {
touch.sync(appjs);
}, 1000);
}).on('restart', function () {
restarted = true;
nodemon.emit('quit');
}).on('quit', function () {
assert(restarted, 'nodemon restarted and quit properly');
nodemon.reset();
done();
}).on('log', function (event) {
// console.log(event.message);
});
});
it('should be restartable', function (done) {
var restarted = false;
nodemon(appjs).on('start', function () {
setTimeout(function () {
nodemon.restart();
}, 1000);
}).on('restart', function () {
restarted = true;
nodemon.emit('quit');
}).on('quit', function () {
assert(restarted);
nodemon.reset();
// unbind events for testing again
done();
});
});
});