mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-02 18:10:18 +05:30
feat(renderer): useAppStore extended with modal discriminated union
This commit is contained in:
@@ -32,4 +32,33 @@ describe('useAppStore', () => {
|
||||
useAppStore.getState().setZenMode(true);
|
||||
expect(useAppStore.getState().zenMode).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('useAppStore (modal)', () => {
|
||||
beforeEach(() => {
|
||||
localStorage.clear();
|
||||
useAppStore.setState({
|
||||
sidebarVisible: true,
|
||||
previewVisible: true,
|
||||
zenMode: false,
|
||||
paneSizes: { sidebar: 20, editor: 50, preview: 30 },
|
||||
modal: { kind: null },
|
||||
} as any);
|
||||
});
|
||||
|
||||
it('openModal sets the modal state', () => {
|
||||
useAppStore.getState().openModal('about');
|
||||
expect(useAppStore.getState().modal).toEqual({ kind: 'about' });
|
||||
});
|
||||
|
||||
it('openModal with kind requiring props passes them through', () => {
|
||||
useAppStore.getState().openModal('export-pdf', { sourcePath: '/a.md' });
|
||||
expect(useAppStore.getState().modal).toEqual({ kind: 'export-pdf', props: { sourcePath: '/a.md' } });
|
||||
});
|
||||
|
||||
it('closeModal clears the modal state', () => {
|
||||
useAppStore.getState().openModal('about');
|
||||
useAppStore.getState().closeModal();
|
||||
expect(useAppStore.getState().modal).toEqual({ kind: null });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user