Skip to content

Commit 9b614e2

Browse files
committed
test(toolsets): add runtime validation test for mutually exclusive accounts
Add test to verify ToolSetConfigError is thrown when both accountId and accountIds are provided at runtime. Uses 'as never' to bypass TypeScript type checking and simulate JavaScript usage scenarios.
1 parent a5e41b7 commit 9b614e2

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/toolsets.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,24 @@ describe('StackOneToolSet', () => {
130130
expect(toolsetMultiple.accountIds).toEqual(['account-1', 'account-2']);
131131
});
132132

133+
it('should throw error when both accountId and accountIds are provided at runtime', () => {
134+
// Runtime validation for JavaScript users or when TypeScript is bypassed
135+
expect(() => {
136+
new StackOneToolSet({
137+
apiKey: 'custom_key',
138+
accountId: 'primary-account',
139+
accountIds: ['account-1', 'account-2'],
140+
} as never); // Use 'as never' to bypass TypeScript for runtime test
141+
}).toThrow(ToolSetConfigError);
142+
expect(() => {
143+
new StackOneToolSet({
144+
apiKey: 'custom_key',
145+
accountId: 'primary-account',
146+
accountIds: ['account-1', 'account-2'],
147+
} as never);
148+
}).toThrow(/Cannot provide both accountId and accountIds/);
149+
});
150+
133151
it('should set baseUrl from config', () => {
134152
const toolset = new StackOneToolSet({
135153
apiKey: 'custom_key',

0 commit comments

Comments
 (0)