Update README.md to provide a comprehensive overview of The Order monorepo, including repository structure, quickstart guide, development workflow, and contribution guidelines.
This commit is contained in:
21
packages/test-utils/README.md
Normal file
21
packages/test-utils/README.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# @the-order/test-utils
|
||||
|
||||
Shared testing utilities for The Order monorepo.
|
||||
|
||||
## Usage
|
||||
|
||||
```typescript
|
||||
import { createTestUser, createTestDocument, sleep } from '@the-order/test-utils';
|
||||
|
||||
const user = createTestUser({ email: 'custom@example.com' });
|
||||
const doc = createTestDocument({ title: 'My Document' });
|
||||
await sleep(1000);
|
||||
```
|
||||
|
||||
## Available Utilities
|
||||
|
||||
- `createTestUser()` - Create a test user object
|
||||
- `createTestDocument()` - Create a test document object
|
||||
- `sleep()` - Wait for a specified number of milliseconds
|
||||
- `createMockResponse()` - Create a mock fetch response
|
||||
|
||||
22
packages/test-utils/package.json
Normal file
22
packages/test-utils/package.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "@the-order/test-utils",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"description": "Shared testing utilities for The Order",
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"scripts": {
|
||||
"test": "vitest run",
|
||||
"test:watch": "vitest",
|
||||
"type-check": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vitest/ui": "^1.1.0",
|
||||
"vitest": "^1.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.10.6",
|
||||
"typescript": "^5.3.3"
|
||||
}
|
||||
}
|
||||
|
||||
62
packages/test-utils/src/index.ts
Normal file
62
packages/test-utils/src/index.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* Test utilities for The Order
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a test user object
|
||||
*/
|
||||
export function createTestUser(overrides?: Partial<TestUser>): TestUser {
|
||||
return {
|
||||
id: 'test-user-id',
|
||||
email: 'test@example.com',
|
||||
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;
|
||||
}
|
||||
|
||||
10
packages/test-utils/tsconfig.json
Normal file
10
packages/test-utils/tsconfig.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user