Skip to content

Commit 5cfddf7

Browse files
add failing test
1 parent 9eb0fd4 commit 5cfddf7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/index.test.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,7 @@ test('handles Set with circular reference that collapses', () => {
11921192
expect(deserialized).toEqual(root);
11931193
});
11941194

1195-
test('handles Map with circular reference that collapses', () => {
1195+
test('handles Map with circular reference mapping to undefined', () => {
11961196
const map = new Map();
11971197
map.set(null, undefined);
11981198
map.set(map, undefined);
@@ -1203,6 +1203,16 @@ test('handles Map with circular reference that collapses', () => {
12031203
expect(deserialized).toEqual(map);
12041204
});
12051205

1206+
test('handles Map with circular reference mapping to null', () => {
1207+
const map = new Map();
1208+
map.set(null, undefined);
1209+
map.set(map, null);
1210+
1211+
const serialized = SuperJSON.serialize(map);
1212+
const deserialized = SuperJSON.deserialize(serialized);
1213+
1214+
expect(deserialized).toEqual(map);
1215+
});
12061216

12071217
test('performance regression', () => {
12081218
const data: any[] = [];

0 commit comments

Comments
 (0)