test: add tests to assert.ok and improve coverage
Refs: https://coverage.nodejs.org/coverage-1a4f27ae21698d0c/lib/assert.js.html#L364 PR-URL: https://github.com/nodejs/node/pull/28355 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
parent
26b048effb
commit
6e9d795642
@ -44,6 +44,19 @@ assert.ok(a.AssertionError.prototype instanceof Error,
|
||||
assert.throws(() => a(false), a.AssertionError, 'ok(false)');
|
||||
assert.throws(() => a.ok(false), a.AssertionError, 'ok(false)');
|
||||
|
||||
// Throw message if the message is instanceof Error.
|
||||
{
|
||||
let threw = false;
|
||||
try {
|
||||
assert.ok(false, new Error('ok(false)'));
|
||||
} catch (e) {
|
||||
threw = true;
|
||||
assert.ok(e instanceof Error);
|
||||
}
|
||||
assert.ok(threw, 'Error: ok(false)');
|
||||
}
|
||||
|
||||
|
||||
a(true);
|
||||
a('test', 'ok(\'test\')');
|
||||
a.ok(true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user