Skip to content

Commit

Permalink
test: refactor test-domain
Browse files Browse the repository at this point in the history
Use assert.strictEqual() instead of assert.equal().

PR-URL: #9890
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
Johnny Reading authored and Fishrock123 committed Dec 5, 2016
1 parent 318a2db commit 6d5ded5
Showing 1 changed file with 34 additions and 33 deletions.
67 changes: 34 additions & 33 deletions test/parallel/test-domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,67 +31,67 @@ d.on('error', function(er) {

switch (er_message) {
case 'emitted':
assert.equal(er.domain, d);
assert.equal(er.domainEmitter, e);
assert.equal(er.domainThrown, false);
assert.strictEqual(er.domain, d);
assert.strictEqual(er.domainEmitter, e);
assert.strictEqual(er.domainThrown, false);
break;

case 'bound':
assert.ok(!er.domainEmitter);
assert.equal(er.domain, d);
assert.equal(er.domainBound, fn);
assert.equal(er.domainThrown, false);
assert.strictEqual(er.domain, d);
assert.strictEqual(er.domainBound, fn);
assert.strictEqual(er.domainThrown, false);
break;

case 'thrown':
assert.ok(!er.domainEmitter);
assert.equal(er.domain, d);
assert.equal(er.domainThrown, true);
assert.strictEqual(er.domain, d);
assert.strictEqual(er.domainThrown, true);
break;

case "ENOENT: no such file or directory, open 'this file does not exist'":
assert.equal(er.domain, d);
assert.equal(er.domainThrown, false);
assert.equal(typeof er.domainBound, 'function');
assert.strictEqual(er.domain, d);
assert.strictEqual(er.domainThrown, false);
assert.strictEqual(typeof er.domainBound, 'function');
assert.ok(!er.domainEmitter);
assert.equal(er.code, 'ENOENT');
assert.equal(er_path, 'this file does not exist');
assert.equal(typeof er.errno, 'number');
assert.strictEqual(er.code, 'ENOENT');
assert.strictEqual(er_path, 'this file does not exist');
assert.strictEqual(typeof er.errno, 'number');
break;

case
"ENOENT: no such file or directory, open 'stream for nonexistent file'":
assert.equal(typeof er.errno, 'number');
assert.equal(er.code, 'ENOENT');
assert.equal(er_path, 'stream for nonexistent file');
assert.equal(er.domain, d);
assert.equal(er.domainEmitter, fst);
assert.strictEqual(typeof er.errno, 'number');
assert.strictEqual(er.code, 'ENOENT');
assert.strictEqual(er_path, 'stream for nonexistent file');
assert.strictEqual(er.domain, d);
assert.strictEqual(er.domainEmitter, fst);
assert.ok(!er.domainBound);
assert.equal(er.domainThrown, false);
assert.strictEqual(er.domainThrown, false);
break;

case 'implicit':
assert.equal(er.domainEmitter, implicit);
assert.equal(er.domain, d);
assert.equal(er.domainThrown, false);
assert.strictEqual(er.domainEmitter, implicit);
assert.strictEqual(er.domain, d);
assert.strictEqual(er.domainThrown, false);
assert.ok(!er.domainBound);
break;

case 'implicit timer':
assert.equal(er.domain, d);
assert.equal(er.domainThrown, true);
assert.strictEqual(er.domain, d);
assert.strictEqual(er.domainThrown, true);
assert.ok(!er.domainEmitter);
assert.ok(!er.domainBound);
break;

case 'Cannot read property \'isDirectory\' of undefined':
assert.equal(er.domain, d);
assert.strictEqual(er.domain, d);
assert.ok(!er.domainEmitter);
assert.ok(!er.domainBound);
break;

case 'nextTick execution loop':
assert.equal(er.domain, d);
assert.strictEqual(er.domain, d);
assert.ok(!er.domainEmitter);
assert.ok(!er.domainBound);
break;
Expand All @@ -107,7 +107,8 @@ d.on('error', function(er) {

process.on('exit', function() {
console.error('exit', caught, expectCaught);
assert.equal(caught, expectCaught, 'caught the expected number of errors');
assert.strictEqual(caught, expectCaught,
'caught the expected number of errors');
console.log('ok');
});

Expand Down Expand Up @@ -172,7 +173,7 @@ expectCaught++;

// intercepted should never pass first argument to callback
function fn2(data) {
assert.equal(data, 'data', 'should not be null err argument');
assert.strictEqual(data, 'data', 'should not be null err argument');
}

bound = d.intercept(fn2);
Expand All @@ -181,8 +182,8 @@ bound(null, 'data');
// intercepted should never pass first argument to callback
// even if arguments length is more than 2.
function fn3(data, data2) {
assert.equal(data, 'data', 'should not be null err argument');
assert.equal(data2, 'data2', 'should not be data argument');
assert.strictEqual(data, 'data', 'should not be null err argument');
assert.strictEqual(data2, 'data2', 'should not be data argument');
}

bound = d.intercept(fn3);
Expand Down Expand Up @@ -225,14 +226,14 @@ expectCaught++;
var result = d.run(function() {
return 'return value';
});
assert.equal(result, 'return value');
assert.strictEqual(result, 'return value');


// check if the executed function take in count the applied parameters
result = d.run(function(a, b) {
return a + ' ' + b;
}, 'return', 'value');
assert.equal(result, 'return value');
assert.strictEqual(result, 'return value');


var fst = fs.createReadStream('stream for nonexistent file');
Expand Down

0 comments on commit 6d5ded5

Please sign in to comment.