forked from clerk/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultiDomain.test.ts
More file actions
33 lines (30 loc) · 966 Bytes
/
Copy pathmultiDomain.test.ts
File metadata and controls
33 lines (30 loc) · 966 Bytes
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
import { handleValueOrFn } from './multiDomain';
const url = new URL('https://example.com');
describe('handleValueOrFn(opts)', () => {
it.each([
[undefined, undefined],
[true, true],
[false, false],
[() => true, true],
[() => false, false],
['', ''],
['some-domain', 'some-domain'],
['clerk.com', 'clerk.com'],
[url => url.host, 'example.com'],
[() => 'some-other-domain', 'some-other-domain'],
])('.handleValueOrFn(%s)', (key, expected) => {
expect(handleValueOrFn(key, url)).toBe(expected);
});
});
describe('handleValueOrFn(opts) with defaults', () => {
it.each([
[undefined, undefined, undefined],
[undefined, true, true],
[true, true, false],
[undefined, false, false],
[false, false, undefined],
[undefined, 'some-domain', 'some-domain'],
])('.handleValueOrFn(%s)', (key, expected, defaultValue) => {
expect(handleValueOrFn(key, url, defaultValue)).toBe(expected);
});
});