Skip to content

Commit e4519f4

Browse files
committed
test(ThemeSelector): add responsive rendering suite for Dracula/Neon preset switching
1 parent 6ede310 commit e4519f4

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

app/customize/components/ThemeSelector.test.tsx

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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: /apply dracula theme/i }).getAttribute('aria-pressed')
163+
).toBe('true');
164+
165+
rerender(<ThemeSelector theme="neon" onThemeChange={onThemeChange} />);
166+
167+
expect(
168+
screen.getByRole('button', { name: /apply neon theme/i }).getAttribute('aria-pressed')
169+
).toBe('true');
170+
expect(
171+
screen.getByRole('button', { name: /apply dracula theme/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(/^(bg|accent|text):/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(/^(bg|accent|text):/i).length).toBe(3);
192+
});
193+
});

0 commit comments

Comments
 (0)