@@ -32,15 +32,15 @@ describe('writeFile and readFile test', (report, done) => {
32
32
. then ( ( ) => fs . readFile ( path , 'utf8' ) )
33
33
. then ( ( actual ) => {
34
34
report ( < Assert key = "utf8 content should correct" expect = { data } actual = { actual } /> )
35
- data + = 'base64'
35
+ data = 'base64'
36
36
return fs . writeFile ( path , RNFetchBlob . base64 . encode ( 'base64' ) , 'base64' )
37
37
} )
38
38
. then ( ( ) => fs . readFile ( path , 'base64' ) )
39
39
. then ( ( actual ) => {
40
40
report ( < Assert key = "base64 content should correct"
41
41
expect = { RNFetchBlob . base64 . decode ( RNFetchBlob . base64 . encode ( data ) ) }
42
42
actual = { RNFetchBlob . base64 . decode ( actual ) } /> )
43
- data + = 'ascii'
43
+ data = 'ascii'
44
44
return fs . writeFile ( path , getASCIIArray ( 'ascii' ) , 'ascii' ) ;
45
45
} )
46
46
. then ( ( ) => fs . readFile ( path , 'ascii' ) )
@@ -54,8 +54,34 @@ describe('writeFile and readFile test', (report, done) => {
54
54
} )
55
55
56
56
describe ( '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
+ } )
57
84
58
- // TODO
59
85
} )
60
86
61
87
function getASCIIArray ( str ) {
0 commit comments