mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-08 14:42:46 +08:00
fix(settings): handle boolean values for indicateTypos (@fehmer) (#6554)
Handle legacy values for indicateTypos. Fixes FRONTEND-MJ
This commit is contained in:
parent
44a67db9fc
commit
71fc96d6b5
2 changed files with 26 additions and 12 deletions
|
@ -80,8 +80,8 @@ describe("config.ts", () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
it("should convert legacy values", () => {
|
||||
const testCases = [
|
||||
describe("should convert legacy values", () => {
|
||||
it.for([
|
||||
{ given: { quickTab: true }, expected: { quickRestart: "tab" } },
|
||||
{ given: { smoothCaret: true }, expected: { smoothCaret: "medium" } },
|
||||
{ given: { smoothCaret: false }, expected: { smoothCaret: "off" } },
|
||||
|
@ -140,18 +140,27 @@ describe("config.ts", () => {
|
|||
expected: { liveAccStyle: "mini" },
|
||||
},
|
||||
{ given: { soundVolume: "0.5" }, expected: { soundVolume: 0.5 } },
|
||||
];
|
||||
|
||||
//WHEN
|
||||
testCases.forEach((test) => {
|
||||
{ given: { funbox: "none" }, expected: { funbox: [] } },
|
||||
{
|
||||
given: { funbox: "58008#read_ahead" },
|
||||
expected: { funbox: ["58008", "read_ahead"] },
|
||||
},
|
||||
{
|
||||
given: { customLayoutfluid: "qwerty#qwertz" },
|
||||
expected: { customLayoutfluid: ["qwerty", "qwertz"] },
|
||||
},
|
||||
{ given: { indicateTypos: false }, expected: { indicateTypos: "off" } },
|
||||
{
|
||||
given: { indicateTypos: true },
|
||||
expected: { indicateTypos: "replace" },
|
||||
},
|
||||
])(`$given`, ({ given, expected }) => {
|
||||
const description = `given: ${JSON.stringify(
|
||||
test.given
|
||||
)}, expected: ${JSON.stringify(test.expected)} `;
|
||||
given
|
||||
)}, expected: ${JSON.stringify(expected)} `;
|
||||
|
||||
const result = migrateConfig(test.given);
|
||||
expect(result, description).toEqual(
|
||||
expect.objectContaining(test.expected)
|
||||
);
|
||||
const result = migrateConfig(given);
|
||||
expect(result, description).toEqual(expect.objectContaining(expected));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -131,5 +131,10 @@ export function replaceLegacyValues(
|
|||
) as ConfigSchemas.CustomLayoutFluid;
|
||||
}
|
||||
|
||||
if (typeof configObj.indicateTypos === "boolean") {
|
||||
configObj.indicateTypos =
|
||||
configObj.indicateTypos === false ? "off" : "replace";
|
||||
}
|
||||
|
||||
return configObj;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue