mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-17 02:56:16 +08:00
fix: custom min speed mode setting not saving between sessions
closes #6890
This commit is contained in:
parent
6f50752b69
commit
14ce657273
2 changed files with 31 additions and 2 deletions
|
@ -157,7 +157,7 @@ describe("Config", () => {
|
|||
expect(dispatchConfigEventMock).toHaveBeenCalledWith(
|
||||
"stopOnError",
|
||||
"off",
|
||||
true,
|
||||
false,
|
||||
"letter"
|
||||
);
|
||||
|
||||
|
@ -195,6 +195,35 @@ describe("Config", () => {
|
|||
expect.stringContaining("numbers")
|
||||
);
|
||||
});
|
||||
|
||||
it("saves configOverride values to localstorage if nosave=false", async () => {
|
||||
//GIVEN
|
||||
replaceConfig({});
|
||||
|
||||
//WHEN
|
||||
Config.genericSet("minWpmCustomSpeed", 120);
|
||||
|
||||
//THEN
|
||||
//wait for debounce
|
||||
await vi.advanceTimersByTimeAsync(2500);
|
||||
|
||||
//save
|
||||
expect(dbSaveConfigMock).toHaveBeenCalledWith({
|
||||
minWpmCustomSpeed: 120,
|
||||
minWpm: "custom",
|
||||
});
|
||||
|
||||
//send event
|
||||
expect(dispatchConfigEventMock).toHaveBeenCalledWith(
|
||||
"saveToLocalStorage",
|
||||
expect.stringContaining("minWpmCustomSpeed")
|
||||
);
|
||||
expect(dispatchConfigEventMock).toHaveBeenCalledWith(
|
||||
"saveToLocalStorage",
|
||||
expect.stringContaining("minWpm")
|
||||
);
|
||||
});
|
||||
|
||||
it("does not save to localstorage if nosave=true", async () => {
|
||||
//GIVEN
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ export function genericSet<T extends keyof ConfigSchemas.Config>(
|
|||
continue; // no need to set if the value is already the same
|
||||
}
|
||||
|
||||
const set = genericSet(targetKey, targetValue, true);
|
||||
const set = genericSet(targetKey, targetValue, nosave);
|
||||
if (!set) {
|
||||
throw new Error(
|
||||
`Failed to set config key "${targetKey}" with value "${targetValue}" for ${metadata.displayString} config override.`
|
||||
|
|
Loading…
Add table
Reference in a new issue