1- import { describe , it , expect , afterEach , vi } from "vitest" ;
2- import { canSetConfigWithCurrentFunboxes } from "../../../src/ts/test/funbox /funbox-validation" ;
1+ import { describe , it , expect } from "vitest" ;
2+ import { canSetConfigWithCurrentFunboxes } from "../../../src/ts/config /funbox-validation" ;
33
4- import * as Notifications from "../../../src/ts/states/notifications" ;
54import { FunboxName } from "@monkeytype/schemas/configs" ;
65describe ( "funbox-validation" , ( ) => {
76 describe ( "canSetConfigWithCurrentFunboxes" , ( ) => {
8- const addNotificationMock = vi . spyOn (
9- Notifications ,
10- "showNoticeNotification" ,
11- ) ;
12- afterEach ( ( ) => {
13- addNotificationMock . mockClear ( ) ;
14- } ) ;
15-
167 const testCases = [
178 //checks for frontendForcedConfig
189 {
1910 key : "mode" ,
2011 value : "zen" ,
2112 funbox : [ "memory" ] ,
22- error : "You can't set mode to zen with currently active funboxes." ,
13+ expected : false ,
2314 } ,
24- { key : "mode" , value : "words" , funbox : [ "memory" ] } , //ok
15+ { key : "mode" , value : "words" , funbox : [ "memory" ] , expected : true } ,
2516
2617 //checks for zen mode
2718 ...[
@@ -40,10 +31,15 @@ describe("funbox-validation", () => {
4031 key : "mode" ,
4132 value : "zen" ,
4233 funbox : [ funbox ] ,
43- error : "You can't set mode to zen with currently active funboxes." ,
34+ expected : false ,
4435 } ) ) ,
45- { key : "mode" , value : "zen" , funbox : [ "mirror" ] } , //ok
46- { key : "mode" , value : "zen" , funbox : [ "space_balls" ] } , //no frontendFunctions
36+ { key : "mode" , value : "zen" , funbox : [ "mirror" ] , expected : true } ,
37+ {
38+ key : "mode" ,
39+ value : "zen" ,
40+ funbox : [ "space_balls" ] ,
41+ expected : true ,
42+ } ,
4743
4844 //checks for words and custom
4945 ...[ "quote" , "custom" ] . flatMap ( ( value ) =>
@@ -56,23 +52,22 @@ describe("funbox-validation", () => {
5652 key : "mode" ,
5753 value,
5854 funbox : [ funbox ] ,
59- error : `You can't set mode to ${ value } with currently active funboxes.` ,
55+ expected : false ,
6056 } ) ) ,
6157 ) ,
62- { key : "mode" , value : "quote" , funbox : [ "space_balls" ] } , //no frontendFunctions
58+ {
59+ key : "mode" ,
60+ value : "quote" ,
61+ funbox : [ "space_balls" ] ,
62+ expected : true ,
63+ } ,
6364 ] ;
6465 it . for ( testCases ) (
6566 `check $funbox with $key=$value` ,
66- ( { key, value, funbox, error } ) => {
67+ ( { key, value, funbox, expected } ) => {
6768 expect (
6869 canSetConfigWithCurrentFunboxes ( key , value , funbox as FunboxName [ ] ) ,
69- ) . toBe ( error === undefined ) ;
70-
71- if ( error !== undefined ) {
72- expect ( addNotificationMock ) . toHaveBeenCalledWith ( error , {
73- durationMs : 5000 ,
74- } ) ;
75- }
70+ ) . toBe ( expected ) ;
7671 } ,
7772 ) ;
7873 } ) ;
0 commit comments