File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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} )
Original file line number Diff line number Diff 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} )
You can’t perform that action at this time.
0 commit comments