-
Notifications
You must be signed in to change notification settings - Fork 451
Expand file tree
/
Copy pathunsafeDisableDevelopmentModeConsoleWarning.test.ts
More file actions
42 lines (33 loc) · 1.42 KB
/
unsafeDisableDevelopmentModeConsoleWarning.test.ts
File metadata and controls
42 lines (33 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import type { RequestState } from '@clerk/backend/internal';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { mergeWithPublicEnvs, pickFromClerkInitState } from '../client/utils';
import { getResponseClerkState } from '../server/utils';
const createRequestState = (): RequestState =>
({
domain: undefined,
isSatellite: false,
publishableKey: 'pk_test_xxx',
proxyUrl: undefined,
signInUrl: undefined,
signUpUrl: undefined,
toAuth: () => ({}),
}) as RequestState;
describe('unsafe_disableDevelopmentModeConsoleWarning', () => {
afterEach(() => {
vi.unstubAllEnvs();
});
it('preserves an explicit false from the initial state when public env is true', () => {
vi.stubEnv('VITE_CLERK_UNSAFE_DISABLE_DEVELOPMENT_MODE_CONSOLE_WARNING', 'true');
const result = mergeWithPublicEnvs({
unsafe_disableDevelopmentModeConsoleWarning: false,
});
expect(result.unsafe_disableDevelopmentModeConsoleWarning).toBe(false);
});
it('hydrates the unprefixed env value from server state', () => {
vi.stubEnv('CLERK_UNSAFE_DISABLE_DEVELOPMENT_MODE_CONSOLE_WARNING', 'true');
const clerkInitialState = getResponseClerkState(createRequestState());
const pickedState = pickFromClerkInitState(clerkInitialState.__internal_clerk_state);
const result = mergeWithPublicEnvs(pickedState);
expect(result.unsafe_disableDevelopmentModeConsoleWarning).toBe(true);
});
});