@@ -32,15 +32,15 @@ describe('writeFile and readFile test', (report, done) => {
3232 . then ( ( ) => fs . readFile ( path , 'utf8' ) )
3333 . then ( ( actual ) => {
3434 report ( < Assert key = "utf8 content should correct" expect = { data } actual = { actual } /> )
35- data + = 'base64'
35+ data = 'base64'
3636 return fs . writeFile ( path , RNFetchBlob . base64 . encode ( 'base64' ) , 'base64' )
3737 } )
3838 . then ( ( ) => fs . readFile ( path , 'base64' ) )
3939 . then ( ( actual ) => {
4040 report ( < Assert key = "base64 content should correct"
4141 expect = { RNFetchBlob . base64 . decode ( RNFetchBlob . base64 . encode ( data ) ) }
4242 actual = { RNFetchBlob . base64 . decode ( actual ) } /> )
43- data + = 'ascii'
43+ data = 'ascii'
4444 return fs . writeFile ( path , getASCIIArray ( 'ascii' ) , 'ascii' ) ;
4545 } )
4646 . then ( ( ) => fs . readFile ( path , 'ascii' ) )
@@ -54,8 +54,34 @@ describe('writeFile and readFile test', (report, done) => {
5454} )
5555
5656describe ( 'append file test' , ( report , done ) => {
57+ let path = dirs . DocumentDir + '/append-test' + Date . now ( )
58+ let content = 'test on ' + Date . now ( )
59+ fs . writeFile ( path , content , 'utf8' )
60+ . then ( ( ) => fs . appendFile ( path , '100' , 'utf8' , true ) )
61+ . then ( ( ) => fs . readFile ( path , 'utf8' ) )
62+ . then ( ( data ) => {
63+ report (
64+ < Assert key = "utf8 data should be appended"
65+ expect = { content + '100' }
66+ actual = { data } /> )
67+ return fs . appendFile ( path , getASCIIArray ( '200' ) , 'ascii' )
68+ } )
69+ . then ( ( ) => fs . readFile ( path , 'ascii' ) )
70+ . then ( ( data ) => {
71+ report ( < Assert key = "ascii data should be appended"
72+ expect = { getASCIIArray ( content + '100' + '200' ) }
73+ comparer = { Comparer . equalToArray }
74+ actual = { data } /> )
75+ return fs . appendFile ( path , RNFetchBlob . base64 . encode ( '300' ) , 'base64' )
76+ } )
77+ . then ( ( ) => fs . readFile ( path , 'base64' ) )
78+ . then ( ( data ) => {
79+ report ( < Assert key = "base64 data should be appended"
80+ expect = { content + '100' + '200' + '300' }
81+ actual = { RNFetchBlob . base64 . decode ( data ) } /> )
82+ done ( )
83+ } )
5784
58- // TODO
5985} )
6086
6187function getASCIIArray ( str ) {
0 commit comments