fix: ensure type-safe mocks in sync-manager.test.ts and resolve lint errors

This commit is contained in:
ClaudiaFang 2026-04-25 03:34:57 +00:00
parent bad9dad097
commit a6104d991c

View file

@ -98,13 +98,13 @@ describe('SyncManager', () => {
// Capture the callback passed to the modal
let callback: (choice: 'local' | 'remote') => void = () => { };
modalMock.mockImplementation(function (this: any, app: App, file: TFile, local: string, remote: string, onChoose: (choice: 'local' | 'remote') => void) {
modalMock.mockImplementation(function (this: SyncConflictModal, app: App, fileName: string, local: string, remote: string, onChoose: (choice: 'local' | 'remote') => void) {
callback = onChoose;
this.open = vi.fn();
this.close = vi.fn();
this.app = app;
this.setTitle = vi.fn().mockReturnThis();
} as any);
(this as unknown as Record<string, unknown>).open = vi.fn();
(this as unknown as Record<string, unknown>).close = vi.fn();
(this as unknown as Record<string, unknown>).app = app;
(this as unknown as Record<string, unknown>).setTitle = vi.fn().mockReturnThis();
});
await manager.pushFile(mockFile);
@ -130,21 +130,13 @@ describe('SyncManager', () => {
const modalMock = vi.mocked(SyncConflictModal);
let callback: (choice: 'local' | 'remote') => void = () => { };
modalMock.mockImplementation(((app: App, file: TFile, local: string, remote: string, onChoose: (choice: 'local' | 'remote') => void) => {
modalMock.mockImplementation(function (this: SyncConflictModal, app: App, fileName: string, local: string, remote: string, onChoose: (choice: 'local' | 'remote') => void) {
callback = onChoose;
return {
open: vi.fn(),
close: vi.fn(),
app,
scope: {} as any,
containerEl: {} as HTMLElement,
contentEl: {} as HTMLElement,
titleEl: {} as HTMLElement,
onOpen: vi.fn(),
onClose: vi.fn(),
setTitle: vi.fn().mockReturnThis(),
} as unknown as SyncConflictModal;
}) as any);
(this as unknown as Record<string, unknown>).open = vi.fn();
(this as unknown as Record<string, unknown>).close = vi.fn();
(this as unknown as Record<string, unknown>).app = app;
(this as unknown as Record<string, unknown>).setTitle = vi.fn().mockReturnThis();
});
await manager.pushFile(mockFile);