| 
				
			 | 
			
			
				@@ -20,7 +20,7 @@ const describe = RNTest.config({ 
			 | 
		
	
		
			
			| 
				20
			 | 
			
				20
			 | 
			
			
				   expand : true, 
			 | 
		
	
		
			
			| 
				21
			 | 
			
				21
			 | 
			
			
				   timeout : 10000, 
			 | 
		
	
		
			
			| 
				22
			 | 
			
				22
			 | 
			
			
				 }) 
			 | 
		
	
		
			
			| 
				23
			 | 
			
				
			 | 
			
			
				-const { TEST_SERVER_URL_SSL, FILENAME, DROPBOX_TOKEN, styles } = prop() 
			 | 
		
	
		
			
			| 
				
			 | 
			
				23
			 | 
			
			
				+const { TEST_SERVER_URL, TEST_SERVER_URL_SSL, FILENAME, DROPBOX_TOKEN, styles } = prop() 
			 | 
		
	
		
			
			| 
				24
			 | 
			
				24
			 | 
			
			
				 const  dirs = RNFetchBlob.fs.dirs 
			 | 
		
	
		
			
			| 
				25
			 | 
			
				25
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				26
			 | 
			
				26
			 | 
			
			
				 let prefix = ((Platform.OS === 'android') ? 'file://' : '') 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -56,7 +56,71 @@ describe('fs URI encoding support', (report, done) => { 
			 | 
		
	
		
			
			| 
				56
			 | 
			
				56
			 | 
			
			
				 }) 
			 | 
		
	
		
			
			| 
				57
			 | 
			
				57
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				58
			 | 
			
				58
			 | 
			
			
				 describe('request timeout working properly', (report, done) => { 
			 | 
		
	
		
			
			| 
				59
			 | 
			
				
			 | 
			
			
				-  done() 
			 | 
		
	
		
			
			| 
				
			 | 
			
				59
			 | 
			
			
				+  RNFetchBlob.config({ timeout : 1 }) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				60
			 | 
			
			
				+  .fetch('GET', `${TEST_SERVER_URL}/timeout`) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				61
			 | 
			
			
				+  .then(() => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				62
			 | 
			
			
				+    report( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				63
			 | 
			
			
				+      <Assert 
			 | 
		
	
		
			
			| 
				
			 | 
			
				64
			 | 
			
			
				+        key="should not execute successfully" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				65
			 | 
			
			
				+        expect={true} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				66
			 | 
			
			
				+        actual={false}/>) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				67
			 | 
			
			
				+    done() 
			 | 
		
	
		
			
			| 
				
			 | 
			
				68
			 | 
			
			
				+  }) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				69
			 | 
			
			
				+  .catch((err) => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				70
			 | 
			
			
				+    report( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				71
			 | 
			
			
				+      <Assert 
			 | 
		
	
		
			
			| 
				
			 | 
			
				72
			 | 
			
			
				+        key="expect timeout error" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				73
			 | 
			
			
				+        expect={true} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				74
			 | 
			
			
				+        actual={/timed out/ig.test(err)}/>) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				75
			 | 
			
			
				+    done() 
			 | 
		
	
		
			
			| 
				
			 | 
			
				76
			 | 
			
			
				+  }) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				77
			 | 
			
			
				+}) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				78
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				79
			 | 
			
			
				+describe('regular request should have correct body', (report, done) => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				80
			 | 
			
			
				+  RNFetchBlob 
			 | 
		
	
		
			
			| 
				
			 | 
			
				81
			 | 
			
			
				+  .fetch('POST', `${TEST_SERVER_URL}/echo`, { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				82
			 | 
			
			
				+    'content-type' :  'text/foo', 
			 | 
		
	
		
			
			| 
				
			 | 
			
				83
			 | 
			
			
				+    foo : 'bar' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				84
			 | 
			
			
				+  }, 'foo is bar') 
			 | 
		
	
		
			
			| 
				
			 | 
			
				85
			 | 
			
			
				+  .then((res) => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				86
			 | 
			
			
				+    report( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				87
			 | 
			
			
				+      <Assert key="check headers" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				88
			 | 
			
			
				+        expect={'bar'} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				89
			 | 
			
			
				+        actual={res.json().headers.foo}/>, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				90
			 | 
			
			
				+      <Assert key="check content type" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				91
			 | 
			
			
				+        expect={'text/foo'} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				92
			 | 
			
			
				+        actual={res.json().headers['content-type']}/>, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				93
			 | 
			
			
				+      <Assert key="check body" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				94
			 | 
			
			
				+        expect={'foo is bar'} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				95
			 | 
			
			
				+        actual={res.json().body}/>) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				96
			 | 
			
			
				+    done() 
			 | 
		
	
		
			
			| 
				
			 | 
			
				97
			 | 
			
			
				+  }) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				98
			 | 
			
			
				+}) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				99
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				100
			 | 
			
			
				+describe('automatic content conversion test', (report, done) => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				101
			 | 
			
			
				+    let expect1 = `test-alpha-${Date.now()}` 
			 | 
		
	
		
			
			| 
				
			 | 
			
				102
			 | 
			
			
				+    let expect2 = `test-beta-${Date.now()}` 
			 | 
		
	
		
			
			| 
				
			 | 
			
				103
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				104
			 | 
			
			
				+    RNFetchBlob.fetch('POST', `${TEST_SERVER_URL}/echo`, { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				105
			 | 
			
			
				+      'Content-Type' : 'application/octet-foo', 
			 | 
		
	
		
			
			| 
				
			 | 
			
				106
			 | 
			
			
				+    }, RNFetchBlob.base64.encode(expect1)) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				107
			 | 
			
			
				+    .then((res) => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				108
			 | 
			
			
				+      report( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				109
			 | 
			
			
				+        <Assert key="request body should be decoded by BASE64 decoder" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				110
			 | 
			
			
				+          expect={expect1} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				111
			 | 
			
			
				+          actual={res.json().body}/>) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				112
			 | 
			
			
				+      return fs.writeFile(dirs.DocumentDir + '/test-0.8.0-auto', expect2, 'utf8') 
			 | 
		
	
		
			
			| 
				
			 | 
			
				113
			 | 
			
			
				+    }) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				114
			 | 
			
			
				+    .then(() => RNFetchBlob.fetch('POST', `${TEST_SERVER_URL}/echo`, { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				115
			 | 
			
			
				+        /* what ever the header is */ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				116
			 | 
			
			
				+    }, RNFetchBlob.wrap(dirs.DocumentDir + '/test-0.8.0-auto'))) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				117
			 | 
			
			
				+    .then((resp) => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				118
			 | 
			
			
				+      report( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				119
			 | 
			
			
				+        <Assert key="request body should send from storage" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				120
			 | 
			
			
				+          expect={expect2} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				121
			 | 
			
			
				+          actual={resp.json().body}/>) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				122
			 | 
			
			
				+      done() 
			 | 
		
	
		
			
			| 
				
			 | 
			
				123
			 | 
			
			
				+    }) 
			 | 
		
	
		
			
			| 
				60
			 | 
			
				124
			 | 
			
			
				 }) 
			 | 
		
	
		
			
			| 
				61
			 | 
			
				125
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				62
			 | 
			
				126
			 | 
			
			
				 function getASCIIArray(str) { 
			 |