@@ -136,3 +136,58 @@ describe('ThemeSelector - Custom Variations (Variation 4)', () => {
136136 expect ( onThemeChange ) . toHaveBeenCalledWith ( 'sunset' ) ;
137137 } ) ;
138138} ) ;
139+
140+ describe ( 'ThemeSelector responsive rendering' , ( ) => {
141+ const onThemeChange = vi . fn ( ) ;
142+
143+ afterEach ( ( ) => {
144+ vi . clearAllMocks ( ) ;
145+ } ) ;
146+
147+ it ( 'check if the root container holds its flex-col layout when switch from Dracula -> Neon' , ( ) => {
148+ const { container, rerender } = render (
149+ < ThemeSelector theme = "dracula" onThemeChange = { onThemeChange } />
150+ ) ;
151+ const root = container . firstChild as HTMLElement ;
152+ expect ( root . className ) . toContain ( 'flex-col' ) ;
153+
154+ rerender ( < ThemeSelector theme = "neon" onThemeChange = { onThemeChange } /> ) ;
155+ expect ( root . className ) . toContain ( 'flex-col' ) ;
156+ } ) ;
157+
158+ it ( 'check if active preset button updates when switching from Dracula to Neon' , ( ) => {
159+ const { rerender } = render ( < ThemeSelector theme = "dracula" onThemeChange = { onThemeChange } /> ) ;
160+
161+ expect (
162+ screen . getByRole ( 'button' , { name : / a p p l y d r a c u l a t h e m e / i } ) . getAttribute ( 'aria-pressed' )
163+ ) . toBe ( 'true' ) ;
164+
165+ rerender ( < ThemeSelector theme = "neon" onThemeChange = { onThemeChange } /> ) ;
166+
167+ expect (
168+ screen . getByRole ( 'button' , { name : / a p p l y n e o n t h e m e / i } ) . getAttribute ( 'aria-pressed' )
169+ ) . toBe ( 'true' ) ;
170+ expect (
171+ screen . getByRole ( 'button' , { name : / a p p l y d r a c u l a t h e m e / i } ) . getAttribute ( 'aria-pressed' )
172+ ) . toBe ( 'false' ) ;
173+ } ) ;
174+
175+ it ( 'check if select value reflects the active theme after switch Dracula -> Neon' , ( ) => {
176+ const { rerender } = render ( < ThemeSelector theme = "dracula" onThemeChange = { onThemeChange } /> ) ;
177+ const select = screen . getByRole ( 'combobox' ) as HTMLSelectElement ;
178+ expect ( select . value ) . toBe ( 'dracula' ) ;
179+
180+ rerender ( < ThemeSelector theme = "neon" onThemeChange = { onThemeChange } /> ) ;
181+ expect ( select . value ) . toBe ( 'neon' ) ;
182+ } ) ;
183+
184+ it ( 'colour swatches update to the new theme after switching' , ( ) => {
185+ const { rerender } = render ( < ThemeSelector theme = "dracula" onThemeChange = { onThemeChange } /> ) ;
186+ const draculaSwatches = screen . getAllByTitle ( / ^ ( b g | a c c e n t | t e x t ) : / i) ;
187+ expect ( draculaSwatches . length ) . toBe ( 3 ) ;
188+
189+ rerender ( < ThemeSelector theme = "neon" onThemeChange = { onThemeChange } /> ) ;
190+ // swatches should still be 3, now reflecting neon's palette
191+ expect ( screen . getAllByTitle ( / ^ ( b g | a c c e n t | t e x t ) : / i) . length ) . toBe ( 3 ) ;
192+ } ) ;
193+ } ) ;
0 commit comments