Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/api-testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# API Testing

The repository includes an API testing template for future backend packages.

## Current location

`tooling/api-test-template`

## Notes

- separates service and route tests
- includes a memory-backed repository helper for isolation
- keeps the template lightweight until the real API app lands
11 changes: 11 additions & 0 deletions tooling/api-test-template/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# API Test Template

This template provides a baseline testing structure for future API services and routes.

## Included pieces

- service test outline
- route integration test outline
- mock repository helper

The template is merge-safe and can be adopted when the API package is created.
16 changes: 16 additions & 0 deletions tooling/api-test-template/mock-repository.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export const createMemoryRepository = <T extends { id: string }>(seed: T[] = []) => {
const records = new Map(seed.map((record) => [record.id, record]));

return {
findById(id: string) {
return records.get(id) ?? null;
},
list() {
return Array.from(records.values());
},
save(record: T) {
records.set(record.id, record);
return record;
}
};
};
5 changes: 5 additions & 0 deletions tooling/api-test-template/routes.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe("capsule routes", () => {
it("returns a response for a valid request", () => {
expect(true).toBe(true);
});
});
5 changes: 5 additions & 0 deletions tooling/api-test-template/service.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe("capsule service", () => {
it("creates and transitions capsule drafts", () => {
expect(true).toBe(true);
});
});
Loading