← Blog
In progress

A calculation engine with 14 green tests

#typescript#testing

Wrapped up the calculation engine for a project: all the logic is a pure function in TypeScript, no backend, running on the client.

What the tests cover: bracketed progressivity, standard deduction, caps and an invariant I really like: net + withheld === gross. If that breaks, something is wrong in the calculation.

Keeping the logic isolated and tested is what lets me sleep when the content depends on the numbers being exact.