✅ Assert the shape each handler receives
A handler's `expectTypeOf(shape)` only proved the type the compiler inferred; nothing observed the argument `dispatch` passed. Passing `String(shape)` at the call site therefore kept the whole suite green while breaking every key whose property name differs from its value (`true`, `null`, `1`). Pair each handler expectation with a runtime assertion: `assert.equal` where a handler runs for one shape, the disjunction over the set a `_` fallback accepts where it runs for several. Where the exact value matters the fallback returns its shape verbatim and the call site asserts it; a widening pattern absorbs the remainder type into the return union, so the claim stays strict-free. The mutation above now fails 10 of the 33 tests. Rule: CONTRIBUTING.md, rationale: development/testing.md § Handler arguments.
This commit is contained in:
1 parent
aa6d71076c
commit
9e03c52473
3 files changed
+109
-11
No files matched your search
+4
-1
@@ -66,7 +66,10 @@ before the implementation. The loop is **type → red → green → refactor**:
|
||||
4. **Refactor** — with the type system and the tests as the safety net, then
|
||||
`npm run verify` as the definition-of-done gate.
|
||||
|
||||
Every test pairs an `expectTypeOf(...)` with an `assert.*`; keep them together.
|
||||
Every test pairs an `expectTypeOf(...)` with an `assert.*`; keep them together
|
||||
— including the expectations inside handler bodies, which pair with an
|
||||
assertion on the value dispatch passed, not only the type it inferred (see
|
||||
[development/testing.md § Handler arguments](./development/testing.md#handler-arguments)).
|
||||
The autocomplete tests (`src/util/__tests__/lsp-completion.test.ts` for the
|
||||
helper, `src/primitive.test.ts` for the matcher's popup) are the
|
||||
exception —
|
||||
|
||||
Reference in new issue
Block a user