@@ -10,10 +10,10 @@ const DEFAULT_DARK = "dark";
1010const DEFAULT_LIGHT = "light" ;
1111const DEFAULT_SYSTEM = "system" ;
1212
13- function runThemeSwitchScript ( {
13+ function runSwitchScript ( {
1414 dark = DEFAULT_DARK ,
1515 light = DEFAULT_LIGHT ,
16- functionName = "themeSwitch " ,
16+ functionName = "colorSchemeSwitch " ,
1717 toggleKey = DEFAULT_TOGGLE_KEY ,
1818 matchMediaDarkMatches = false ,
1919 matchMediaLightMatches = false ,
@@ -102,7 +102,7 @@ describe("ColorSchemeSwitchScript.js IIFE behavior (three states)", () => {
102102 localStorage . setItem ( "colorScheme" , DEFAULT_DARK ) ;
103103 document . documentElement . classList . add ( DEFAULT_DARK ) ;
104104
105- runThemeSwitchScript ( ) ;
105+ runSwitchScript ( ) ;
106106 window . inlineScripts . switchColorScheme ( ) ;
107107
108108 expect ( document . documentElement . classList . contains ( DEFAULT_DARK ) ) . toBe ( false ) ;
@@ -112,7 +112,7 @@ describe("ColorSchemeSwitchScript.js IIFE behavior (three states)", () => {
112112 it ( "transitions from light to system with dark preference" , ( ) => {
113113 localStorage . setItem ( "colorScheme" , DEFAULT_LIGHT ) ;
114114
115- runThemeSwitchScript ( { matchMediaDarkMatches : true , matchMediaLightMatches : false } ) ;
115+ runSwitchScript ( { matchMediaDarkMatches : true , matchMediaLightMatches : false } ) ;
116116 window . inlineScripts . switchColorScheme ( ) ;
117117
118118 expect ( document . documentElement . classList . contains ( DEFAULT_DARK ) ) . toBe ( true ) ;
@@ -122,7 +122,7 @@ describe("ColorSchemeSwitchScript.js IIFE behavior (three states)", () => {
122122 it ( "transitions from light to system with light preference" , ( ) => {
123123 localStorage . setItem ( "colorScheme" , DEFAULT_LIGHT ) ;
124124
125- runThemeSwitchScript ( { matchMediaDarkMatches : false , matchMediaLightMatches : true } ) ;
125+ runSwitchScript ( { matchMediaDarkMatches : false , matchMediaLightMatches : true } ) ;
126126 window . inlineScripts . switchColorScheme ( ) ;
127127
128128 expect ( document . documentElement . classList . contains ( DEFAULT_DARK ) ) . toBe ( false ) ;
@@ -132,7 +132,7 @@ describe("ColorSchemeSwitchScript.js IIFE behavior (three states)", () => {
132132 it ( "transitions from light to system with no preference" , ( ) => {
133133 localStorage . setItem ( "colorScheme" , DEFAULT_LIGHT ) ;
134134
135- runThemeSwitchScript ( { matchMediaDarkMatches : false , matchMediaLightMatches : false } ) ;
135+ runSwitchScript ( { matchMediaDarkMatches : false , matchMediaLightMatches : false } ) ;
136136 window . inlineScripts . switchColorScheme ( ) ;
137137
138138 expect ( document . documentElement . classList . contains ( DEFAULT_DARK ) ) . toBe ( false ) ;
@@ -142,7 +142,7 @@ describe("ColorSchemeSwitchScript.js IIFE behavior (three states)", () => {
142142 it ( "transitions from system to dark" , ( ) => {
143143 localStorage . setItem ( "colorScheme" , DEFAULT_SYSTEM ) ;
144144
145- runThemeSwitchScript ( ) ;
145+ runSwitchScript ( ) ;
146146 window . inlineScripts . switchColorScheme ( ) ;
147147
148148 expect ( document . documentElement . classList . contains ( DEFAULT_DARK ) ) . toBe ( true ) ;
@@ -152,7 +152,7 @@ describe("ColorSchemeSwitchScript.js IIFE behavior (three states)", () => {
152152 it ( "transitions from undefined/empty to dark" , ( ) => {
153153 // No colorScheme set in localStorage
154154
155- runThemeSwitchScript ( ) ;
155+ runSwitchScript ( ) ;
156156 window . inlineScripts . switchColorScheme ( ) ;
157157
158158 expect ( document . documentElement . classList . contains ( DEFAULT_DARK ) ) . toBe ( true ) ;
@@ -163,7 +163,7 @@ describe("ColorSchemeSwitchScript.js IIFE behavior (three states)", () => {
163163 localStorage . setItem ( "colorScheme" , DEFAULT_DARK ) ;
164164 document . documentElement . classList . add ( DEFAULT_DARK ) ;
165165
166- runThemeSwitchScript ( { matchMediaDarkMatches : true } ) ;
166+ runSwitchScript ( { matchMediaDarkMatches : true } ) ;
167167
168168 // Dark -> Light
169169 window . inlineScripts . switchColorScheme ( ) ;
@@ -190,7 +190,7 @@ describe("ColorSchemeSwitchScript.js IIFE behavior (three states)", () => {
190190 const eventListener = vi . fn ( ) ;
191191 document . addEventListener ( "colorSchemeChanged" , eventListener ) ;
192192
193- runThemeSwitchScript ( ) ;
193+ runSwitchScript ( ) ;
194194 window . inlineScripts . switchColorScheme ( ) ;
195195
196196 expect ( eventListener ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -207,7 +207,7 @@ describe("ColorSchemeSwitchScript.js IIFE behavior (three states)", () => {
207207 const eventListener = vi . fn ( ) ;
208208 document . addEventListener ( "colorSchemeChanged" , eventListener ) ;
209209
210- runThemeSwitchScript ( ) ;
210+ runSwitchScript ( ) ;
211211 window . inlineScripts . switchColorScheme ( ) ;
212212
213213 expect ( eventListener ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -224,7 +224,7 @@ describe("ColorSchemeSwitchScript.js IIFE behavior (three states)", () => {
224224 localStorage . setItem ( "colorScheme" , DEFAULT_DARK ) ;
225225 document . documentElement . classList . add ( DEFAULT_DARK ) ;
226226
227- runThemeSwitchScript ( ) ;
227+ runSwitchScript ( ) ;
228228 dispatchKeydown ( DEFAULT_TOGGLE_KEY ) ;
229229
230230 expect ( document . documentElement . classList . contains ( DEFAULT_DARK ) ) . toBe ( false ) ;
@@ -235,7 +235,7 @@ describe("ColorSchemeSwitchScript.js IIFE behavior (three states)", () => {
235235 localStorage . setItem ( "colorScheme" , DEFAULT_DARK ) ;
236236 document . documentElement . classList . add ( DEFAULT_DARK ) ;
237237
238- runThemeSwitchScript ( ) ;
238+ runSwitchScript ( ) ;
239239
240240 dispatchKeydown ( DEFAULT_TOGGLE_KEY , { ctrlKey : true } ) ;
241241 expect ( localStorage . getItem ( "colorScheme" ) ) . toBe ( DEFAULT_DARK ) ;
@@ -251,7 +251,7 @@ describe("ColorSchemeSwitchScript.js IIFE behavior (three states)", () => {
251251 localStorage . setItem ( "colorScheme" , DEFAULT_DARK ) ;
252252 document . documentElement . classList . add ( DEFAULT_DARK ) ;
253253
254- runThemeSwitchScript ( { toggleKey : "t" } ) ;
254+ runSwitchScript ( { toggleKey : "t" } ) ;
255255
256256 // wrong key - no toggle
257257 dispatchKeydown ( DEFAULT_TOGGLE_KEY ) ;
@@ -267,7 +267,7 @@ describe("ColorSchemeSwitchScript.js IIFE behavior (three states)", () => {
267267 localStorage . setItem ( "colorScheme" , DEFAULT_DARK ) ;
268268 document . documentElement . classList . add ( DEFAULT_DARK ) ;
269269
270- runThemeSwitchScript ( ) ;
270+ runSwitchScript ( ) ;
271271
272272 // Create and focus an input element
273273 const input = document . createElement ( "input" ) ;
@@ -289,7 +289,7 @@ describe("ColorSchemeSwitchScript.js IIFE behavior (three states)", () => {
289289 localStorage . setItem ( "colorScheme" , DEFAULT_DARK ) ;
290290 document . documentElement . classList . add ( DEFAULT_DARK ) ;
291291
292- runThemeSwitchScript ( ) ;
292+ runSwitchScript ( ) ;
293293
294294 // Create and focus a textarea element
295295 const textarea = document . createElement ( "textarea" ) ;
@@ -311,7 +311,7 @@ describe("ColorSchemeSwitchScript.js IIFE behavior (three states)", () => {
311311 localStorage . setItem ( "colorScheme" , DEFAULT_DARK ) ;
312312 document . documentElement . classList . add ( DEFAULT_DARK ) ;
313313
314- runThemeSwitchScript ( ) ;
314+ runSwitchScript ( ) ;
315315
316316 // Create and focus a select element
317317 const select = document . createElement ( "select" ) ;
@@ -337,7 +337,7 @@ describe("ColorSchemeSwitchScript.js IIFE behavior (three states)", () => {
337337 localStorage . setItem ( "colorScheme" , DEFAULT_DARK ) ;
338338 document . documentElement . classList . add ( DEFAULT_DARK ) ;
339339
340- runThemeSwitchScript ( ) ;
340+ runSwitchScript ( ) ;
341341
342342 // Create and focus a contentEditable element
343343 const div = document . createElement ( "div" ) ;
@@ -361,7 +361,7 @@ describe("ColorSchemeSwitchScript.js IIFE behavior (three states)", () => {
361361 localStorage . setItem ( "colorScheme" , DEFAULT_DARK ) ;
362362 document . documentElement . classList . add ( DEFAULT_DARK ) ;
363363
364- runThemeSwitchScript ( ) ;
364+ runSwitchScript ( ) ;
365365
366366 // Create an input but don't focus it
367367 const input = document . createElement ( "input" ) ;
@@ -385,7 +385,7 @@ describe("ColorSchemeSwitchScript.js IIFE behavior (three states)", () => {
385385 const eventListener = vi . fn ( ) ;
386386 document . addEventListener ( "colorSchemeChanged" , eventListener ) ;
387387
388- runThemeSwitchScript ( ) ;
388+ runSwitchScript ( ) ;
389389 dispatchKeydown ( DEFAULT_TOGGLE_KEY ) ;
390390
391391 expect ( eventListener ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -402,8 +402,8 @@ describe("ColorSchemeSwitchScript.js IIFE behavior (three states)", () => {
402402 localStorage . setItem ( "colorScheme" , DEFAULT_DARK ) ;
403403
404404 expect ( ( ) => {
405- runThemeSwitchScript ( ) ;
406- runThemeSwitchScript ( ) ;
405+ runSwitchScript ( ) ;
406+ runSwitchScript ( ) ;
407407 } ) . not . toThrow ( ) ;
408408
409409 // Should still work after double initialization
@@ -418,7 +418,7 @@ describe("ColorSchemeSwitchScript.js IIFE behavior (three states)", () => {
418418 localStorage . setItem ( "colorScheme" , customDark ) ;
419419 document . documentElement . classList . add ( customDark ) ;
420420
421- runThemeSwitchScript ( { dark : customDark , light : customLight } ) ;
421+ runSwitchScript ( { dark : customDark , light : customLight } ) ;
422422 window . inlineScripts . switchColorScheme ( ) ;
423423
424424 expect ( document . documentElement . classList . contains ( customDark ) ) . toBe ( false ) ;
@@ -429,7 +429,7 @@ describe("ColorSchemeSwitchScript.js IIFE behavior (three states)", () => {
429429 localStorage . setItem ( "colorScheme" , DEFAULT_DARK ) ;
430430 document . documentElement . classList . add ( DEFAULT_DARK ) ;
431431
432- runThemeSwitchScript ( { matchMediaDarkMatches : true } ) ;
432+ runSwitchScript ( { matchMediaDarkMatches : true } ) ;
433433
434434 // Call multiple times rapidly
435435 window . inlineScripts . switchColorScheme ( ) ; // Dark -> Light
0 commit comments