-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathparseReconstructionAsync.test.ts
More file actions
67 lines (61 loc) · 2.56 KB
/
Copy pathparseReconstructionAsync.test.ts
File metadata and controls
67 lines (61 loc) · 2.56 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
65
66
67
// Copyright (c) 2023 Joseph Hale <me@jhale.dev>
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
import { STIF } from '../../stif';
import { parseReconstruction } from '../parseReconstruction';
import { parseReconstructionAsync } from '../parseReconstructionAsync';
const rcAttempt =
require('../__fixtures__/rubiks_connected_attempt.json') as STIF.Attempt;
const rcRecording =
require('../__fixtures__/rubiks_connected_recording.json') as STIF.SolveRecording;
describe('parseReconstructionAsync', () => {
it('resolves with the same result as parseReconstruction for a Rubiks Connected attempt', async () => {
const attempt = rcAttempt;
const scramble = attempt.solutions[0].scramble;
const expected = parseReconstruction(rcRecording, scramble, attempt.timerStart);
const actual = await parseReconstructionAsync(
rcRecording,
scramble,
attempt.timerStart,
);
expect(actual).toEqual(expected);
});
it('resolves with the same result as parseReconstruction for a Particula 2x2x2', async () => {
const attempt =
require('../__fixtures__/particula_2x2x2_attempt.json') as STIF.Attempt;
const recording =
require('../__fixtures__/particula_2x2x2_recording.json') as STIF.SolveRecording;
const scramble = attempt.solutions[0].scramble;
const expected = parseReconstruction(recording, scramble, attempt.timerStart);
const actual = await parseReconstructionAsync(
recording,
scramble,
attempt.timerStart,
);
expect(actual).toEqual(expected);
});
it('resolves with the same result as parseReconstruction for a Particula 3x3x3', async () => {
const attempt =
require('../__fixtures__/particula_3x3x3_attempt.json') as STIF.Attempt;
const recording =
require('../__fixtures__/particula_3x3x3_recording.json') as STIF.SolveRecording;
const scramble = attempt.solutions[0].scramble;
const expected = parseReconstruction(recording, scramble, attempt.timerStart);
const actual = await parseReconstructionAsync(
recording,
scramble,
attempt.timerStart,
);
expect(actual).toEqual(expected);
});
it('resolves with an empty array when there is no message stream', async () => {
const actual = await parseReconstructionAsync(
{ smartPuzzle: rcRecording.smartPuzzle, stream: [] },
rcAttempt.solutions[0].scramble,
rcAttempt.timerStart,
);
expect(actual).toEqual([]);
});
});