32 lines
913 B
TypeScript
32 lines
913 B
TypeScript
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
import { noteRelationshipRoutes } from './routes.js';
|
|
|
|
const { extractAuthMock } = vi.hoisted(() => ({
|
|
extractAuthMock: vi.fn(async () => ({ sub: 'user_1' })),
|
|
}));
|
|
|
|
vi.mock('../../lib/auth.js', () => ({ extractAuth: extractAuthMock }));
|
|
vi.mock('../../lib/product-config.js', () => ({ PRODUCT_ID: 'bytelyst-notes' }));
|
|
vi.mock('./repository.js', () => ({
|
|
listRelationships: vi.fn(async () => ({ items: [], total: 0 })),
|
|
createRelationship: vi.fn(async (doc: unknown) => doc),
|
|
}));
|
|
|
|
describe('noteRelationshipRoutes', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it('registers route handlers', async () => {
|
|
const app = {
|
|
get: vi.fn(),
|
|
post: vi.fn(),
|
|
};
|
|
|
|
await noteRelationshipRoutes(app as never);
|
|
|
|
expect(app.get).toHaveBeenCalledTimes(1);
|
|
expect(app.post).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|