You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(csv): add unit tests for toCsv escaping (comma, quote, newline) #196
Add unit tests for the CSV serializer in web/src/lib/csv.ts.
It's a small, pure function with clear escaping rules — an ideal first test
suite.
⚠️Blocked by #195 — this needs the Vitest setup from #195 to be merged
first. Please don't start until the test runner exists, otherwise there's
nothing to run the tests with.
What to do
Add web/src/lib/csv.test.ts covering toCsv (and its escape behavior via
the public output). Suggested cases:
Plain values pass through unquoted (e.g. hello → hello).
Comma in a value triggers quoting (e.g. a,b → "a,b").
Double quote in a value is doubled and the field is quoted
(e.g. she said "hi" → "she said ""hi""").
Newline in a value triggers quoting (e.g. line1\nline2 → "line1\nline2").
null and undefined become empty strings.
Header row is emitted first, joined by commas.
Column order follows the headers array, and a missing key in a row
produces an empty field.
Multiple rows are joined by \n.
Acceptance
cd web && yarn test runs the new suite and it passes.
Cases above are all covered.
No changes to csv.ts itself — this is test-only. (If a genuine bug is found
while testing, note it in a separate issue rather than changing behavior here.)
Activity
gkhngyk commentedon Jun 8, 2026
Part of the test-infrastructure epic #125 (item 4). Blocked by #195.