Skip to content

Commit 71fc96d

Browse files
authored
fix(settings): handle boolean values for indicateTypos (@fehmer) (monkeytypegame#6554)
Handle legacy values for indicateTypos. Fixes FRONTEND-MJ
1 parent 44a67db commit 71fc96d

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

frontend/__tests__/utils/config.spec.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ describe("config.ts", () => {
8080
);
8181
});
8282
});
83-
it("should convert legacy values", () => {
84-
const testCases = [
83+
describe("should convert legacy values", () => {
84+
it.for([
8585
{ given: { quickTab: true }, expected: { quickRestart: "tab" } },
8686
{ given: { smoothCaret: true }, expected: { smoothCaret: "medium" } },
8787
{ given: { smoothCaret: false }, expected: { smoothCaret: "off" } },
@@ -140,18 +140,27 @@ describe("config.ts", () => {
140140
expected: { liveAccStyle: "mini" },
141141
},
142142
{ given: { soundVolume: "0.5" }, expected: { soundVolume: 0.5 } },
143-
];
144-
145-
//WHEN
146-
testCases.forEach((test) => {
143+
{ given: { funbox: "none" }, expected: { funbox: [] } },
144+
{
145+
given: { funbox: "58008#read_ahead" },
146+
expected: { funbox: ["58008", "read_ahead"] },
147+
},
148+
{
149+
given: { customLayoutfluid: "qwerty#qwertz" },
150+
expected: { customLayoutfluid: ["qwerty", "qwertz"] },
151+
},
152+
{ given: { indicateTypos: false }, expected: { indicateTypos: "off" } },
153+
{
154+
given: { indicateTypos: true },
155+
expected: { indicateTypos: "replace" },
156+
},
157+
])(`$given`, ({ given, expected }) => {
147158
const description = `given: ${JSON.stringify(
148-
test.given
149-
)}, expected: ${JSON.stringify(test.expected)} `;
159+
given
160+
)}, expected: ${JSON.stringify(expected)} `;
150161

151-
const result = migrateConfig(test.given);
152-
expect(result, description).toEqual(
153-
expect.objectContaining(test.expected)
154-
);
162+
const result = migrateConfig(given);
163+
expect(result, description).toEqual(expect.objectContaining(expected));
155164
});
156165
});
157166
});

frontend/src/ts/utils/config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,5 +131,10 @@ export function replaceLegacyValues(
131131
) as ConfigSchemas.CustomLayoutFluid;
132132
}
133133

134+
if (typeof configObj.indicateTypos === "boolean") {
135+
configObj.indicateTypos =
136+
configObj.indicateTypos === false ? "off" : "replace";
137+
}
138+
134139
return configObj;
135140
}

0 commit comments

Comments
 (0)