The task
src/lib/placement.ts exports slugify, assignSlugs and applyOverrides, and has no test
file. Add one.
Why this is a good first issue
slugify is the classic pure function — a string goes in, a URL-safe string comes out — and
assignSlugs builds on it. You can read the whole module in a couple of minutes and it needs no
setup.
Where the test goes
src/lib/placement.test.ts, beside the source. Read the implementation first and write tests for
what it actually does, not what you assume a slugifier does — the interesting cases are where
implementations differ.
Acceptance criteria
The one thing that matters here
Read the code before writing the test, and if slugify does something you find surprising, do
not "fix" it in the same PR. Pin the current behaviour and say in the PR description that you
found it surprising. Changing behaviour and adding its first test at the same time means nobody
can tell which of the two broke something later.
And break it on purpose before opening the PR — confirm your test goes red, then undo. Say which
mutation you tried; a test that cannot fail is the most common defect here (#396).
Getting set up
docker compose up -d
docker compose exec scripthammer pnpm test --run src/lib/placement.test.ts
The task
src/lib/placement.tsexportsslugify,assignSlugsandapplyOverrides, and has no testfile. Add one.
Why this is a good first issue
slugifyis the classic pure function — a string goes in, a URL-safe string comes out — andassignSlugsbuilds on it. You can read the whole module in a couple of minutes and it needs nosetup.
Where the test goes
src/lib/placement.test.ts, beside the source. Read the implementation first and write tests forwhat it actually does, not what you assume a slugifier does — the interesting cases are where
implementations differ.
Acceptance criteria
src/lib/placement.test.tsslugifycovered for: spaces, mixed case, punctuation, leading/trailing whitespace, and astring that is already a valid slug (it should come back unchanged)
assignSlugscovered for the case that actually matters: two inputs that slugify to thesame string. Whatever it does — suffix, dedupe, overwrite — pin it, because that is the
behaviour someone will accidentally change later
applyOverrideshas at least one casedocker compose exec scripthammer pnpm test --run src/lib/placement.test.tspassesThe one thing that matters here
Read the code before writing the test, and if
slugifydoes something you find surprising, donot "fix" it in the same PR. Pin the current behaviour and say in the PR description that you
found it surprising. Changing behaviour and adding its first test at the same time means nobody
can tell which of the two broke something later.
And break it on purpose before opening the PR — confirm your test goes red, then undo. Say which
mutation you tried; a test that cannot fail is the most common defect here (#396).
Getting set up