Skip to content

Commit e246295

Browse files
test: add skipPrototypeComparison tests for Assert class
1 parent 7709510 commit e246295

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

test/parallel/test-assert-class.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,3 +478,46 @@ test('Assert class non strict with simple diff', () => {
478478
);
479479
}
480480
});
481+
482+
// Shared setup for skipPrototypeComparison tests
483+
{
484+
const message = 'Expected values to be strictly deep-equal:\n' +
485+
'+ actual - expected\n' +
486+
'\n' +
487+
' [\n' +
488+
' 1,\n' +
489+
' 2,\n' +
490+
' 3,\n' +
491+
' 4,\n' +
492+
' 5,\n' +
493+
'+ 6,\n' +
494+
'- 9,\n' +
495+
' 7\n' +
496+
' ]\n';
497+
498+
function CoolClass(name) { this.name = name; }
499+
500+
function AwesomeClass(name) { this.name = name; }
501+
const person = new CoolClass('Assert is inspiring');
502+
const user = new AwesomeClass('Assert is inspiring');
503+
504+
test('Assert class strict with skipPrototypeComparison', () => {
505+
const assertInstance = new Assert({ skipPrototypeComparison: true });
506+
507+
assert.throws(
508+
() => assertInstance.deepEqual([1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 9, 7]),
509+
{ message }
510+
);
511+
assertInstance.deepEqual(person, user);
512+
});
513+
514+
test('Assert class non strict with skipPrototypeComparison', () => {
515+
const assertInstance = new Assert({ strict: false, skipPrototypeComparison: true });
516+
517+
assert.throws(
518+
() => assertInstance.deepStrictEqual([1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 9, 7]),
519+
{ message }
520+
);
521+
assertInstance.deepStrictEqual(person, user);
522+
});
523+
}

0 commit comments

Comments
 (0)