diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2018-12-28 18:08:03 +0100 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-01-10 03:26:51 +0100 |
commit | 8c0290e0543af85ac82c243987d5996c00a16cc6 (patch) | |
tree | aca365ec9dbd5d318832e50398a0b8ee4b896df7 /test/parallel/test-assert.js | |
parent | dfaa61fa18b5008912583ee8e00ebbd4f96debf6 (diff) | |
download | android-node-v8-8c0290e0543af85ac82c243987d5996c00a16cc6.tar.gz android-node-v8-8c0290e0543af85ac82c243987d5996c00a16cc6.tar.bz2 android-node-v8-8c0290e0543af85ac82c243987d5996c00a16cc6.zip |
test: fix failing assertion
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: https://github.com/nodejs/node/pull/25250
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-assert.js')
-rw-r--r-- | test/parallel/test-assert.js | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index bf2da0b5dd..a7c37e8fb3 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -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) { @@ -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()'); |