Browse Source

code refactor

Ben Hsieh 7 years ago
parent
commit
13c6d92de7
3 changed files with 6 additions and 7 deletions
  1. 1
    3
      src/index.js
  2. 3
    2
      src/ios/RNFetchBlobFS.m
  3. 2
    2
      test/test-xmlhttp.js

+ 1
- 3
src/index.js View File

@@ -172,9 +172,7 @@ function fetch(...args:any):Promise {
172 172
       delete promise['uploadProgress']
173 173
       delete promise['stateChange']
174 174
       delete promise['cancel']
175
-      promise.cancel = () => {
176
-        console.warn('finished request could not be canceled')
177
-      }
175
+      promise.cancel = () => {}
178 176
 
179 177
       if(err)
180 178
         reject(new Error(err, respInfo))

+ 3
- 2
src/ios/RNFetchBlobFS.m View File

@@ -390,7 +390,7 @@ NSMutableDictionary *fileStreams = nil;
390 390
 # pragma mark - stat
391 391
 
392 392
 + (NSDictionary *) stat:(NSString *) path error:(NSError **) error {
393
-    NSMutableDictionary *stat = [[NSMutableDictionary alloc] init];
393
+    
394 394
     BOOL isDir = NO;
395 395
     NSFileManager * fm = [NSFileManager defaultManager];
396 396
     if([fm fileExistsAtPath:path isDirectory:&isDir] == NO) {
@@ -407,7 +407,8 @@ NSMutableDictionary *fileStreams = nil;
407 407
              @"path" : path,
408 408
              @"lastModified" : [NSString stringWithFormat:@"%d", [lastModified timeIntervalSince1970]],
409 409
              @"type" : isDir ? @"directory" : @"file"
410
-             };
410
+            };
411
+    
411 412
 }
412 413
 
413 414
 # pragma mark - exists

+ 2
- 2
test/test-xmlhttp.js View File

@@ -157,7 +157,7 @@ describe('request headers records should be cleared by open()', (report, done) =
157 157
     if(this.readyState == 4) {
158 158
       report(<Assert key="headers should be cleared by open()"
159 159
         expect={"200"}
160
-        actual={this.response.value}/>)
160
+        actual={JSON.parse(this.response).value}/>)
161 161
       done()
162 162
     }
163 163
   }
@@ -243,7 +243,7 @@ describe('upload progress event test', (report, done) => {
243 243
       report(
244 244
         <Assert key="reponse should correct"
245 245
           expect={time}
246
-          actual={Math.floor(xhr.response.time)}/>,
246
+          actual={Math.floor(JSON.parse(xhr.response).time)}/>,
247 247
         <Assert key="responseType should correct"
248 248
           expect={'json'}
249 249
           actual={xhr.responseType}/>)