-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecording.spec.ts
More file actions
34 lines (31 loc) · 1.52 KB
/
recording.spec.ts
File metadata and controls
34 lines (31 loc) · 1.52 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
import { initRecording, playRecording, testRecording } from './recording';
import { matrix } from './switch-matrix';
import { machine } from './machine';
import { Color } from './light';
import { initMachine } from './init';
import { Log } from './log';
import { MPU } from './mpu';
import { snapshot } from './jest';
describe('recordings', () => {
test('reading', async () => {
const shooter = jest.spyOn(matrix[0][0]!, 'changeState');
const right4 = jest.spyOn(matrix[2][2]!, 'changeState');
const right3 = jest.spyOn(matrix[3][2]!, 'changeState');
const upper3a = jest.spyOn(matrix[2][5]!, 'changeState');
expect(matrix[3][2]?.name).toBe('right 3');
initRecording('./recordings/test-1.rec');
await playRecording();
expect(shooter).lastCalledWith(true, expect.stringContaining('recording'));
expect(shooter).lastReturnedWith(expect.objectContaining({when: 2503}));
expect(right4).lastCalledWith(true, expect.stringContaining('recording'));
expect(right4).lastReturnedWith(expect.objectContaining({when: 7319}));
expect(right3).lastCalledWith(true, expect.stringContaining('recording'));
expect(right3).lastReturnedWith(expect.objectContaining({when: 8836}));
expect(upper3a).lastCalledWith(true, expect.stringContaining('recording'));
expect(upper3a).lastReturnedWith(expect.objectContaining({when: 13093}));
});
test('play test', async () => {
await testRecording('lightStraight');
snapshot();
});
});