Skip to content

Commit 6643e80

Browse files
committed
fix(cli): use DI pattern in fetchUsageData test instead of modifying process.env
1 parent dcdda60 commit 6643e80

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

cli/src/hooks/__tests__/use-usage-query.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {
1111
} from 'bun:test'
1212
import React from 'react'
1313

14+
import type { ClientEnv } from '@codebuff/common/types/contracts/env'
15+
1416
import { useChatStore } from '../../state/chat-store'
1517
import * as authModule from '../../utils/auth'
1618
import {
@@ -65,11 +67,12 @@ describe('fetchUsageData', () => {
6567
})
6668

6769
test('should throw error when app URL is not set', async () => {
68-
delete process.env.NEXT_PUBLIC_CODEBUFF_APP_URL
69-
70-
await expect(fetchUsageData({ authToken: 'test-token' })).rejects.toThrow(
71-
'NEXT_PUBLIC_CODEBUFF_APP_URL is not set',
72-
)
70+
await expect(
71+
fetchUsageData({
72+
authToken: 'test-token',
73+
clientEnv: { NEXT_PUBLIC_CODEBUFF_APP_URL: undefined } as ClientEnv,
74+
}),
75+
).rejects.toThrow('NEXT_PUBLIC_CODEBUFF_APP_URL is not set')
7376
})
7477
})
7578

0 commit comments

Comments
 (0)