소스 검색

Add fs test cases #18

Ben Hsieh 8 년 전
부모
커밋
c27fbb16b9
4개의 변경된 파일19개의 추가작업 그리고 14개의 파일을 삭제
  1. 1
    1
      test/test-0.1.x-0.4.x.js
  2. 1
    1
      test/test-0.5.x.js
  3. 16
    11
      test/test-fs.js
  4. 1
    1
      test/test-init.js

+ 1
- 1
test/test-0.1.x-0.4.x.js 파일 보기

@@ -14,7 +14,7 @@ const { Assert, Comparer, Info, prop } = RNTest
14 14
 const describe = RNTest.config({
15 15
   group : '0.1.x - 0.4.x',
16 16
   expand : false,
17
-  run : false
17
+  run : true
18 18
 })
19 19
 
20 20
 let { TEST_SERVER_URL, FILENAME, DROPBOX_TOKEN, styles, image } = prop()

+ 1
- 1
test/test-0.5.x.js 파일 보기

@@ -16,7 +16,7 @@ const fs = RNFetchBlob.fs
16 16
 const { Assert, Comparer, Info, prop } = RNTest
17 17
 const describe = RNTest.config({
18 18
   group : '0.5.x',
19
-  run : false,
19
+  run : true,
20 20
   expand : false,
21 21
 })
22 22
 const { TEST_SERVER_URL, FILENAME, DROPBOX_TOKEN, styles } = prop()

+ 16
- 11
test/test-fs.js 파일 보기

@@ -132,15 +132,19 @@ describe('create file API test', (report, done) => {
132 132
 
133 133
 describe('mkdir and isDir API test', (report, done) => {
134 134
   let p = dirs.DocumentDir + '/mkdir-test-' + Date.now()
135
-  fs.mkdir(p + '/mkdir').then((err) => {
135
+  fs.mkdir(p).then((err) => {
136 136
     report(<Assert key="folder should be created without error"
137 137
       expect={undefined}
138 138
       actual={err} />)
139
-    return fs.isDir(p + '/mkdir')
139
+    return fs.exists(p)
140
+  })
141
+  .then((exist) => {
142
+    report(<Assert key="mkdir should work correctly" expect={true} actual={exist} />)
143
+    return fs.isDir(p)
140 144
   })
141 145
   .then((isDir) => {
142 146
     report(<Assert key="isDir should work correctly" expect={true} actual={isDir} />)
143
-    return fs.mkdir(p + '/mkdir')
147
+    return fs.mkdir(p)
144 148
   })
145 149
   .then()
146 150
   .catch((err) => {
@@ -164,14 +168,14 @@ describe('unlink and mkdir API test', (report, done) => {
164 168
   })
165 169
   .then((exist) => {
166 170
     report(<Assert key="file removed" expect={false} actual={exist} />)
167
-    return fs.mkdir(p + '/dir')
171
+    return fs.mkdir(p + '-dir')
168 172
   })
169
-  .then((err) => fs.exists(p + '/dir'))
173
+  .then((err) => fs.exists(p + '-dir'))
170 174
   .then((exist) => {
171 175
     report(<Assert key="mkdir should success" expect={true} actual={exist} />)
172
-    return fs.unlink(p + '/dir')
176
+    return fs.unlink(p + '-dir')
173 177
   })
174
-  .then(() => fs.exists(p + '/dir'))
178
+  .then(() => fs.exists(p + '-dir'))
175 179
   .then((exist) => {
176 180
     report(<Assert key="folder should be removed" expect={false} actual={exist} />)
177 181
     done()
@@ -209,9 +213,9 @@ describe('write stream API test', (report, done) => {
209 213
     fs.writeStream(p, 'base64', false)
210 214
     .then((ws) => {
211 215
       for(let i = 0; i< 100; i++) {
212
-        expect += RNFetchBlob.base64.encode(i)
213
-        ws.write(RNFetchBlob.base64.encode(i))
216
+        expect += String(i)
214 217
       }
218
+      ws.write(RNFetchBlob.base64.encode(expect))
215 219
       return ws.close()
216 220
     })
217 221
     .then(() => {
@@ -221,10 +225,11 @@ describe('write stream API test', (report, done) => {
221 225
         d2 += chunk
222 226
       })
223 227
       rs.onEnd(() => {
228
+        console.log(RNFetchBlob.base64.encode(expect),d2)
224 229
         report(
225 230
           <Assert key="file should be overwritten by base64 encoded data"
226
-            expect={expect}
227
-            actual={RNFetchBlob.base64.decode(d2)} />)
231
+            expect={RNFetchBlob.base64.encode(expect)}
232
+            actual={d2} />)
228 233
         done()
229 234
       })
230 235
     })

+ 1
- 1
test/test-init.js 파일 보기

@@ -18,7 +18,7 @@ const { Assert, Comparer, Info, describe, prop } = RNTest
18 18
 // test environment variables
19 19
 
20 20
 prop('FILENAME', `${Platform.OS}-0.5.0-${Date.now()}.png`)
21
-prop('TEST_SERVER_URL', 'http://192.168.16.70:8123')
21
+prop('TEST_SERVER_URL', 'http://192.168.0.14:8123')
22 22
 prop('DROPBOX_TOKEN', 'fsXcpmKPrHgAAAAAAAAAoXZhcXYWdgLpQMan6Tb_bzJ237DXhgQSev12hA-gUXt4')
23 23
 prop('styles', {
24 24
   image : {