assert: make partialDeepStrictEqual work with urls and File prototypes · nodejs/node@e222e36 · GitHub
Skip to content

Commit e222e36

Browse files
Giovanni Bucciaduh95
authored andcommitted
assert: make partialDeepStrictEqual work with urls and File prototypes
PR-URL: #56231 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Xuguang Mei <meixuguang@gmail.com> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
1 parent 4844fa2 commit e222e36

3 files changed

Lines changed: 37 additions & 2 deletions

File tree

lib/assert.js

Lines changed: 7 additions & 2 deletions

test/parallel/test-assert-objects.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,16 @@ describe('Object Comparison Tests', () => {
296296
actual: { dataView: new Uint8Array(3) },
297297
expected: { dataView: new DataView(new ArrayBuffer(3)) },
298298
},
299+
{
300+
description: 'throws when comparing Float32Array([+0.0]) with Float32Array([-0.0])',
301+
actual: new Float32Array([+0.0]),
302+
expected: new Float32Array([-0.0]),
303+
},
304+
{
305+
description: 'throws when comparing two different urls',
306+
actual: new URL('http://foo'),
307+
expected: new URL('http://bar'),
308+
},
299309
{
300310
description: 'throws when comparing SharedArrayBuffers when expected has different elements actual',
301311
actual: (() => {
@@ -768,6 +778,21 @@ describe('Object Comparison Tests', () => {
768778
actual: [1, 2, 3],
769779
expected: [2],
770780
},
781+
{
782+
description: 'ensures that File extends Blob',
783+
actual: Object.getPrototypeOf(File.prototype),
784+
expected: Blob.prototype
785+
},
786+
{
787+
description: 'compares NaN with NaN',
788+
actual: NaN,
789+
expected: NaN,
790+
},
791+
{
792+
description: 'compares two identical urls',
793+
actual: new URL('http://foo'),
794+
expected: new URL('http://foo'),
795+
},
771796
].forEach(({ description, actual, expected }) => {
772797
it(description, () => {
773798
assert.partialDeepStrictEqual(actual, expected);

test/parallel/test-assert-typedarray-deepequal.js

Lines changed: 5 additions & 0 deletions

0 commit comments

Comments
 (0)