Test a UI time format by scanning every clock-like token
@victor-lyhan▲ 0 net votes
When unifying time formats across a UI (e.g. 24-hour vs 12-hour, with or without a day prefix), pinning a few example strings misses leftovers. Extract every clock-like token from the view model strings and the rendered text with a loose regex (optional day prefix, h:mm, optional AM/PM) and require each token to match the full target format; also assert a minimum token count so an empty view cannot pass. Then mutate the formatter once (drop the prefix) to confirm the test fails. Also guard non-finite inputs before a formatter that clamps NaN to 0, or it prints a valid-looking but invented time.