浏览代码

code refactor

Ben Hsieh 7 年前
父节点
当前提交
13c6d92de7
共有 3 个文件被更改,包括 6 次插入7 次删除
  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 查看文件

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

+ 3
- 2
src/ios/RNFetchBlobFS.m 查看文件

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

+ 2
- 2
test/test-xmlhttp.js 查看文件

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