Commit Graph

1 Commits

Author SHA1 Message Date
simoleo89 bb28d252d8 Vitest: +16 cases on ColorUtils, FixedSizeStack, LocalizeFormattedNumber
49 -> 65 passing tests, 4 -> 5 test files.

New file: tests/api-utils-extra.test.ts (16 cases)
- LocalizeFormattedNumber (3): zero/NaN/null guard, sub-1000 stays,
  >=1000 inserts thin-space group separators.
- ColorUtils (8): makeColorHex, makeColorNumberHex (with zero-pad),
  convertFromHex (with/without #), int_to_8BitVals/eight_bitVals_to_int
  roundtrip, int2rgb pure-RGB output, zero-input edge cases.
- FixedSizeStack (4): grow then overwrite oldest (ring-buffer
  semantics), reset clears state, partial-fill behavior of getMax,
  empty-stack returns Number.MIN_VALUE. The "partial-fill" case
  documents a subtle quirk: getMax iterates the whole maxSize window
  including undefined slots, but `undefined > X` is false in JS so
  the inserted value wins — the test pins that behavior.

Note on `usePetPackageWidget` and `useWordQuizWidget`
- They were both considered for a state/actions split this turn but
  their actions mutate internal state (`onClose` resets 5 useState,
  `vote` reads pollId/question/answerSent). A clean split would
  require either passing args to the action or hoisting the state
  to a shared store first. Deferred as follow-up.

Verification
- yarn test: 5 files / 65 cases / ~1.9s.
- yarn eslint on the new test file: 0 errors / 0 warnings.
2026-05-11 17:50:47 +00:00