forked from clerk/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.test.ts
More file actions
34 lines (30 loc) · 1.52 KB
/
Copy patherror.test.ts
File metadata and controls
34 lines (30 loc) · 1.52 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
import type { ErrorThrowerOptions } from '../error';
import { buildErrorThrower } from '../error';
describe('ErrorThrower', () => {
const errorThrower = buildErrorThrower({ packageName: '@clerk/test-package' });
it('throws the correct error message and interpolates pkg and known parameters', () => {
expect(() => errorThrower.throwInvalidPublishableKeyError({ key: 'whatever' })).toThrow(
'@clerk/test-package: The publishableKey passed to Clerk is invalid. You can get your Publishable key at https://dashboard.clerk.com/last-active?path=api-keys. (key=whatever)',
);
});
it('throws the correct error message and interpolates pkg if no parameters are provided', () => {
expect(() => errorThrower.throwMissingPublishableKeyError()).toThrow(
'@clerk/test-package: Missing publishableKey. You can get your key at https://dashboard.clerk.com/last-active?path=api-keys.',
);
});
it('throws a custom error message and interpolates pkg and known parameters', () => {
expect(() =>
errorThrower
.setPackageName({
packageName: '@clerk/another-test-package',
})
.setMessages({
customMessages: {
InvalidPublishableKeyErrorMessage:
'This is a custom error message for key={{key}} and an unknown {{replacement}}',
},
} as ErrorThrowerOptions)
.throwInvalidPublishableKeyError({ key: 'whatever' }),
).toThrow('@clerk/another-test-package: This is a custom error message for key=whatever and an unknown ');
});
});