@@ -28,7 +28,77 @@ const dirs = RNFetchBlob.fs.dirs
28
28
29
29
let prefix = ( ( Platform . OS === 'android' ) ? 'file://' : '' )
30
30
31
- describe ( 'issue #122 force response data format' , ( report , done ) => {
31
+ // describe('issue #122 force response data format', (report, done) => {
32
+ //
33
+ // RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/public/json-dummy.json`, {
34
+ // 'RNFB-Response' : 'base64'
35
+ // })
36
+ // .then((res) => {
37
+ // let r = RNFetchBlob.base64.decode(res.data)
38
+ // report(
39
+ // <Assert key="test data verify" expect="fetchblob-dev" actual={JSON.parse(r).name}/>,
40
+ // <Assert key="should successfully decode the data" expect={true} actual={true}/>)
41
+ // return RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/public/json-dummy.json`)
42
+ // })
43
+ // .then((res) => {
44
+ // report(
45
+ // <Assert key="response should in format of plain-text" expect="fetchblob-dev" actual={JSON.parse(res.data).name}/>)
46
+ // done()
47
+ // })
48
+ // .catch(() => {
49
+ // report(
50
+ // <Assert key="Should successfully decode the data" expect={true} actual={false}/>)
51
+ // done()
52
+ // })
53
+ //
54
+ // })
55
+
56
+ // describe('#129 memory leaking when enable uploadProgress', (report, done) => {
57
+ //
58
+ // let file = null
59
+ // let count = 0
60
+ //
61
+ // RNFetchBlob.config({ fileCache : true })
62
+ // .fetch('GET', `${TEST_SERVER_URL}/public/6mb-dummy`)
63
+ // .then((res) => {
64
+ // file = res.path()
65
+ // setTimeout(() => {
66
+ // for(let i=0;i<20;i++){
67
+ // RNFetchBlob.fetch('POST', `${TEST_SERVER_URL}/upload`, {}, RNFetchBlob.wrap(file))
68
+ // .uploadProgress(() => {})
69
+ // .then(() => {
70
+ // if(count > 20) {
71
+ // fs.unlink(file)
72
+ // report(<Assert key="finished" expect={true} actual={true}/>)
73
+ // done()
74
+ // }
75
+ // })
76
+ // }
77
+ // }, 3000)
78
+ // })
79
+ //
80
+ // })
81
+
82
+ describe ( '#131 status code != 200 should not throw an error' , ( report , done ) => {
83
+
84
+ let count = 0
85
+ let codes = [ 404 , 500 , 501 , 403 ]
86
+
87
+ codes . forEach ( ( code ) => {
88
+
89
+ RNFetchBlob . fetch ( 'GET' , `${ TEST_SERVER_URL } /xhr-code/${ code } ` , {
90
+ 'Cache-Control' : 'no-store'
91
+ } )
92
+ . then ( function ( res ) {
93
+ report ( < Assert key = { `status code should be ${ this } ` } expect = { Math . floor ( this ) } actual = { Math . floor ( res . info ( ) . status ) } /> )
94
+ count ++
95
+ if ( count >= 4 )
96
+ done ( )
97
+ } . bind ( code ) )
98
+ . catch ( function ( err ) {
99
+ report ( < Assert key = { `status code ${ this } should not cause error` } expect = { true } actual = { false } /> )
100
+ count ++
101
+ } . bind ( code ) )
32
102
33
103
} )
34
104
0 commit comments