Skip to content

Commit

Permalink
test: fix failing assertion
Browse files Browse the repository at this point in the history
One test did not cause an assertion. By changing the test to use
`assert.throws()` all tests have to throw, otherwise the test will
fail.

PR-URL: #25250
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
BridgeAR committed Jan 10, 2019
1 parent dfaa61f commit 8c0290e
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions test/parallel/test-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,16 +257,14 @@ const circular = { y: 1 };
circular.x = circular;

function testAssertionMessage(actual, expected, msg) {
try {
assert.strictEqual(actual, '');
} catch (e) {
assert.strictEqual(
e.message,
msg || strictEqualMessageStart +
`+ actual - expected\n\n+ ${expected}\n- ''`
);
assert.ok(e.generatedMessage, 'Message not marked as generated');
}
assert.throws(
() => assert.strictEqual(actual, ''),
{
generatedMessage: true,
message: msg || strictEqualMessageStart +
`+ actual - expected\n\n+ ${expected}\n- ''`
}
);
}

function testShortAssertionMessage(actual, expected) {
Expand All @@ -280,7 +278,7 @@ testShortAssertionMessage(false, 'false');
testShortAssertionMessage(100, '100');
testShortAssertionMessage(NaN, 'NaN');
testShortAssertionMessage(Infinity, 'Infinity');
testShortAssertionMessage('', '""');
testShortAssertionMessage('a', '"a"');
testShortAssertionMessage('foo', '\'foo\'');
testShortAssertionMessage(0, '0');
testShortAssertionMessage(Symbol(), 'Symbol()');
Expand Down

0 comments on commit 8c0290e

Please sign in to comment.