Something went wrong. Try again.
An atproto AppView for tracking a Magic: The Gathering collection github.com/eth0net/manaweb
appview atproto mtg rust typescript
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031import { expect, test } from "bun:test";import { parse } from "../import/csv";import { write } from "./csv";
test("a field carrying a comma is quoted", () => { expect(write([["Baba Lysaga, Night Witch", "b"]])).toBe( '"Baba Lysaga, Night Witch",b\n', );});
test("a quote is doubled and the field quoted", () => { expect(write([['Ach! Hans, "Run!"']])).toBe('"Ach! Hans, ""Run!"""\n');});
test("a line break keeps its field together", () => { expect(write([["one\ntwo", "b"]])).toBe('"one\ntwo",b\n');});
test("nothing else is quoted", () => { expect(write([["a", "", "c"]])).toBe("a,,c\n");});
test("what is written is what reads back", () => { const rows = [ ["Name", "Note"], ["Baba Lysaga, Night Witch", 'Ach! Hans, "Run!"'], ["Ordinary", "one\ntwo"], ]; expect(parse(write(rows))).toEqual(rows);});