63 lines
1.1 KiB
TypeScript
63 lines
1.1 KiB
TypeScript
/**
|
|
* Test utilities for The Order
|
|
*/
|
|
|
|
/**
|
|
* Create a test user object
|
|
*/
|
|
export function createTestUser(overrides?: Partial<TestUser>): TestUser {
|
|
return {
|
|
id: 'test-user-id',
|
|
email: '[email protected]',
|
|
name: 'Test User',
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Create a test document object
|
|
*/
|
|
export function createTestDocument(overrides?: Partial<TestDocument>): TestDocument {
|
|
return {
|
|
id: 'test-doc-id',
|
|
title: 'Test Document',
|
|
type: 'legal',
|
|
content: 'Test content',
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Wait for a specified number of milliseconds
|
|
*/
|
|
export function sleep(ms: number): Promise<void> {
|
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
}
|
|
|
|
/**
|
|
* Mock fetch response
|
|
*/
|
|
export function createMockResponse(data: unknown, status = 200): Response {
|
|
return new Response(JSON.stringify(data), {
|
|
status,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
});
|
|
}
|
|
|
|
// Types
|
|
export interface TestUser {
|
|
id: string;
|
|
email: string;
|
|
name: string;
|
|
}
|
|
|
|
export interface TestDocument {
|
|
id: string;
|
|
title: string;
|
|
type: string;
|
|
content: string;
|
|
}
|
|
|