mirror of
https://github.com/firstsun-dev/git-files-sync.git
synced 2026-07-22 17:20:30 +00:00
fix: ensure type-safe mocks in sync-manager.test.ts and resolve lint errors
This commit is contained in:
parent
bad9dad097
commit
a6104d991c
1 changed files with 12 additions and 20 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue