Bladeren bron

Add test cases

Ben Hsieh 8 jaren geleden
bovenliggende
commit
83b787070a
2 gewijzigde bestanden met toevoegingen van 8 en 6 verwijderingen
  1. 7
    5
      test/benchmark.js
  2. 1
    1
      test/test-0.8.0.js

+ 7
- 5
test/benchmark.js Bestand weergeven

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

+ 1
- 1
test/test-0.8.0.js Bestand weergeven

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