import { describe, expect, it } from "vitest"
import { csvEscape, rowsToCsv } from "@/lib/csv"

describe("csvEscape", () => {
  it("escapes quotes and commas", () => {
    expect(csvEscape('a,b')).toBe('"a,b"')
    expect(csvEscape('a"b')).toBe('"a""b"')
    expect(csvEscape('simple')).toBe('simple')
  })
})

describe("rowsToCsv", () => {
  it("joins rows and columns with newline and commas", () => {
    const csv = rowsToCsv([["A", "B"], [1, 2]])
    expect(csv).toBe("A,B\n1,2\n")
  })
})

