fix(test): resolve all TS lint errors in note-collaborators routes test — properly typed mock fns

This commit is contained in:
saravanakumardb1 2026-04-06 20:56:20 -07:00
parent 338e80fc33
commit b7bdfd97bc

View File

@ -14,22 +14,25 @@ vi.mock('../../lib/embeddings.js', () => ({
stripHtmlForEmbedding: vi.fn((s: string) => s.replace(/<[^>]*>/g, ' ').trim()), 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', () => ({ 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 createCollaboratorMock = vi.fn<(doc: CollabDoc) => Promise<CollabDoc>>();
const listCollaboratorsForNoteMock = vi.fn(async () => []); const listCollaboratorsForNoteMock = vi.fn<(noteId: string, productId: string) => Promise<CollabDoc[]>>();
const listSharedWithMeMock = vi.fn(async () => []); const listSharedWithMeMock = vi.fn<(userId: string, productId: string) => Promise<CollabDoc[]>>();
const findCollaboratorMock = vi.fn(async () => null); const findCollaboratorMock = vi.fn<(noteId: string, userId: string, productId: string) => Promise<CollabDoc | null>>();
const deleteCollaboratorMock = vi.fn(async () => undefined); const deleteCollaboratorMock = vi.fn<(id: string, partitionKey: string) => Promise<void>>();
vi.mock('./repository.js', () => ({ vi.mock('./repository.js', () => ({
createCollaborator: (...args: unknown[]) => createCollaboratorMock(...args as [Record<string, unknown>]), createCollaborator: (...args: [CollabDoc]) => createCollaboratorMock(...args),
listCollaboratorsForNote: (...args: unknown[]) => listCollaboratorsForNoteMock(...args), listCollaboratorsForNote: (...args: [string, string]) => listCollaboratorsForNoteMock(...args),
listSharedWithMe: (...args: unknown[]) => listSharedWithMeMock(...args), listSharedWithMe: (...args: [string, string]) => listSharedWithMeMock(...args),
findCollaborator: (...args: unknown[]) => findCollaboratorMock(...args), findCollaborator: (...args: [string, string, string]) => findCollaboratorMock(...args),
deleteCollaborator: (...args: unknown[]) => deleteCollaboratorMock(...args), deleteCollaborator: (...args: [string, string]) => deleteCollaboratorMock(...args),
})); }));
import { buildTestApp } from '../../test-helpers.js'; import { buildTestApp } from '../../test-helpers.js';