assert: make Maps be partially compared in partialDeepStrictEqual · nodejs/node@2314e49
@@ -169,12 +169,26 @@ describe('Object Comparison Tests', () => {
169169},
170170{
171171description:
172-'throws when comparing two Map objects with different length',
172+'throws when the expected Map has more entries than the actual Map',
173173actual: new Map([
174174['key1', 'value1'],
175175['key2', 'value2'],
176176]),
177-expected: new Map([['key1', 'value1']]),
177+expected: new Map([
178+['key1', 'value1'],
179+['key2', 'value2'],
180+['key3', 'value3'],
181+]),
182+},
183+{
184+description: 'throws when the nested array in the Map is not a subset of the other nested array',
185+actual: new Map([
186+['key1', ['value1', 'value2']],
187+['key2', 'value2'],
188+]),
189+expected: new Map([
190+['key1', ['value3']],
191+]),
178192},
179193{
180194description:
@@ -564,6 +578,63 @@ describe('Object Comparison Tests', () => {
564578['key2', 'value2'],
565579]),
566580},
581+{
582+description:
583+'compares two Map objects where expected is a subset of actual',
584+actual: new Map([
585+['key1', 'value1'],
586+['key2', 'value2'],
587+]),
588+expected: new Map([['key1', 'value1']]),
589+},
590+{
591+description:
592+'compares two deeply nested Maps',
593+actual: {
594+a: {
595+b: {
596+c: new Map([
597+['key1', 'value1'],
598+['key2', 'value2'],
599+])
600+},
601+z: [1, 2, 3]
602+}
603+},
604+expected: {
605+a: {
606+z: [1, 2, 3],
607+b: {
608+c: new Map([['key1', 'value1']])
609+}
610+}
611+},
612+},
613+{
614+description: 'compares Maps nested into Maps',
615+actual: new Map([
616+['key1', new Map([
617+['nestedKey1', 'nestedValue1'],
618+['nestedKey2', 'nestedValue2'],
619+])],
620+['key2', 'value2'],
621+]),
622+expected: new Map([
623+['key1', new Map([
624+['nestedKey1', 'nestedValue1'],
625+])],
626+])
627+},
628+{
629+description: 'compares Maps with nested arrays inside',
630+actual: new Map([
631+['key1', ['value1', 'value2']],
632+['key2', 'value2'],
633+]),
634+expected: new Map([
635+['key1', ['value1', 'value2']],
636+]),
637+},
567638{
568639description:
569640'compares two objects with identical getter/setter properties',