@@ -73,15 +73,13 @@ describe("ThemeInitScript.js IIFE behavior (three states)", () => {
7373 runThemeInitScript ( { matchMediaDarkMatches : false , matchMediaLightMatches : false } ) ;
7474
7575 expect ( document . documentElement . classList . contains ( DEFAULT_DARK ) ) . toBe ( true ) ;
76- expect ( document . documentElement . classList . contains ( DEFAULT_LIGHT ) ) . toBe ( false ) ;
7776 } ) ;
7877
79- it ( "adds light class when localStorage.colorScheme is light" , ( ) => {
78+ it ( "does not add dark class when localStorage.colorScheme is light" , ( ) => {
8079 localStorage . setItem ( "colorScheme" , DEFAULT_LIGHT ) ;
8180
8281 runThemeInitScript ( { matchMediaDarkMatches : false , matchMediaLightMatches : false } ) ;
8382
84- expect ( document . documentElement . classList . contains ( DEFAULT_LIGHT ) ) . toBe ( true ) ;
8583 expect ( document . documentElement . classList . contains ( DEFAULT_DARK ) ) . toBe ( false ) ;
8684 } ) ;
8785
@@ -90,14 +88,12 @@ describe("ThemeInitScript.js IIFE behavior (three states)", () => {
9088 runThemeInitScript ( { matchMediaDarkMatches : true , matchMediaLightMatches : false } ) ;
9189
9290 expect ( document . documentElement . classList . contains ( DEFAULT_DARK ) ) . toBe ( true ) ;
93- expect ( document . documentElement . classList . contains ( DEFAULT_LIGHT ) ) . toBe ( false ) ;
9491 } ) ;
9592
96- it ( "adds light class when no localStorage.colorScheme and prefers-color-scheme: light" , ( ) => {
93+ it ( "does not add dark class when no localStorage.colorScheme and prefers-color-scheme: light" , ( ) => {
9794 // No localStorage.colorScheme
9895 runThemeInitScript ( { matchMediaDarkMatches : false , matchMediaLightMatches : true } ) ;
9996
100- expect ( document . documentElement . classList . contains ( DEFAULT_LIGHT ) ) . toBe ( true ) ;
10197 expect ( document . documentElement . classList . contains ( DEFAULT_DARK ) ) . toBe ( false ) ;
10298 } ) ;
10399
@@ -106,7 +102,6 @@ describe("ThemeInitScript.js IIFE behavior (three states)", () => {
106102 runThemeInitScript ( { matchMediaDarkMatches : false , matchMediaLightMatches : false } ) ;
107103
108104 expect ( document . documentElement . classList . contains ( DEFAULT_DARK ) ) . toBe ( false ) ;
109- expect ( document . documentElement . classList . contains ( DEFAULT_LIGHT ) ) . toBe ( false ) ;
110105 } ) ;
111106
112107 it ( "is idempotent when executed twice" , ( ) => {
@@ -121,15 +116,12 @@ describe("ThemeInitScript.js IIFE behavior (three states)", () => {
121116 expect ( document . documentElement . classList . contains ( DEFAULT_DARK ) ) . toBe ( true ) ;
122117 } ) ;
123118
124- it ( "removes light class when switching to dark" , ( ) => {
125- // First set light
126- document . documentElement . classList . add ( DEFAULT_LIGHT ) ;
119+ it ( "adds dark class when switching to dark" , ( ) => {
127120 localStorage . setItem ( "colorScheme" , DEFAULT_DARK ) ;
128121
129122 runThemeInitScript ( { matchMediaDarkMatches : false , matchMediaLightMatches : false } ) ;
130123
131124 expect ( document . documentElement . classList . contains ( DEFAULT_DARK ) ) . toBe ( true ) ;
132- expect ( document . documentElement . classList . contains ( DEFAULT_LIGHT ) ) . toBe ( false ) ;
133125 } ) ;
134126
135127 it ( "removes dark class when switching to light" , ( ) => {
@@ -139,7 +131,6 @@ describe("ThemeInitScript.js IIFE behavior (three states)", () => {
139131
140132 runThemeInitScript ( { matchMediaDarkMatches : false , matchMediaLightMatches : false } ) ;
141133
142- expect ( document . documentElement . classList . contains ( DEFAULT_LIGHT ) ) . toBe ( true ) ;
143134 expect ( document . documentElement . classList . contains ( DEFAULT_DARK ) ) . toBe ( false ) ;
144135 } ) ;
145136} ) ;
0 commit comments