Skip to content

Commit

Permalink
Fix broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
simonkellly committed May 22, 2024
1 parent eb0a979 commit f596601
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/components/timer/timerStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ export const useCubeTimer = () => {
console.log('Scramble:', TimerStore.state.originalScramble);
let last = times.length > 0 ? times[0].cubeTimestamp : 0;
console.table(
algs.map(([alg, idx]) => {
algs.map(([alg, comment, idx]) => {
const ms = times[idx].cubeTimestamp - last;
const time = (ms / 1000).toFixed(2);
last = times[idx].cubeTimestamp;
return [alg, time];
return [alg + comment, time];
})
);

Expand Down
16 changes: 9 additions & 7 deletions src/lib/solutionParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export function simplify(alg: string) {
// TODO: Handle AUF +2
export async function extractAlgs(
moveSet: string[]
): Promise<[string, number][]> {
): Promise<[string, string, number][]> {
const comms: [
alg: string,
moveIdx: number,
Expand Down Expand Up @@ -425,7 +425,7 @@ export async function extractAlgs(
let foundComm: string | undefined;

if (is2E2C) {
return [simplifiedComm.toString() + comment, moveIdx] as [string, number];
return [simplifiedComm.toString(), comment, moveIdx];
}

if (isEdgeComm || isTwist) {
Expand All @@ -441,7 +441,7 @@ export async function extractAlgs(
}

if (!isAnyAlg) {
return [simplify(comm.trim()) + comment, moveIdx] as [string, number];
return [simplify(comm.trim()).toString(), comment, moveIdx];
}

if (!foundComm || foundComm.endsWith('.')) {
Expand All @@ -460,14 +460,16 @@ export async function extractAlgs(

if (foundComm.endsWith('.')) {
return [
simplify(comm.trim()) + comment + ' (comm not found)',
simplify(comm.trim()).toString(),
comment + ' (comm not found)',
moveIdx,
] as [string, number];
];
}

return [
foundComm.replaceAll(',', ', ').replaceAll(':', ': ') + comment,
foundComm.replaceAll(',', ', ').replaceAll(':', ': '),
comment,
moveIdx,
] as [string, number];
];
});
}
2 changes: 1 addition & 1 deletion tests/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('Extract Comms', () => {
test('Extract invalid comm', async () => {
const extracted = await extractAlgs("R U' R'".split(' '));
expect(extracted.length).toBe(1);
expect(extracted[0][0]).toBe("R U' R' // not found");
expect(extracted[0][0]).toBe("R U' R'");
});

test('Extract slice alg (FK)', async () => {
Expand Down

0 comments on commit f596601

Please sign in to comment.