diff --git a/docs/api-testing.md b/docs/api-testing.md new file mode 100644 index 0000000..1438a4d --- /dev/null +++ b/docs/api-testing.md @@ -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 diff --git a/tooling/api-test-template/README.md b/tooling/api-test-template/README.md new file mode 100644 index 0000000..8df61fd --- /dev/null +++ b/tooling/api-test-template/README.md @@ -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. diff --git a/tooling/api-test-template/mock-repository.ts b/tooling/api-test-template/mock-repository.ts new file mode 100644 index 0000000..a16ff6b --- /dev/null +++ b/tooling/api-test-template/mock-repository.ts @@ -0,0 +1,16 @@ +export const createMemoryRepository = (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; + } + }; +}; diff --git a/tooling/api-test-template/routes.test.ts b/tooling/api-test-template/routes.test.ts new file mode 100644 index 0000000..c64ad86 --- /dev/null +++ b/tooling/api-test-template/routes.test.ts @@ -0,0 +1,5 @@ +describe("capsule routes", () => { + it("returns a response for a valid request", () => { + expect(true).toBe(true); + }); +}); diff --git a/tooling/api-test-template/service.test.ts b/tooling/api-test-template/service.test.ts new file mode 100644 index 0000000..10d15ab --- /dev/null +++ b/tooling/api-test-template/service.test.ts @@ -0,0 +1,5 @@ +describe("capsule service", () => { + it("creates and transitions capsule drafts", () => { + expect(true).toBe(true); + }); +});