Skip to content

Commit

Permalink
test: split require tests
Browse files Browse the repository at this point in the history
  • Loading branch information
remy committed Apr 8, 2020
1 parent 33ae6da commit ee92ee4
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 24 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions test/lib/require-restartable.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'use strict';
/*global describe:true, it: true, afterEach: true */
var nodemon = require('../../lib/'),
assert = require('assert'),
path = require('path'),
touch = require('touch'),
utils = require('../utils'),
appjs = path.resolve(__dirname, '..', 'fixtures', 'app.js'),
envjs = path.resolve(__dirname, '..', 'fixtures', 'env.js');

describe('require-able', function () {
var pwd = process.cwd(),
oldhome = utils.home;

afterEach(function () {
process.chdir(pwd);
utils.home = oldhome;
});

beforeEach(function (done) {
// move to the fixtures directory to allow for config loading
process.chdir(path.resolve(pwd, 'test'));
utils.home = path.resolve(pwd, ['test'].join(path.sep));

nodemon.reset(done);
});


it('should restart on file change', function (done) {
var restarted = false;

utils.port++;
nodemon({ script: appjs, verbose: true, env: { PORT: utils.port } }).on('start', function () {
setTimeout(function () {
touch.sync(appjs);
}, 1000);
}).on('start', function() {
if (restarted) {
setTimeout(function() { nodemon.emit('quit') });
}
}).on('restart', function () {
restarted = true;
}).on('quit', function () {
assert(restarted, 'nodemon restarted and quit properly');
nodemon.reset(done);
}).on('log', function (event) {
// console.log(event.message);
});
});

});
22 changes: 0 additions & 22 deletions test/lib/require.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,6 @@ describe('require-able', function () {
assert(nodemon.config.required, 'nodemon has required property');
});

it('should restart on file change', function (done) {
var restarted = false;

utils.port++;
nodemon({ script: appjs, verbose: true, env: { PORT: utils.port } }).on('start', function () {
setTimeout(function () {
touch.sync(appjs);
}, 1000);
}).on('start', function() {
if (restarted) {
setTimeout(function() { nodemon.emit('quit') });
}
}).on('restart', function () {
restarted = true;
}).on('quit', function () {
assert(restarted, 'nodemon restarted and quit properly');
nodemon.reset(done);
}).on('log', function (event) {
// console.log(event.message);
});
});

it('should restart on file change with custom signal', function (done) {
var restarted = false;

Expand Down

0 comments on commit ee92ee4

Please sign in to comment.