-
Notifications
You must be signed in to change notification settings - Fork 110
/
Copy pathtotalBlockingTime.spec.ts
53 lines (48 loc) · 1.29 KB
/
totalBlockingTime.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* @jest-environment jsdom
*/
import { fcp, tbt } from '../src/metrics';
import { initTotalBlockingTime } from '../src/totalBlockingTime';
describe('totalBlockingTime', () => {
describe('.initTotalBlockingTime()', () => {
beforeEach(() => {
fcp.value = 10;
tbt.value = 0;
});
it('should keep the value to 0 when PerformanceEntry are empty', () => {
initTotalBlockingTime([]);
expect(tbt.value).toEqual(0);
});
it('should keep the value to 0 when PerformanceEntry are not self', () => {
const pe = {
name: 'nope',
startTime: 10,
} as any;
initTotalBlockingTime([pe]);
expect(tbt.value).toEqual(0);
});
it('should set correctly the value', () => {
const pe = {
name: 'self',
startTime: 20,
duration: 60,
} as any;
const peTwo = {
name: 'self',
startTime: 20,
duration: 40,
} as any;
initTotalBlockingTime([pe, peTwo, pe]);
expect(tbt.value).toEqual(20);
});
it('should keep the value to 0 when tasks are not large enough', () => {
const peTwo = {
name: 'self',
startTime: 20,
duration: 40,
} as any;
initTotalBlockingTime([peTwo]);
expect(tbt.value).toEqual(0);
});
});
});