style: run prettier formatter over src and tests

This commit is contained in:
2026-06-11 20:46:00 +05:30
parent 2389d4f297
commit 6b564a4569
211 changed files with 6134 additions and 4234 deletions
+1 -1
View File
@@ -31,4 +31,4 @@ describe('AboutDialog', () => {
// closeModal sets modal.kind = null, so isOpen=false, Dialog unmounts
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
});
});
});
@@ -32,4 +32,4 @@ describe('AsciiGeneratorDialog', () => {
render(<AsciiGeneratorDialog />);
expect(screen.getByRole('button', { name: /copy/i })).toBeInTheDocument();
});
});
});
@@ -34,10 +34,8 @@ describe('ConfirmDialog', () => {
});
it('destructive variant uses destructive button class', () => {
render(
<ConfirmDialog title="T" body="B" destructive onConfirm={() => {}} />
);
render(<ConfirmDialog title="T" body="B" destructive onConfirm={() => {}} />);
const btn = screen.getByRole('button', { name: /confirm/i });
expect(btn.className).toContain('bg-destructive');
});
});
});
@@ -18,7 +18,12 @@ describe('CrashReportModal', () => {
test('lists crashes returned by ipc', async () => {
(ipc.crash.read as any).mockResolvedValue([
{ filename: '1700000000000-1-uncaughtException.json', kind: 'uncaughtException', message: 'boom', timestamp: '2026-01-01T00:00:00.000Z' },
{
filename: '1700000000000-1-uncaughtException.json',
kind: 'uncaughtException',
message: 'boom',
timestamp: '2026-01-01T00:00:00.000Z',
},
]);
render(<CrashReportModal onClose={() => {}} />);
expect(await screen.findByText(/boom/)).toBeInTheDocument();
@@ -26,12 +31,19 @@ describe('CrashReportModal', () => {
test('delete button calls ipc.crash.delete', async () => {
(ipc.crash.read as any).mockResolvedValue([
{ filename: '1700000000000-1-uncaughtException.json', kind: 'uncaughtException', message: 'boom', timestamp: '2026-01-01T00:00:00.000Z' },
{
filename: '1700000000000-1-uncaughtException.json',
kind: 'uncaughtException',
message: 'boom',
timestamp: '2026-01-01T00:00:00.000Z',
},
]);
render(<CrashReportModal onClose={() => {}} />);
const btn = await screen.findByText(/delete/i);
fireEvent.click(btn);
await waitFor(() => expect(ipc.crash.delete).toHaveBeenCalledWith('1700000000000-1-uncaughtException.json'));
await waitFor(() =>
expect(ipc.crash.delete).toHaveBeenCalledWith('1700000000000-1-uncaughtException.json')
);
});
test('open folder button calls ipc.crash.openDir', async () => {
@@ -40,4 +52,4 @@ describe('CrashReportModal', () => {
fireEvent.click(await screen.findByText(/open dump folder/i));
expect(ipc.crash.openDir).toHaveBeenCalled();
});
});
});
@@ -7,7 +7,14 @@ describe('ExportBatchDialog', () => {
beforeEach(() => {
localStorage.clear();
window.electronAPI = {
export: { batch: vi.fn().mockResolvedValue({ ok: true, data: { total: 2, succeeded: 2, failed: 0, results: [] } }) },
export: {
batch: vi
.fn()
.mockResolvedValue({
ok: true,
data: { total: 2, succeeded: 2, failed: 0, results: [] },
}),
},
} as any;
});
@@ -23,7 +30,10 @@ describe('ExportBatchDialog', () => {
await userEvent.click(screen.getByRole('option', { name: /^pdf$/i }));
await userEvent.click(screen.getByRole('button', { name: /^export$/i }));
const call = (window.electronAPI.export.batch as any).mock.calls[0];
expect(call[0]).toEqual([{ inputPath: '/a.md', outputPath: expect.any(String) }, { inputPath: '/b.md', outputPath: expect.any(String) }]);
expect(call[0]).toEqual([
{ inputPath: '/a.md', outputPath: expect.any(String) },
{ inputPath: '/b.md', outputPath: expect.any(String) },
]);
expect(call[1].format).toBe('pdf');
});
});
@@ -14,7 +14,13 @@ vi.mock('@/lib/ipc', () => ({
}));
vi.mock('@/lib/docx-export', () => ({
generateDocx: vi.fn().mockResolvedValue(new Blob([new Uint8Array(8)], { type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' })),
generateDocx: vi
.fn()
.mockResolvedValue(
new Blob([new Uint8Array(8)], {
type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
})
),
}));
import { ipc } from '@/lib/ipc';
@@ -31,8 +37,15 @@ describe('ExportDocxDialog', () => {
}));
(ipc.file.writeBuffer as any).mockResolvedValue({ ok: true });
useSettingsStore.setState(useSettingsStore.getInitialState());
useFileStore.setState({ activeTabId: '/test.md', openTabs: [{ id: '/test.md', path: '/test.md', title: 'test.md', dirty: false }] } as any);
useEditorStore.setState({ buffers: new Map([['/test.md', { id: '/test.md', path: '/test.md', content: '# hi', dirty: false }]]) } as any);
useFileStore.setState({
activeTabId: '/test.md',
openTabs: [{ id: '/test.md', path: '/test.md', title: 'test.md', dirty: false }],
} as any);
useEditorStore.setState({
buffers: new Map([
['/test.md', { id: '/test.md', path: '/test.md', content: '# hi', dirty: false }],
]),
} as any);
});
it('renders with standard template selected by default', () => {
@@ -25,8 +25,15 @@ describe('ExportHtmlDialog', () => {
}));
(ipc.file.writeBuffer as any).mockResolvedValue({ ok: true });
useSettingsStore.setState(useSettingsStore.getInitialState());
useFileStore.setState({ activeTabId: '/test.md', openTabs: [{ id: '/test.md', path: '/test.md', title: 'test.md', dirty: false }] } as any);
useEditorStore.setState({ buffers: new Map([['/test.md', { id: '/test.md', path: '/test.md', content: '# hi', dirty: false }]]) } as any);
useFileStore.setState({
activeTabId: '/test.md',
openTabs: [{ id: '/test.md', path: '/test.md', title: 'test.md', dirty: false }],
} as any);
useEditorStore.setState({
buffers: new Map([
['/test.md', { id: '/test.md', path: '/test.md', content: '# hi', dirty: false }],
]),
} as any);
});
it('renders with default github highlight style', () => {
@@ -22,8 +22,15 @@ describe('ExportPdfDialog', () => {
localStorage.clear();
vi.clearAllMocks();
useSettingsStore.setState(useSettingsStore.getInitialState());
useFileStore.setState({ activeTabId: '/test.md', openTabs: [{ id: '/test.md', path: '/test.md', title: 'test.md', dirty: false }] } as any);
useEditorStore.setState({ buffers: new Map([['/test.md', { id: '/test.md', path: '/test.md', content: '# hi', dirty: false }]]) } as any);
useFileStore.setState({
activeTabId: '/test.md',
openTabs: [{ id: '/test.md', path: '/test.md', title: 'test.md', dirty: false }],
} as any);
useEditorStore.setState({
buffers: new Map([
['/test.md', { id: '/test.md', path: '/test.md', content: '# hi', dirty: false }],
]),
} as any);
});
it('renders with default PDF options from settings', () => {
@@ -64,7 +64,10 @@ describe('FindInFilesDialog', () => {
});
it('shows an error banner when search fails', async () => {
(ipc.file.search as any).mockResolvedValueOnce({ ok: false, error: { code: 'E', message: 'regex invalid' } });
(ipc.file.search as any).mockResolvedValueOnce({
ok: false,
error: { code: 'E', message: 'regex invalid' },
});
render(<FindInFilesDialog />);
await userEvent.paste('[invalid', { initialSelectionStart: 0, initialSelectionEnd: 0 });
await userEvent.click(screen.getByRole('button', { name: /search/i }));
+1 -1
View File
@@ -29,4 +29,4 @@ describe('ModalLayer', () => {
expect(screen.queryByText(/about markdownconverter/i)).not.toBeInTheDocument();
expect(screen.getByText(/settings/i)).toBeInTheDocument();
});
});
});
@@ -55,4 +55,4 @@ describe('SettingsSheet', () => {
await userEvent.click(screen.getByRole('button', { name: /reset/i }));
expect(useSettingsStore.getState().fontSize).toBe(14);
});
});
});
@@ -33,4 +33,4 @@ describe('TableGeneratorDialog', () => {
render(<TableGeneratorDialog />);
expect(screen.getByRole('button', { name: /copy/i })).toBeInTheDocument();
});
});
});
@@ -47,7 +47,7 @@ describe('WelcomeDialog', () => {
// Effects that fire the warning run in a microtask; one tick is enough.
await Promise.resolve();
const offending = warnings.filter((w) =>
/Missing\s+`?Description`?|aria-describedby=\{undefined\}/.test(w),
/Missing\s+`?Description`?|aria-describedby=\{undefined\}/.test(w)
);
expect(offending).toEqual([]);
} finally {
@@ -7,7 +7,13 @@ import { useEditorStore } from '@/stores/editor-store';
import { useSettingsStore } from '@/stores/settings-store';
vi.mock('@/lib/docx-export', () => ({
generateDocx: vi.fn().mockResolvedValue(new Blob([new Uint8Array([1, 2, 3])], { type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' })),
generateDocx: vi
.fn()
.mockResolvedValue(
new Blob([new Uint8Array([1, 2, 3])], {
type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
})
),
}));
vi.mock('@/lib/toast', () => ({
@@ -37,8 +43,15 @@ describe('WordExportDialog', () => {
localStorage.clear();
vi.clearAllMocks();
useSettingsStore.setState(useSettingsStore.getInitialState());
useFileStore.setState({ activeTabId: '/test.md', openTabs: [{ id: '/test.md', path: '/test.md', title: 'test.md', dirty: false }] } as any);
useEditorStore.setState({ buffers: new Map([['/test.md', { id: '/test.md', path: '/test.md', content: '# hi', dirty: false }]]) } as any);
useFileStore.setState({
activeTabId: '/test.md',
openTabs: [{ id: '/test.md', path: '/test.md', title: 'test.md', dirty: false }],
} as any);
useEditorStore.setState({
buffers: new Map([
['/test.md', { id: '/test.md', path: '/test.md', content: '# hi', dirty: false }],
]),
} as any);
(ipc.app.showSaveDialog as any).mockResolvedValue({ ok: true, data: '/out.docx' });
(ipc.file.writeBuffer as any).mockResolvedValue({ ok: true });
});
@@ -58,14 +71,20 @@ describe('WordExportDialog', () => {
});
it('shows error message on write failure', async () => {
(ipc.file.writeBuffer as any).mockResolvedValue({ ok: false, error: { code: 'E', message: 'write failed' } });
(ipc.file.writeBuffer as any).mockResolvedValue({
ok: false,
error: { code: 'E', message: 'write failed' },
});
render(<WordExportDialog sourcePath="/test.md" />);
await userEvent.click(screen.getByRole('button', { name: /^export$/i }));
expect(await screen.findByText(/write failed/i)).toBeInTheDocument();
});
it('switches to custom template path when "Custom" is selected', async () => {
useSettingsStore.setState({ ...useSettingsStore.getInitialState(), docxCustomTemplatePath: '/my.dotx' });
useSettingsStore.setState({
...useSettingsStore.getInitialState(),
docxCustomTemplatePath: '/my.dotx',
});
render(<WordExportDialog sourcePath="/test.md" />);
expect(screen.getByText(/\/my\.dotx/)).toBeInTheDocument();
});