Skip to content

Commit 74d7c5f

Browse files
committed
Add tests
1 parent 93d7830 commit 74d7c5f

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

tests/csv-test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,27 @@ Deno.test("writes a csv file", async () => {
3333
const csv = await readCSV(csvWritePath)
3434

3535
assertArrayIncludes(csv, [{ age: "70", name: "Rick" }]);
36+
})
37+
Deno.test("appends to a csv file", async () => {
38+
const data = [
39+
{
40+
age: 70,
41+
name: 'Rick'
42+
},
43+
{
44+
age: 14,
45+
name: 'Smith'
46+
}
47+
]
48+
await writeCSV(csvWritePath, data)
49+
const data2 = [
50+
{
51+
age: 42,
52+
name: 'Jodi'
53+
}
54+
]
55+
await writeCSV(csvWritePath, data2, { append: true })
56+
const csv = await readCSV(csvWritePath)
57+
assertArrayIncludes(csv, [{ age: "70", name: "Rick" }])
58+
assertArrayIncludes(csv, [{ age: "42", name: "Jodi" }])
3659
})

tests/txt-test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,15 @@ Deno.test("writes a txt file", async () => {
1717
const txt = await readTXT(jsonWritePath)
1818

1919
assertStringIncludes(txt, content);
20+
})
21+
22+
Deno.test("appends to a txt file", async () => {
23+
const content = 'Write to a file'
24+
const content2 = 'Append to a file'
25+
await writeTXT(jsonWritePath, content)
26+
await writeTXT(jsonWritePath, content2, { append: true })
27+
const txt = await readTXT(jsonWritePath)
28+
29+
assertStringIncludes(txt, content);
30+
assertStringIncludes(txt, content2);
2031
})

0 commit comments

Comments
 (0)