fix(test): resolve all TS lint errors in note-collaborators routes test — properly typed mock fns
This commit is contained in:
parent
338e80fc33
commit
b7bdfd97bc
@ -14,22 +14,25 @@ vi.mock('../../lib/embeddings.js', () => ({
|
||||
stripHtmlForEmbedding: vi.fn((s: string) => s.replace(/<[^>]*>/g, ' ').trim()),
|
||||
}));
|
||||
|
||||
const getNoteMock = vi.fn(async () => null);
|
||||
type NoteDoc = { id: string; userId?: string; productId?: string; title?: string; body?: string };
|
||||
type CollabDoc = Record<string, unknown>;
|
||||
|
||||
const getNoteMock = vi.fn<(id: string, userId: string) => Promise<NoteDoc | null>>();
|
||||
vi.mock('../notes/repository.js', () => ({
|
||||
getNote: (...args: unknown[]) => getNoteMock(...args),
|
||||
getNote: (...args: [string, string]) => getNoteMock(...args),
|
||||
}));
|
||||
|
||||
const createCollaboratorMock = vi.fn(async (doc: Record<string, unknown>) => doc);
|
||||
const listCollaboratorsForNoteMock = vi.fn(async () => []);
|
||||
const listSharedWithMeMock = vi.fn(async () => []);
|
||||
const findCollaboratorMock = vi.fn(async () => null);
|
||||
const deleteCollaboratorMock = vi.fn(async () => undefined);
|
||||
const createCollaboratorMock = vi.fn<(doc: CollabDoc) => Promise<CollabDoc>>();
|
||||
const listCollaboratorsForNoteMock = vi.fn<(noteId: string, productId: string) => Promise<CollabDoc[]>>();
|
||||
const listSharedWithMeMock = vi.fn<(userId: string, productId: string) => Promise<CollabDoc[]>>();
|
||||
const findCollaboratorMock = vi.fn<(noteId: string, userId: string, productId: string) => Promise<CollabDoc | null>>();
|
||||
const deleteCollaboratorMock = vi.fn<(id: string, partitionKey: string) => Promise<void>>();
|
||||
vi.mock('./repository.js', () => ({
|
||||
createCollaborator: (...args: unknown[]) => createCollaboratorMock(...args as [Record<string, unknown>]),
|
||||
listCollaboratorsForNote: (...args: unknown[]) => listCollaboratorsForNoteMock(...args),
|
||||
listSharedWithMe: (...args: unknown[]) => listSharedWithMeMock(...args),
|
||||
findCollaborator: (...args: unknown[]) => findCollaboratorMock(...args),
|
||||
deleteCollaborator: (...args: unknown[]) => deleteCollaboratorMock(...args),
|
||||
createCollaborator: (...args: [CollabDoc]) => createCollaboratorMock(...args),
|
||||
listCollaboratorsForNote: (...args: [string, string]) => listCollaboratorsForNoteMock(...args),
|
||||
listSharedWithMe: (...args: [string, string]) => listSharedWithMeMock(...args),
|
||||
findCollaborator: (...args: [string, string, string]) => findCollaboratorMock(...args),
|
||||
deleteCollaborator: (...args: [string, string]) => deleteCollaboratorMock(...args),
|
||||
}));
|
||||
|
||||
import { buildTestApp } from '../../test-helpers.js';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user