| 
				
			 | 
			
			
				@@ -45,47 +45,20 @@ describe('Upload and download large file', (report, done) => { 
			 | 
		
	
		
			
			| 
				45
			 | 
			
				45
			 | 
			
			
				     deb = Date.now() 
			 | 
		
	
		
			
			| 
				46
			 | 
			
				46
			 | 
			
			
				     report(<Info uid="200" key="progress"> 
			 | 
		
	
		
			
			| 
				47
			 | 
			
				47
			 | 
			
			
				       <Text> 
			 | 
		
	
		
			
			| 
				48
			 | 
			
				
			 | 
			
			
				-        {`download ${now} / ${total} bytes (${Math.floor(now / (Date.now() - begin))} kb/s)`} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				48
			 | 
			
			
				+        {`download ${now} / ${total} bytes (${Math.floor(now / (Date.now() - begin))} kb/s) ${(100*now/total).toFixed(2)}%`} 
			 | 
		
	
		
			
			| 
				49
			 | 
			
				49
			 | 
			
			
				       </Text> 
			 | 
		
	
		
			
			| 
				50
			 | 
			
				50
			 | 
			
			
				     </Info>) 
			 | 
		
	
		
			
			| 
				51
			 | 
			
				51
			 | 
			
			
				   }) 
			 | 
		
	
		
			
			| 
				52
			 | 
			
				52
			 | 
			
			
				   .then((res) => { 
			 | 
		
	
		
			
			| 
				53
			 | 
			
				53
			 | 
			
			
				     bigfile = res.path() 
			 | 
		
	
		
			
			| 
				
			 | 
			
				54
			 | 
			
			
				+    return fs.stat(bigfile) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				55
			 | 
			
			
				+  }) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				56
			 | 
			
			
				+  .then((stat) => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				57
			 | 
			
			
				+    report(<Info key="big file stat"> 
			 | 
		
	
		
			
			| 
				
			 | 
			
				58
			 | 
			
			
				+      <Text>{JSON.stringify(stat)}</Text> 
			 | 
		
	
		
			
			| 
				
			 | 
			
				59
			 | 
			
			
				+    </Info>) 
			 | 
		
	
		
			
			| 
				54
			 | 
			
				60
			 | 
			
			
				     done() 
			 | 
		
	
		
			
			| 
				55
			 | 
			
				61
			 | 
			
			
				   }) 
			 | 
		
	
		
			
			| 
				56
			 | 
			
				
			 | 
			
			
				-  // .then((res) => { 
			 | 
		
	
		
			
			| 
				57
			 | 
			
				
			 | 
			
			
				-  //   bigfile = res.path() 
			 | 
		
	
		
			
			| 
				58
			 | 
			
				
			 | 
			
			
				-  //   try { 
			 | 
		
	
		
			
			| 
				59
			 | 
			
				
			 | 
			
			
				-  //   deb = Date.now() 
			 | 
		
	
		
			
			| 
				60
			 | 
			
				
			 | 
			
			
				-  //   let promise =  RNFetchBlob.fetch('POST', 'https://content.dropboxapi.com/2/files/upload', { 
			 | 
		
	
		
			
			| 
				61
			 | 
			
				
			 | 
			
			
				-  //     Authorization : `Bearer ${DROPBOX_TOKEN}`, 
			 | 
		
	
		
			
			| 
				62
			 | 
			
				
			 | 
			
			
				-  //     'Dropbox-API-Arg': '{\"path\": \"/rn-upload/'+filename+'\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}', 
			 | 
		
	
		
			
			| 
				63
			 | 
			
				
			 | 
			
			
				-  //     'Content-Type' : 'application/octet-stream', 
			 | 
		
	
		
			
			| 
				64
			 | 
			
				
			 | 
			
			
				-  //   }, RNFetchBlob.wrap(res.path())) 
			 | 
		
	
		
			
			| 
				65
			 | 
			
				
			 | 
			
			
				-  //   promise.uploadProgress((now, total) => { 
			 | 
		
	
		
			
			| 
				66
			 | 
			
				
			 | 
			
			
				-  //     if(Date.now() - deb < 1000) 
			 | 
		
	
		
			
			| 
				67
			 | 
			
				
			 | 
			
			
				-  //       return 
			 | 
		
	
		
			
			| 
				68
			 | 
			
				
			 | 
			
			
				-  //     deb = Date.now() 
			 | 
		
	
		
			
			| 
				69
			 | 
			
				
			 | 
			
			
				-  //     if(begin2 === -1) 
			 | 
		
	
		
			
			| 
				70
			 | 
			
				
			 | 
			
			
				-  //       begin2 = Date.now() 
			 | 
		
	
		
			
			| 
				71
			 | 
			
				
			 | 
			
			
				-  //     let speed = Math.floor(now / (Date.now() - begin2)) 
			 | 
		
	
		
			
			| 
				72
			 | 
			
				
			 | 
			
			
				-  //     report(<Info uid="100"  key="progress"> 
			 | 
		
	
		
			
			| 
				73
			 | 
			
				
			 | 
			
			
				-  //       <Text> 
			 | 
		
	
		
			
			| 
				74
			 | 
			
				
			 | 
			
			
				-  //         {`upload ${now} / ${total} bytes (${speed} kb/s)`} 
			 | 
		
	
		
			
			| 
				75
			 | 
			
				
			 | 
			
			
				-  //         {` ${Math.floor((total-now)/speed/1000)} seconds left`} 
			 | 
		
	
		
			
			| 
				76
			 | 
			
				
			 | 
			
			
				-  //       </Text> 
			 | 
		
	
		
			
			| 
				77
			 | 
			
				
			 | 
			
			
				-  //     </Info>) 
			 | 
		
	
		
			
			| 
				78
			 | 
			
				
			 | 
			
			
				-  //   }) 
			 | 
		
	
		
			
			| 
				79
			 | 
			
				
			 | 
			
			
				-  //   return promise 
			 | 
		
	
		
			
			| 
				80
			 | 
			
				
			 | 
			
			
				-  // } catch(err) { console.log(err) } 
			 | 
		
	
		
			
			| 
				81
			 | 
			
				
			 | 
			
			
				-  // }) 
			 | 
		
	
		
			
			| 
				82
			 | 
			
				
			 | 
			
			
				-  // .then((res) => { 
			 | 
		
	
		
			
			| 
				83
			 | 
			
				
			 | 
			
			
				-  //   report(<Assert 
			 | 
		
	
		
			
			| 
				84
			 | 
			
				
			 | 
			
			
				-  //     key="upload should success without crashing app" 
			 | 
		
	
		
			
			| 
				85
			 | 
			
				
			 | 
			
			
				-  //     expect={filename} 
			 | 
		
	
		
			
			| 
				86
			 | 
			
				
			 | 
			
			
				-  //     actual={res.json().name}/>) 
			 | 
		
	
		
			
			| 
				87
			 | 
			
				
			 | 
			
			
				-  //   done() 
			 | 
		
	
		
			
			| 
				88
			 | 
			
				
			 | 
			
			
				-  // }) 
			 | 
		
	
		
			
			| 
				89
			 | 
			
				62
			 | 
			
			
				 }) 
			 | 
		
	
		
			
			| 
				90
			 | 
			
				63
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				91
			 | 
			
				64
			 | 
			
			
				 describe('cancel task should work properly', (report, done) => { 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -93,12 +66,13 @@ describe('cancel task should work properly', (report, done) => { 
			 | 
		
	
		
			
			| 
				93
			 | 
			
				66
			 | 
			
			
				   let bytesWitten = 0 
			 | 
		
	
		
			
			| 
				94
			 | 
			
				67
			 | 
			
			
				   let deb = Date.now() 
			 | 
		
	
		
			
			| 
				95
			 | 
			
				68
			 | 
			
			
				   let begin = -1 
			 | 
		
	
		
			
			| 
				96
			 | 
			
				
			 | 
			
			
				-  let promise =  RNFetchBlob.fetch('POST', 'https://content.dropboxapi.com/2/files/upload', { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				69
			 | 
			
			
				+  let task =  RNFetchBlob.fetch('POST', 'https://content.dropboxapi.com/2/files/upload', { 
			 | 
		
	
		
			
			| 
				97
			 | 
			
				70
			 | 
			
			
				     Authorization : `Bearer ${DROPBOX_TOKEN}`, 
			 | 
		
	
		
			
			| 
				98
			 | 
			
				71
			 | 
			
			
				     'Dropbox-API-Arg': '{\"path\": \"/rn-upload/'+filename+'\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}', 
			 | 
		
	
		
			
			| 
				99
			 | 
			
				72
			 | 
			
			
				     'Content-Type' : 'application/octet-stream', 
			 | 
		
	
		
			
			| 
				100
			 | 
			
				73
			 | 
			
			
				   }, RNFetchBlob.wrap(bigfile)) 
			 | 
		
	
		
			
			| 
				101
			 | 
			
				
			 | 
			
			
				-  promise.uploadProgress((now, total) => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				74
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				75
			 | 
			
			
				+  task.uploadProgress((now, total) => { 
			 | 
		
	
		
			
			| 
				102
			 | 
			
				76
			 | 
			
			
				     bytesWitten = now 
			 | 
		
	
		
			
			| 
				103
			 | 
			
				77
			 | 
			
			
				     if(Date.now() - deb < 1000) 
			 | 
		
	
		
			
			| 
				104
			 | 
			
				78
			 | 
			
			
				       return 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -115,7 +89,7 @@ describe('cancel task should work properly', (report, done) => { 
			 | 
		
	
		
			
			| 
				115
			 | 
			
				89
			 | 
			
			
				   }) 
			 | 
		
	
		
			
			| 
				116
			 | 
			
				90
			 | 
			
			
				   let checkpoint1 = 0 
			 | 
		
	
		
			
			| 
				117
			 | 
			
				91
			 | 
			
			
				   Timer.setTimeout(() => { 
			 | 
		
	
		
			
			| 
				118
			 | 
			
				
			 | 
			
			
				-    promise.cancel() 
			 | 
		
	
		
			
			| 
				
			 | 
			
				92
			 | 
			
			
				+    task.cancel() 
			 | 
		
	
		
			
			| 
				119
			 | 
			
				93
			 | 
			
			
				   }, 5000) 
			 | 
		
	
		
			
			| 
				120
			 | 
			
				94
			 | 
			
			
				   Timer.setTimeout(() => { 
			 | 
		
	
		
			
			| 
				121
			 | 
			
				95
			 | 
			
			
				     checkpoint1 = bytesWitten 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -124,17 +98,22 @@ describe('cancel task should work properly', (report, done) => { 
			 | 
		
	
		
			
			| 
				124
			 | 
			
				98
			 | 
			
			
				     report(<Assert key="data should not write to stream after task is canceled" 
			 | 
		
	
		
			
			| 
				125
			 | 
			
				99
			 | 
			
			
				       expect={checkpoint1} 
			 | 
		
	
		
			
			| 
				126
			 | 
			
				100
			 | 
			
			
				       actual={bytesWitten}/>) 
			 | 
		
	
		
			
			| 
				127
			 | 
			
				
			 | 
			
			
				-    done() 
			 | 
		
	
		
			
			| 
				
			 | 
			
				101
			 | 
			
			
				+    fs.unlink(bigfile).then(() => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				102
			 | 
			
			
				+      done() 
			 | 
		
	
		
			
			| 
				
			 | 
			
				103
			 | 
			
			
				+    }) 
			 | 
		
	
		
			
			| 
				128
			 | 
			
				104
			 | 
			
			
				   }, 10000) 
			 | 
		
	
		
			
			| 
				129
			 | 
			
				
			 | 
			
			
				-  promise.then((res) => { 
			 | 
		
	
		
			
			| 
				130
			 | 
			
				
			 | 
			
			
				-    report( 
			 | 
		
	
		
			
			| 
				131
			 | 
			
				
			 | 
			
			
				-      <Assert key="task not canceled" 
			 | 
		
	
		
			
			| 
				132
			 | 
			
				
			 | 
			
			
				-        expected={false} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				105
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				106
			 | 
			
			
				+  task 
			 | 
		
	
		
			
			| 
				
			 | 
			
				107
			 | 
			
			
				+    .then((res) => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				108
			 | 
			
			
				+      report( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				109
			 | 
			
			
				+        <Assert key="task not canceled" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				110
			 | 
			
			
				+          expected={false} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				111
			 | 
			
			
				+          actual={true}/>) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				112
			 | 
			
			
				+    }) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				113
			 | 
			
			
				+    .catch((resp) => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				114
			 | 
			
			
				+      report(<Assert key="task cancelled rejection should be catachable" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				115
			 | 
			
			
				+        expect={true} 
			 | 
		
	
		
			
			| 
				133
			 | 
			
				116
			 | 
			
			
				         actual={true}/>) 
			 | 
		
	
		
			
			| 
				134
			 | 
			
				
			 | 
			
			
				-  }) 
			 | 
		
	
		
			
			| 
				135
			 | 
			
				
			 | 
			
			
				-  promise.catch((resp) => { 
			 | 
		
	
		
			
			| 
				136
			 | 
			
				
			 | 
			
			
				-    report(<Assert key="task cancelled rejection should be catachable" 
			 | 
		
	
		
			
			| 
				137
			 | 
			
				
			 | 
			
			
				-      expect={true} 
			 | 
		
	
		
			
			| 
				138
			 | 
			
				
			 | 
			
			
				-      actual={true}/>) 
			 | 
		
	
		
			
			| 
				139
			 | 
			
				
			 | 
			
			
				-  }) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				117
			 | 
			
			
				+    }) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				118
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				140
			 | 
			
				119
			 | 
			
			
				 }) 
			 |