-
Notifications
You must be signed in to change notification settings - Fork 110
/
Copy pathvitalsScore.spec.ts
50 lines (44 loc) · 1.68 KB
/
vitalsScore.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
/**
* @jest-environment jsdom
*/
import { webVitalsScore, getVitalsScore, getRating } from '../src/vitalsScore';
describe('vitalsScore', () => {
describe('webVitalsScore', () => {
it('should default to the correct values', () => {
expect(webVitalsScore).toEqual({
RT: [100, 200],
TBT: [200, 600],
NTBT: [200, 600],
});
});
});
describe('getVitalsScore()', () => {
it('should return the correct values for RT', () => {
expect(getVitalsScore('RT', 80)).toEqual('good');
expect(getVitalsScore('RT', 120)).toEqual('needsImprovement');
expect(getVitalsScore('RT', 220)).toEqual('poor');
});
it('should return the correct values for TBT', () => {
expect(getVitalsScore('TBT', 100)).toEqual('good');
expect(getVitalsScore('TBT', 200)).toEqual('good');
expect(getVitalsScore('TBT', 201)).toEqual('needsImprovement');
expect(getVitalsScore('TBT', 700)).toEqual('poor');
});
it('should return the correct values for NTBT', () => {
expect(getVitalsScore('NTBT', 100)).toEqual('good');
expect(getVitalsScore('NTBT', 200)).toEqual('good');
expect(getVitalsScore('NTBT', 201)).toEqual('needsImprovement');
expect(getVitalsScore('NTBT', 700)).toEqual('poor');
});
it('should return null if vital does not exist', () => {
expect(getVitalsScore('InvalidVital', 100)).toBeNull();
});
});
describe('getRating()', () => {
it('should return the correct values', () => {
expect(getRating(50, [100, 200])).toEqual('good');
expect(getRating(150, [100, 200])).toEqual('needsImprovement');
expect(getRating(250, [100, 200])).toEqual('poor');
});
});
});