Skip to content

Commit f0a7b82

Browse files
committed
fix: test not failing if min speed check failed on the last second
1 parent 2431ae3 commit f0a7b82

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

frontend/src/ts/test/test-timer.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function layoutfluid(): void {
129129
function checkIfFailed(
130130
wpmAndRaw: { wpm: number; raw: number },
131131
acc: number
132-
): void {
132+
): boolean {
133133
if (timerDebug) console.time("fail conditions");
134134
TestInput.pushKeypressesToHistory();
135135
TestInput.pushErrorToHistory();
@@ -143,16 +143,17 @@ function checkIfFailed(
143143
SlowTimer.clear();
144144
slowTimerCount = 0;
145145
TimerEvent.dispatch("fail", "min speed");
146-
return;
146+
return true;
147147
}
148148
if (Config.minAcc === "custom" && acc < Config.minAccCustom) {
149149
if (timer !== null) clearTimeout(timer);
150150
SlowTimer.clear();
151151
slowTimerCount = 0;
152152
TimerEvent.dispatch("fail", "min accuracy");
153-
return;
153+
return true;
154154
}
155155
if (timerDebug) console.timeEnd("fail conditions");
156+
return false;
156157
}
157158

158159
function checkIfTimeIsUp(): void {
@@ -200,8 +201,8 @@ async function timerStep(): Promise<void> {
200201
const acc = calculateAcc();
201202
monkey(wpmAndRaw);
202203
layoutfluid();
203-
checkIfFailed(wpmAndRaw, acc);
204-
checkIfTimeIsUp();
204+
const failed = checkIfFailed(wpmAndRaw, acc);
205+
if (!failed) checkIfTimeIsUp();
205206
if (timerDebug) console.timeEnd("timer step -----------------------------");
206207
}
207208

0 commit comments

Comments
 (0)