refactor(theme): replace themeManager singleton with lazy getThemeManager
Convert the eager themeManager singleton to a getThemeManager() lazy accessor (+ __resetThemeManager for tests), so the persistent-store subscription is set up on first access rather than at module load. Update the barrel and consumers (Layout init/destroy, ThemeSwitch, story, test).
This commit is contained in:
@@ -3,16 +3,25 @@ import {
|
||||
render,
|
||||
screen,
|
||||
} from '@testing-library/svelte';
|
||||
import { themeManager } from '../../model';
|
||||
import { afterEach } from 'vitest';
|
||||
import { getThemeManager } from '../../model';
|
||||
import { __resetThemeManager } from '../../model/store/ThemeManager/ThemeManager.svelte';
|
||||
import ThemeSwitch from './ThemeSwitch.svelte';
|
||||
|
||||
const context = new Map([['responsive', { isMobile: false }]]);
|
||||
|
||||
describe('ThemeSwitch', () => {
|
||||
let themeManager: ReturnType<typeof getThemeManager>;
|
||||
|
||||
beforeEach(() => {
|
||||
themeManager = getThemeManager();
|
||||
themeManager.setTheme('light');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
__resetThemeManager();
|
||||
});
|
||||
|
||||
describe('Rendering', () => {
|
||||
it('renders an icon button', () => {
|
||||
render(ThemeSwitch, { context });
|
||||
|
||||
Reference in New Issue
Block a user