Browse Source

Add test cases

Ben Hsieh 8 years ago
parent
commit
83b787070a
2 changed files with 8 additions and 6 deletions
  1. 7
    5
      test/benchmark.js
  2. 1
    1
      test/test-0.8.0.js

+ 7
- 5
test/benchmark.js View File

100
 })
100
 })
101
 
101
 
102
 
102
 
103
-false && describe('write file BASE64 v.s. URI', (report, done) => {
103
+describe('write file BASE64 v.s. URI', (report, done) => {
104
   let iteration = 200
104
   let iteration = 200
105
-  let target = `${TEST_SERVER_URL}/public/6mb-dummy`
105
+  let target = `${TEST_SERVER_URL}/public/12k-dummy`
106
   let sourceURI = dirs.DocumentDir + '/benchmark2-source'
106
   let sourceURI = dirs.DocumentDir + '/benchmark2-source'
107
+  let writeTarget = dirs.DocumentDir +'/benchmark2-target'
107
   let sourceBASE64 = null
108
   let sourceBASE64 = null
108
   let b64Res = 0
109
   let b64Res = 0
109
   let uriRes = 0
110
   let uriRes = 0
123
             <Info key="benchmark progress" uid="report2">
124
             <Info key="benchmark progress" uid="report2">
124
               <Text style={{textAlign:'center'}}>BASE64 {count}/{iteration}</Text>
125
               <Text style={{textAlign:'center'}}>BASE64 {count}/{iteration}</Text>
125
             </Info>)
126
             </Info>)
126
-          return fs.writeFile(dirs.DocumentDir +'/benchmark2-target', sourceBASE64, 'base64')
127
+          return fs.readFile(sourceURI, 'base64')
128
+                   .then((data) => fs.writeFile(writeTarget, data))
127
         }
129
         }
128
         else {
130
         else {
129
           b64Res = Date.now() - begin
131
           b64Res = Date.now() - begin
144
             <Info key="benchmark progress" uid="report2">
146
             <Info key="benchmark progress" uid="report2">
145
               <Text style={{textAlign:'center'}}>URI {count}/{iteration}</Text>
147
               <Text style={{textAlign:'center'}}>URI {count}/{iteration}</Text>
146
             </Info>)
148
             </Info>)
147
-          return fs.writeFile(dirs.DocumentDir +'/benchmark2-target', sourceURI, 'uri')
149
+          return fs.writeFile(writeTarget, sourceURI, 'uri')
148
         }
150
         }
149
         else {
151
         else {
150
           uriRes = Date.now() - begin
152
           uriRes = Date.now() - begin
168
 })
170
 })
169
 
171
 
170
 
172
 
171
-describe('read file benchmark', (report, done) => {
173
+false && describe('read file benchmark', (report, done) => {
172
 
174
 
173
   let iteration = 50
175
   let iteration = 50
174
   let target = `${TEST_SERVER_URL}/public/1mb-dummy`
176
   let target = `${TEST_SERVER_URL}/public/1mb-dummy`

+ 1
- 1
test/test-0.8.0.js View File

56
 })
56
 })
57
 
57
 
58
 describe('request timeout working properly', (report, done) => {
58
 describe('request timeout working properly', (report, done) => {
59
-  RNFetchBlob.config({ timeout : 1 })
59
+  RNFetchBlob.config({ timeout : 1000 })
60
   .fetch('GET', `${TEST_SERVER_URL}/timeout`)
60
   .fetch('GET', `${TEST_SERVER_URL}/timeout`)
61
   .then(() => {
61
   .then(() => {
62
     report(
62
     report(