Skip to content

Commit 603afe2

Browse files
committed
doc: fix some recent nits in assert.md
* add missing bottom reference * fix possible typos * fix ABC-order in references and sections PR-URL: #19284 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 599337f commit 603afe2

File tree

1 file changed

+38
-37
lines changed

1 file changed

+38
-37
lines changed

doc/api/assert.md

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ rejected. See [`assert.rejects()`][] for more details.
326326
When `assert.doesNotReject()` is called, it will immediately call the `block`
327327
function, and awaits for completion.
328328

329-
Besides the async nature to await the completion behaves identical to
329+
Besides the async nature to await the completion behaves identically to
330330
[`assert.doesNotThrow()`][].
331331

332332
```js
@@ -844,40 +844,6 @@ assert(0);
844844
// assert(0)
845845
```
846846

847-
## assert.strictEqual(actual, expected[, message])
848-
<!-- YAML
849-
added: v0.1.21
850-
changes:
851-
- version: REPLACEME
852-
pr-url: https://github.com/nodejs/node/pull/17003
853-
description: Used comparison changed from Strict Equality to `Object.is()`
854-
-->
855-
* `actual` {any}
856-
* `expected` {any}
857-
* `message` {any}
858-
859-
Tests strict equality between the `actual` and `expected` parameters as
860-
determined by the [SameValue Comparison][].
861-
862-
```js
863-
const assert = require('assert').strict;
864-
865-
assert.strictEqual(1, 2);
866-
// AssertionError: 1 strictEqual 2
867-
868-
assert.strictEqual(1, 1);
869-
// OK
870-
871-
assert.strictEqual(1, '1');
872-
// AssertionError: 1 strictEqual '1'
873-
```
874-
875-
If the values are not strictly equal, an `AssertionError` is thrown with a
876-
`message` property set equal to the value of the `message` parameter. If the
877-
`message` parameter is undefined, a default error message is assigned. If the
878-
`message` parameter is an instance of an [`Error`][] then it will be thrown
879-
instead of the `AssertionError`.
880-
881847
## assert.rejects(block[, error][, message])
882848
<!-- YAML
883849
added: REPLACEME
@@ -891,7 +857,7 @@ Awaits for promise returned by function `block` to be rejected.
891857
When `assert.rejects()` is called, it will immediately call the `block`
892858
function, and awaits for completion.
893859

894-
Besides the async nature to await the completion behaves identical to
860+
Besides the async nature to await the completion behaves identically to
895861
[`assert.throws()`][].
896862

897863
If specified, `error` can be a constructor, [`RegExp`][], a validation
@@ -920,6 +886,40 @@ assert.rejects(
920886
});
921887
```
922888

889+
## assert.strictEqual(actual, expected[, message])
890+
<!-- YAML
891+
added: v0.1.21
892+
changes:
893+
- version: REPLACEME
894+
pr-url: https://github.com/nodejs/node/pull/17003
895+
description: Used comparison changed from Strict Equality to `Object.is()`
896+
-->
897+
* `actual` {any}
898+
* `expected` {any}
899+
* `message` {any}
900+
901+
Tests strict equality between the `actual` and `expected` parameters as
902+
determined by the [SameValue Comparison][].
903+
904+
```js
905+
const assert = require('assert').strict;
906+
907+
assert.strictEqual(1, 2);
908+
// AssertionError: 1 strictEqual 2
909+
910+
assert.strictEqual(1, 1);
911+
// OK
912+
913+
assert.strictEqual(1, '1');
914+
// AssertionError: 1 strictEqual '1'
915+
```
916+
917+
If the values are not strictly equal, an `AssertionError` is thrown with a
918+
`message` property set equal to the value of the `message` parameter. If the
919+
`message` parameter is undefined, a default error message is assigned. If the
920+
`message` parameter is an instance of an [`Error`][] then it will be thrown
921+
instead of the `AssertionError`.
922+
923923
## assert.throws(block[, error][, message])
924924
<!-- YAML
925925
added: v0.1.21
@@ -1051,12 +1051,13 @@ second argument. This might lead to difficult-to-spot errors.
10511051
[`WeakSet`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet
10521052
[`assert.deepEqual()`]: #assert_assert_deepequal_actual_expected_message
10531053
[`assert.deepStrictEqual()`]: #assert_assert_deepstrictequal_actual_expected_message
1054+
[`assert.doesNotThrow()`]: #assert_assert_doesnotthrow_block_error_message
10541055
[`assert.notDeepStrictEqual()`]: #assert_assert_notdeepstrictequal_actual_expected_message
10551056
[`assert.notStrictEqual()`]: #assert_assert_notstrictequal_actual_expected_message
10561057
[`assert.ok()`]: #assert_assert_ok_value_message
1058+
[`assert.rejects()`]: #assert_assert_rejects_block_error_message
10571059
[`assert.strictEqual()`]: #assert_assert_strictequal_actual_expected_message
10581060
[`assert.throws()`]: #assert_assert_throws_block_error_message
1059-
[`assert.rejects()`]: #assert_assert_rejects_block_error_message
10601061
[`strict mode`]: #assert_strict_mode
10611062
[Abstract Equality Comparison]: https://tc39.github.io/ecma262/#sec-abstract-equality-comparison
10621063
[Object.prototype.toString()]: https://tc39.github.io/ecma262/#sec-object.prototype.tostring

0 commit comments

Comments
 (0)