File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed
Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -157,7 +157,7 @@ describe("Config", () => {
157157 expect ( dispatchConfigEventMock ) . toHaveBeenCalledWith (
158158 "stopOnError" ,
159159 "off" ,
160- true ,
160+ false ,
161161 "letter"
162162 ) ;
163163
@@ -195,6 +195,35 @@ describe("Config", () => {
195195 expect . stringContaining ( "numbers" )
196196 ) ;
197197 } ) ;
198+
199+ it ( "saves configOverride values to localstorage if nosave=false" , async ( ) => {
200+ //GIVEN
201+ replaceConfig ( { } ) ;
202+
203+ //WHEN
204+ Config . genericSet ( "minWpmCustomSpeed" , 120 ) ;
205+
206+ //THEN
207+ //wait for debounce
208+ await vi . advanceTimersByTimeAsync ( 2500 ) ;
209+
210+ //save
211+ expect ( dbSaveConfigMock ) . toHaveBeenCalledWith ( {
212+ minWpmCustomSpeed : 120 ,
213+ minWpm : "custom" ,
214+ } ) ;
215+
216+ //send event
217+ expect ( dispatchConfigEventMock ) . toHaveBeenCalledWith (
218+ "saveToLocalStorage" ,
219+ expect . stringContaining ( "minWpmCustomSpeed" )
220+ ) ;
221+ expect ( dispatchConfigEventMock ) . toHaveBeenCalledWith (
222+ "saveToLocalStorage" ,
223+ expect . stringContaining ( "minWpm" )
224+ ) ;
225+ } ) ;
226+
198227 it ( "does not save to localstorage if nosave=true" , async ( ) => {
199228 //GIVEN
200229
Original file line number Diff line number Diff line change @@ -175,7 +175,7 @@ export function genericSet<T extends keyof ConfigSchemas.Config>(
175175 continue ; // no need to set if the value is already the same
176176 }
177177
178- const set = genericSet ( targetKey , targetValue , true ) ;
178+ const set = genericSet ( targetKey , targetValue , nosave ) ;
179179 if ( ! set ) {
180180 throw new Error (
181181 `Failed to set config key "${ targetKey } " with value "${ targetValue } " for ${ metadata . displayString } config override.`
You can’t perform that action at this time.
0 commit comments