mirror of
https://github.com/SrIzan10/nodemon.git
synced 2026-05-01 10:55:09 +00:00
57 lines
1.5 KiB
JavaScript
57 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 (){
|
|
nodemon.emit('quit');
|
|
nodemon.removeAllListners();
|
|
});
|
|
|
|
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.removeAllListners();
|
|
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);
|
|
// unbind events for testing again
|
|
nodemon.removeAllListners();
|
|
done();
|
|
});
|
|
});
|
|
|
|
});
|