-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathSessionBarProcessor.spec.ts
More file actions
64 lines (63 loc) · 2 KB
/
Copy pathSessionBarProcessor.spec.ts
File metadata and controls
64 lines (63 loc) · 2 KB
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
54
55
56
57
58
59
60
61
62
63
64
import { describe, expect, it } from 'vitest';
import type { Session, Telemetry } from '@irdashies/types';
import { SessionBarProcessor } from './SessionBarProcessor';
describe('SessionBarProcessor', () => {
it('projects the auxiliary session bar state and resets with lifecycle', () => {
const processor = new SessionBarProcessor();
processor.init({
WeekendInfo: {
TrackDisplayName: 'Okayama',
WeekendOptions: { IncidentLimit: 17 },
},
DriverInfo: {
DriverCarIdx: 0,
Drivers: [{ CarIdx: 0, CarID: 67, CarClassID: 1 }],
},
SessionInfo: {
Sessions: [{ SessionNum: 1, SessionName: 'Race', SessionType: 'Race' }],
},
} as unknown as Session);
processor.onFrame({
SessionTime: { value: [1] },
SessionNum: { value: [1] },
DisplayUnits: { value: [1] },
FuelLevel: { value: [30] },
PlayerCarTeamIncidentCount: { value: [2] },
CarIdxPosition: { value: [1] },
CarIdxClassPosition: { value: [1] },
CarIdxBestLapTime: { value: [90] },
Lap: { value: [2] },
Speed: { value: [50] },
} as unknown as Telemetry);
expect(processor.snapshot()).toMatchObject({
sessionName: 'Race',
trackDisplayName: 'Okayama',
fuelLevel: 30,
incidents: 2,
playerClassPosition: 1,
playerClassSize: 1,
sessionBestLap: 90,
});
processor.onFrame({
SessionTime: { value: [1.05] },
SessionNum: { value: [1] },
Lap: { value: [2] },
Speed: { value: [70] },
} as unknown as Telemetry);
processor.onFrame({
SessionTime: { value: [1.2] },
SessionNum: { value: [1] },
Lap: { value: [3] },
Speed: { value: [40] },
} as unknown as Telemetry);
expect(processor.snapshot()).toMatchObject({
lastLapTopSpeed: 70,
sessionBestTopSpeed: 70,
});
processor.onLifecycle({ type: 'disconnect' });
expect(processor.snapshot()).toMatchObject({
sessionNum: null,
incidents: 0,
});
});
});