Skip to content

Commit 07e4bee

Browse files
committed
Add negative tests
1 parent 37de9b1 commit 07e4bee

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

index.test-d.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,32 @@ it('should handle different key and value types', () => {
4545
expectTypeOf(map.set([true, 123, 'hello'], {status: 'active'})).toEqualTypeOf<typeof map>();
4646
expectTypeOf(map.get([false, 456, 'world'])).toEqualTypeOf<DiverseValue | undefined>();
4747
});
48+
49+
it('should not accept non-array keys', () => {
50+
// @ts-expect-error - string key should not be allowed
51+
expectTypeOf<ManyKeysMap<string, any>>().not.toBeAny();
52+
53+
// @ts-expect-error - number key should not be allowed
54+
expectTypeOf<ManyKeysMap<number, any>>().not.toBeAny();
55+
56+
// @ts-expect-error - object key should not be allowed
57+
expectTypeOf<ManyKeysMap<Record<string, unknown>, any>>().not.toBeAny();
58+
});
59+
60+
it('should not accept undefined or null keys', () => {
61+
// @ts-expect-error - undefined key should not be allowed
62+
expectTypeOf<ManyKeysMap<undefined, any>>().not.toBeAny();
63+
64+
// @ts-expect-error - null key should not be allowed
65+
expectTypeOf<ManyKeysMap<undefined, any>>().not.toBeAny();
66+
});
67+
68+
it('should not accept function keys', () => {
69+
// @ts-expect-error - function key should not be allowed
70+
expectTypeOf<ManyKeysMap<() => void, any>>().not.toBeAny();
71+
});
72+
73+
it('should not accept symbol keys', () => {
74+
// @ts-expect-error - symbol key should not be allowed
75+
expectTypeOf<ManyKeysMap<symbol, any>>().not.toBeAny();
76+
});

0 commit comments

Comments
 (0)