Skip to content

Commit e6fbcc6

Browse files
committed
test(toolsets): add type-level tests for StackOneToolSetConfig
Add comprehensive type tests using vitest's expectTypeOf to verify the MergeExclusive behaviour of account configuration options: - Test that accountId alone is valid - Test that accountIds alone is valid - Test that neither is valid (optional) - Test that both together is rejected by the type system - Verify accountId is typed as string | undefined - Verify accountIds is typed as string[] | undefined
1 parent 2ab55cd commit e6fbcc6

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

src/toolsets.test-d.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { expectTypeOf } from 'vitest';
2+
import type { StackOneToolSetConfig } from './toolsets';
3+
4+
// Valid configurations - only accountId
5+
test('StackOneToolSetConfig accepts only accountId', () => {
6+
expectTypeOf<{
7+
apiKey: string;
8+
accountId: string;
9+
}>().toMatchTypeOf<StackOneToolSetConfig>();
10+
});
11+
12+
// Valid configurations - only accountIds
13+
test('StackOneToolSetConfig accepts only accountIds', () => {
14+
expectTypeOf<{
15+
apiKey: string;
16+
accountIds: string[];
17+
}>().toMatchTypeOf<StackOneToolSetConfig>();
18+
});
19+
20+
// Valid configurations - neither accountId nor accountIds
21+
test('StackOneToolSetConfig accepts neither accountId nor accountIds', () => {
22+
expectTypeOf<{
23+
apiKey: string;
24+
}>().toMatchTypeOf<StackOneToolSetConfig>();
25+
});
26+
27+
// Invalid configuration - both accountId and accountIds should NOT match
28+
test('StackOneToolSetConfig rejects both accountId and accountIds', () => {
29+
expectTypeOf<{
30+
apiKey: string;
31+
accountId: string;
32+
accountIds: string[];
33+
}>().not.toMatchTypeOf<StackOneToolSetConfig>();
34+
});
35+
36+
// Verify accountId can be string or undefined
37+
test('accountId is typed as string | undefined', () => {
38+
expectTypeOf<StackOneToolSetConfig['accountId']>().toEqualTypeOf<string | undefined>();
39+
});
40+
41+
// Verify accountIds can be string[] or undefined
42+
test('accountIds is typed as string[] | undefined', () => {
43+
expectTypeOf<StackOneToolSetConfig['accountIds']>().toEqualTypeOf<string[] | undefined>();
44+
});

0 commit comments

Comments
 (0)