forked from chromaui/chromatic-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
isChromatic.test.ts
39 lines (35 loc) · 943 Bytes
/
isChromatic.test.ts
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
/* eslint-env browser */
import { describe, expect, it } from 'vitest';
import isChromatic from './isChromatic';
describe('with window arg', () => {
it('returns false', () => {
expect(
isChromatic({
navigator: {
userAgent: 'Chrome',
},
location: new URL('https://example.com'),
} as any as Window)
).toBe(false);
});
it('returns true if location.href contains chromatic=true queryparam', () => {
expect(
isChromatic({
navigator: {
userAgent: 'Chrome',
},
location: new URL('https://example.com?chromatic=true'),
} as any as Window)
).toBe(true);
});
it('returns true if userAgent contains Chromatic', () => {
expect(
isChromatic({
navigator: {
userAgent: 'Chromium(Chromatic)',
},
location: new URL('https://example.com'),
} as any as Window)
).toBe(true);
});
});