The task
src/utils/colorblind-matrices.ts exports the colour-blindness simulation matrices and the
helpers that turn them into SVG filter strings. It has no test file. Add one.
Why this is a good first issue
COLORBLIND_MATRICES is data, and matrixToSVGString, getColorblindMatrixString and
isValidColorMatrix are pure functions over it. No DOM, no network. It also backs a real
accessibility feature, so the tests are worth having rather than busywork.
Where the test goes
src/utils/colorblind-matrices.test.ts, beside the source.
Acceptance criteria
Skip this one
measureFilterPerformance uses performance.now() and is about timing rather than logic. Leave
it out — timing assertions are flaky and this repo has actively removed them (#300).
The one thing that matters here
The isValidColorMatrix both-directions requirement is the whole point. Then break something on
purpose — corrupt one matrix in the data, or make the validator always return true — and
confirm your test goes red. Say which mutation you tried in the PR. A gate that cannot fail is
the most common defect in this repo (#396).
Getting set up
docker compose up -d
docker compose exec scripthammer pnpm test --run src/utils/colorblind-matrices.test.ts
The task
src/utils/colorblind-matrices.tsexports the colour-blindness simulation matrices and thehelpers that turn them into SVG filter strings. It has no test file. Add one.
Why this is a good first issue
COLORBLIND_MATRICESis data, andmatrixToSVGString,getColorblindMatrixStringandisValidColorMatrixare pure functions over it. No DOM, no network. It also backs a realaccessibility feature, so the tests are worth having rather than busywork.
Where the test goes
src/utils/colorblind-matrices.test.ts, beside the source.Acceptance criteria
src/utils/colorblind-matrices.test.tsCOLORBLIND_MATRICESis validated — iterate the object rather thanhardcoding a list of types, so a matrix added later is covered automatically
isValidColorMatrixis tested in both directions: a real matrix passes, and amalformed one (wrong length, a non-number) fails. A validator only ever seen saying "yes"
has not been shown to work
matrixToSVGStringproduces the expected shape for a known matrixgetColorblindMatrixStringreturns something sensible for each supported typedocker compose exec scripthammer pnpm test --run src/utils/colorblind-matrices.test.tspassesSkip this one
measureFilterPerformanceusesperformance.now()and is about timing rather than logic. Leaveit out — timing assertions are flaky and this repo has actively removed them (#300).
The one thing that matters here
The
isValidColorMatrixboth-directions requirement is the whole point. Then break something onpurpose — corrupt one matrix in the data, or make the validator always return
true— andconfirm your test goes red. Say which mutation you tried in the PR. A gate that cannot fail is
the most common defect in this repo (#396).
Getting set up