-
Notifications
You must be signed in to change notification settings - Fork 110
/
Copy pathisSupported.spec.ts
33 lines (29 loc) · 1016 Bytes
/
isSupported.spec.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
/**
* @jest-environment jsdom
*/
import { WP } from '../src/constants';
import { isPerformanceSupported } from '../src/isSupported';
import mock from './_mock';
describe('isSupported', () => {
beforeEach(() => {
(WP as any) = mock.performance();
(window as any).PerformanceObserver = mock.PerformanceObserver;
});
describe('.isPerformanceSupported()', () => {
it('should return true if the browser supports the Navigation Timing API', () => {
expect(isPerformanceSupported()).toEqual(true);
});
it('should return false if the browser does not supports performance.mark', () => {
// @ts-ignore
delete window.performance.mark;
expect(isPerformanceSupported()).toEqual(false);
});
it('should return false if the browser does not supports performance.now', () => {
// @ts-ignore
window.performance.mark = () => 1;
// @ts-ignore
delete window.performance.now;
expect(isPerformanceSupported()).toEqual(false);
});
});
});