Skip to content

Commit eab1737

Browse files
committed
fix: alt space highlighting correct word as incorrect
also updates tests to just use the implementation instead of mocking it
1 parent d617513 commit eab1737

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

frontend/__tests__/input/helpers/validation.spec.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,15 @@ vi.mock("../../../src/ts/test/funbox/list", () => ({
1414
findSingleActiveFunboxWithFunction: vi.fn(),
1515
}));
1616

17-
vi.mock("../../../src/ts/utils/strings", () => ({
18-
areCharactersVisuallyEqual: vi.fn(),
19-
isSpace: vi.fn(),
20-
}));
17+
vi.mock("../../../src/ts/utils/strings", async () => {
18+
const actual = await vi.importActual<typeof Strings>(
19+
"../../../src/ts/utils/strings"
20+
);
21+
return {
22+
...actual,
23+
areCharactersVisuallyEqual: vi.fn(),
24+
};
25+
});
2126

2227
describe("isCharCorrect", () => {
2328
beforeEach(() => {
@@ -34,7 +39,6 @@ describe("isCharCorrect", () => {
3439
null
3540
);
3641
(Strings.areCharactersVisuallyEqual as any).mockReturnValue(false);
37-
(Strings.isSpace as any).mockReturnValue(false);
3842
});
3943

4044
afterAll(() => {
@@ -133,7 +137,6 @@ describe("isCharCorrect", () => {
133137

134138
describe("shouldInsertSpaceCharacter", () => {
135139
beforeEach(() => {
136-
(Strings.isSpace as any).mockReturnValue(true);
137140
replaceConfig({
138141
mode: "time",
139142
stopOnError: "off",
@@ -147,7 +150,6 @@ describe("shouldInsertSpaceCharacter", () => {
147150
});
148151

149152
it("returns null if data is not a space", () => {
150-
(Strings.isSpace as any).mockReturnValue(false);
151153
expect(
152154
shouldInsertSpaceCharacter({
153155
data: "a",

frontend/src/ts/input/helpers/validation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function isCharCorrect(options: {
2525
throw new Error("Failed to check if char is correct - data is undefined");
2626
}
2727

28-
if (data === " ") {
28+
if (isSpace(data)) {
2929
return inputValue === targetWord;
3030
}
3131

0 commit comments

Comments
 (0)