Skip to content

test: harden ky create test and cover delete/list routes - #119

Open
whitewofe wants to merge 1 commit into
tscircuit:mainfrom
whitewofe:test/ky-await-and-coverage
Open

test: harden ky create test and cover delete/list routes#119
whitewofe wants to merge 1 commit into
tscircuit:mainfrom
whitewofe:test/ky-await-and-coverage

Conversation

@whitewofe

Copy link
Copy Markdown

Summary

/claim #2

Builds on the prior ky-migration test work by removing the remaining race in the create test and filling in coverage for the two things routes that had no tests.

tests/routes/things/create.test.ts

  • Awaits the ky.post("things/create", …) call so the create completes before things/list runs (previously fire-and-forget, the assertion only passed by accident on fast paths).
  • Asserts the create response body equals { ok: true }.
  • After listing, verifies the persisted name, description, and that thing_id is a non-empty string — covers the full create → persist → list contract.

tests/routes/things/delete.test.ts (new)

  • Creates two things, deletes one by thing_id via URL-encoded form data, asserts { ok: true } and that only the surviving thing remains.
  • Adds a no-op case: deleting a non-existent thing_id still returns { ok: true } and leaves existing data untouched.

tests/routes/things/list.test.ts (new)

  • Empty-list case returns { things: [] }.
  • Multi-create case verifies things come back in insertion order and that thing_id values are unique and monotonically increasing (matches the idCounter behavior in lib/db/db-client.ts).

Validation

$ bun test
 6 pass
 0 fail
 21 expect() calls

$ bun run format:check
 Checked 24 files in 12ms. No fixes applied.

No production code changed; tests only.

Closes #2

- create.test.ts: await ky.post, assert {ok:true}, verify persisted
  thing_id/name/description so the create+list sequence is deterministic.
- delete.test.ts (new): covers happy-path deletion via URLSearchParams
  body and a no-op when thing_id is not present.
- list.test.ts (new): covers empty-list response and insertion-order
  with monotonically increasing thing_id from the db idCounter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Switch to ky from redaxios

1 participant