Browse Source

Add test case #72

Ben Hsieh 8 years ago
parent
commit
3c9d0d9992
1 changed files with 24 additions and 1 deletions
  1. 24
    1
      test/test-0.8.2.js

+ 24
- 1
test/test-0.8.2.js View File

13
 } from 'react-native';
13
 } from 'react-native';
14
 
14
 
15
 window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest
15
 window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest
16
-window.Blob = Blob
16
+window.Blob = RNFetchBlob.polyfill.Blob
17
 window.fetch = new RNFetchBlob.polyfill.Fetch({
17
 window.fetch = new RNFetchBlob.polyfill.Fetch({
18
   auto : true,
18
   auto : true,
19
   binaryContentTypes : ['image/', 'video/', 'audio/']
19
   binaryContentTypes : ['image/', 'video/', 'audio/']
46
     done()
46
     done()
47
   })
47
   })
48
 })
48
 })
49
+
50
+RNTest.config({
51
+  group : '0.8.2',
52
+  run : true,
53
+  expand : false,
54
+  timeout : 24000
55
+})('request should not retry after timed out', (report, done) => {
56
+
57
+  let count = 0
58
+  RNFetchBlob
59
+    .config({ timeout : 3000 })
60
+    .fetch('GET', `${TEST_SERVER_URL}/timeout`)
61
+    .then((res) => {
62
+      report(<Assert key="request should not success" expect={true} actual={false}/>)
63
+    })
64
+    .catch(() => {
65
+      count ++
66
+    })
67
+  setTimeout(() => {
68
+    report(<Assert key="request does not retry" expect={1} actual={count}/>)
69
+    done()
70
+  }, 12000)
71
+})