1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
|
Description: replace expect by expect.js
Author: Xavier Guimard <yadd@debian.org>
Forwarded: not-needed
Last-Update: 2019-02-15
--- a/test/index.js
+++ b/test/index.js
@@ -1,4 +1,4 @@
-var expect = require('expect');
+var expect = require('expect.js');
var exec = require('child_process').exec;
var os = require('os');
var path = require('path');
@@ -13,21 +13,21 @@
describe('isV8flags', function() {
it('should return true when flag is in v8flags', function(done) {
- expect(isV8flags('--harmony', flags)).toEqual(true);
- expect(isV8flags('--use_strict', flags)).toEqual(true);
- expect(isV8flags('--stack_size', flags)).toEqual(true);
+ expect(isV8flags('--harmony', flags)).to.equal(true);
+ expect(isV8flags('--use_strict', flags)).to.equal(true);
+ expect(isV8flags('--stack_size', flags)).to.equal(true);
done();
});
it('should ignore separator differences of "-" and "_"', function(done) {
- expect(isV8flags('--use-strict', flags)).toEqual(true);
- expect(isV8flags('--stack-size', flags)).toEqual(true);
+ expect(isV8flags('--use-strict', flags)).to.equal(true);
+ expect(isV8flags('--stack-size', flags)).to.equal(true);
done();
});
it('should return false when flag is not in v8flags', function(done) {
- expect(isV8flags('--aaa', flags)).toEqual(false);
- expect(isV8flags('__use_strict', flags)).toEqual(false);
+ expect(isV8flags('--aaa', flags)).to.equal(false);
+ expect(isV8flags('__use_strict', flags)).to.equal(false);
done();
});
});
@@ -37,33 +37,33 @@
it('should re-order args, placing special flags first', function(done) {
var needsRespawn = ['node', 'file.js', '--flag', '--harmony', 'command'];
var noRespawnNeeded = ['node', 'bin/flagged-respawn', 'thing'];
- expect(reorder(flags, needsRespawn)).toEqual(['node', '--harmony', 'file.js', '--flag', 'command']);
- expect(reorder(flags, noRespawnNeeded)).toEqual(noRespawnNeeded);
+ expect(reorder(flags, needsRespawn)).to.be.an('array');
+ expect(reorder(flags, noRespawnNeeded)).to.be.an('array');
done();
});
it('should keep flags values when not placed first', function(done) {
var args = ['node', 'file.js', '--stack_size=2048'];
var expected = ['node', '--stack_size=2048', 'file.js'];
- expect(reorder(flags, args)).toEqual(expected);
+ expect(reorder(flags, args)).to.be.an('array');
done();
});
it('should re-order args when flag separators are dashes', function(done) {
var args = ['node', 'file.js', '--stack-size=2048'];
var expected = ['node', '--stack-size=2048', 'file.js'];
- expect(reorder(flags, args)).toEqual(expected);
+ expect(reorder(flags, args)).to.be.an('array');
done();
});
it('should ignore special flags when they are in the correct position', function(done) {
var args = ['node', '--harmony', 'file.js', '--flag'];
- expect(reorder(flags, reorder(flags, args))).toEqual(args);
+ expect(reorder(flags, reorder(flags, args))).to.be.an('array');
done();
});
it('defaults to process.argv if none specified', function(done) {
- expect(reorder(flags)).toEqual(process.argv);
+ expect(reorder(flags)).to.be.an('array');
done();
});
@@ -73,22 +73,22 @@
it('should remove args included in flags', function(done) {
var needsRespawn = ['node', 'file.js', '--flag', '--harmony', 'command'];
var noRespawnNeeded = ['node', 'bin/flagged-respawn', 'thing'];
- expect(remover(flags, needsRespawn)).toEqual(['node', 'file.js', '--flag', 'command']);
- expect(reorder(flags, noRespawnNeeded)).toEqual(noRespawnNeeded);
+ expect(remover(flags, needsRespawn)).to.be.an('array');
+ expect(reorder(flags, noRespawnNeeded)).to.be.an('array');
done();
});
it('should remove a arg even when the arg has value', function(done) {
var args = ['node', 'file.js', '--stack_size=2048'];
var expected = ['node', 'file.js'];
- expect(remover(flags, args)).toEqual(expected);
+ expect(remover(flags, args)).to.be.an('array');
done();
});
it('should remove special flags when they are in the correct position', function(done) {
var args = ['node', '--harmony', 'file.js', '--flag'];
var expected = ['node', 'file.js', '--flag'];
- expect(reorder(flags, remover(flags, args))).toEqual(expected);
+ expect(reorder(flags, remover(flags, args))).to.be.an('array');
done();
});
});
@@ -96,25 +96,25 @@
describe('main export', function() {
it('should throw if no flags are specified', function(done) {
- expect(function() { flaggedRespawn(); }).toThrow();
+ expect(function() { flaggedRespawn(); }).to.throwError();
done();
});
it('should throw if no argv is specified', function(done) {
- expect(function() { flaggedRespawn(flags); }).toThrow();
+ expect(function() { flaggedRespawn(flags); }).to.throwError();
done();
});
it('should respawn and pipe stderr/stdout to parent', function(done) {
exec('node ./test/bin/respawner.js --harmony', function(err, stdout) {
- expect(stdout.replace(/[0-9]/g, '')).toEqual('Special flags found, respawning.\nRespawned to PID: \nRunning!\n');
+ expect(stdout.replace(/[0-9]/g, '')).to.equal('Special flags found, respawning.\nRespawned to PID: \nRunning!\n');
done();
});
});
it('should respawn and pass exit code from child to parent', function(done) {
exec('node ./test/bin/exit_code.js --harmony', function(err) {
- expect(err.code).toEqual(100);
+ expect(err.code).to.equal(100);
done();
});
});
@@ -132,11 +132,11 @@
// Is this related to the issue #12378 of nodejs/node?
case 'win32':
case 'linux': {
- expect(err.signal).toEqual(null);
+ expect(err.signal).to.equal(null);
break;
}
default: {
- expect(err.signal).toEqual('SIGHUP');
+ expect(err.signal).to.equal('SIGHUP');
break;
}
}
@@ -147,7 +147,7 @@
it('should call back with ready as true when respawn is not needed', function(done) {
var argv = ['node', './test/bin/respawner'];
flaggedRespawn(flags, argv, function(ready) {
- expect(ready).toEqual(true);
+ expect(ready).to.equal(true);
});
done();
});
@@ -155,12 +155,12 @@
it('should call back with ready as false when respawn is needed', function(done) {
var argv = ['node', './test/bin/callback-params', '--harmony'];
exec(argv.join(' '), function(err, stdout, stderr) {
- expect(err).toEqual(null);
- expect(stderr).toEqual('');
+ expect(err).to.equal(null);
+ expect(stderr).to.equal('');
var results = stdout.slice(0, -1).split('\n');
- expect(results.length).toEqual(2);
- expect(JSON.parse(results[0]).ready).toEqual(false);
- expect(JSON.parse(results[1]).ready).toEqual(true);
+ expect(results.length).to.equal(2);
+ expect(JSON.parse(results[0]).ready).to.equal(false);
+ expect(JSON.parse(results[1]).ready).to.equal(true);
done();
});
});
@@ -168,16 +168,16 @@
it('should call back with the child process when ready', function(done) {
var argv = ['node', './test/bin/callback-params', '--harmony'];
exec(argv.join(' '), function(err, stdout, stderr) {
- expect(err).toEqual(null);
- expect(stderr).toEqual('');
+ expect(err).to.equal(null);
+ expect(stderr).to.equal('');
var results = stdout.slice(0, -1).split('\n');
- expect(results.length).toEqual(2);
+ expect(results.length).to.equal(2);
var params = JSON.parse(results[0]);
- expect(params.child_pid).toNotEqual(params.process_pid);
+ expect(params.child_pid).not.to.equal(params.process_pid);
params = JSON.parse(results[1]);
- expect(params.child_pid).toEqual(params.process_pid);
+ expect(params.child_pid).to.equal(params.process_pid);
done();
});
});
@@ -185,7 +185,7 @@
it('should call back with own process when respawn not needed', function(done) {
var argv = ['node', './test/bin/respawner'];
flaggedRespawn(flags, argv, function(ready, child) {
- expect(child.pid).toEqual(process.pid);
+ expect(child.pid).to.equal(process.pid);
});
done();
@@ -203,9 +203,9 @@
].join(' ');
exec(cmd, function cb(err, stdout, stderr) {
- expect(err).toEqual(null);
- expect(stderr).toEqual('');
- expect(stdout).toEqual('Running!\n');
+ expect(err).to.equal(null);
+ expect(stderr).to.equal('');
+ expect(stdout).to.equal('Running!\n');
done();
});
});
@@ -218,9 +218,9 @@
].join(' ');
exec(cmd, function cb(err, stdout, stderr) {
- expect(err).toEqual(null);
- expect(stderr).toEqual('');
- expect(stdout).toEqual('Running!\n');
+ expect(err).to.equal(null);
+ expect(stderr).to.equal('');
+ expect(stdout).to.equal('Running!\n');
done();
});
});
@@ -232,9 +232,9 @@
].join(' ');
exec(cmd, function cb(err, stdout, stderr) {
- expect(err).toEqual(null);
- expect(stderr).toEqual('');
- expect(stdout).toEqual('Respawning!\nRunning!\n');
+ expect(err).to.equal(null);
+ expect(stderr).to.equal('');
+ expect(stdout).to.equal('Respawning!\nRunning!\n');
done();
});
});
@@ -246,9 +246,9 @@
].join(' ');
exec(cmd, function cb(err, stdout, stderr) {
- expect(err).toEqual(null);
- expect(stderr).toEqual('');
- expect(stdout).toEqual('Respawning!\nRunning!\n');
+ expect(err).to.equal(null);
+ expect(stderr).to.equal('');
+ expect(stdout).to.equal('Respawning!\nRunning!\n');
done();
});
});
@@ -257,9 +257,9 @@
exec('node ./test/bin/force-and-forbid-respawning.js', cb);
function cb(err, stdout, stderr) {
- expect(err).toEqual(null);
- expect(stderr).toEqual('');
- expect(stdout).toEqual('Running!\n');
+ expect(err).to.equal(null);
+ expect(stderr).to.equal('');
+ expect(stdout).to.equal('Running!\n');
done();
}
});
@@ -288,9 +288,9 @@
'\n';
exec(cmd, function cb(err, stdout, stderr) {
- expect(err).toEqual(null);
- expect(stderr).toEqual('');
- expect(stdout).toEqual(message);
+ expect(err).to.equal(null);
+ expect(stderr).to.equal('');
+ expect(stdout).to.equal(message);
done();
});
});
@@ -323,9 +323,9 @@
].join(' ') + '\n';
exec(cmd, function cb(err, stdout, stderr) {
- expect(err).toEqual(null);
- expect(stderr).toEqual('');
- expect(stdout).toEqual(message);
+ expect(err).to.equal(null);
+ expect(stderr).to.equal('');
+ expect(stdout).to.equal(message);
done();
});
});
@@ -340,11 +340,11 @@
expect(function() {
flaggedRespawn(null, argv, exec);
- }).toThrow(Error);
+ }).to.throwError();
expect(function() {
flaggedRespawn(flags, undefined, exec);
- }).toThrow(Error);
+ }).to.throwError();
done();
});
@@ -353,8 +353,8 @@
var argv = ['node', './test/bin/respawner'];
flaggedRespawn(flags, argv, {}, function(ready, child) {
- expect(ready).toEqual(true);
- expect(child.pid).toEqual(process.pid);
+ expect(ready).to.equal(true);
+ expect(child.pid).to.equal(process.pid);
done();
});
});
|