暫無描述

test-0.6.3.js 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import RNTest from './react-native-testkit/'
  2. import React from 'react'
  3. import RNFetchBlob from 'react-native-fetch-blob'
  4. import Timer from 'react-timer-mixin'
  5. import {
  6. StyleSheet,
  7. Text,
  8. View,
  9. ScrollView,
  10. CameraRoll,
  11. Platform,
  12. Dimensions,
  13. Image,
  14. } from 'react-native';
  15. const fs = RNFetchBlob.fs
  16. const { Assert, Comparer, Info, prop } = RNTest
  17. const describe = RNTest.config({
  18. group : '0.6.3',
  19. run : true,
  20. expand : true,
  21. timeout : 300000000,
  22. })
  23. const { TEST_SERVER_URL, TEST_SERVER_URL_SSL, DROPBOX_TOKEN, styles } = prop()
  24. const dirs = RNFetchBlob.fs.dirs
  25. let prefix = ((Platform.OS === 'android') ? 'file://' : '')
  26. describe('massive HTTP request', (report, done) => {
  27. try {
  28. let promises = []
  29. let progress = []
  30. let begin = Date.now()
  31. for(let i=0; i<1500;i++) {
  32. let p = RNFetchBlob
  33. .config({fileCache : true})
  34. .fetch('GET', `${TEST_SERVER_URL}/public/github2.jpg`)
  35. // .progress(function(current, total){
  36. // progress[this] = current/total
  37. // }.bind(i))
  38. promises.push(p)
  39. }
  40. // let it = Timer.setInterval(() => {
  41. // function pgs() {
  42. // let res = []
  43. // for(var i in progress) {
  44. // res.push(<Text key={`download#${i}`}>{`download #${i} ${Math.floor(progress[i]*100)}%`}</Text>)
  45. // }
  46. // return res
  47. // }
  48. // report(<Info key={`progress monitor`} uid="progress">
  49. // {pgs()}
  50. // </Info>)
  51. // }, 1000)
  52. Promise.all(promises).then((resps) => {
  53. for(let i in resps) {
  54. fs.unlink(resps[i].path())
  55. }
  56. report(<Info key={`time = ${(Date.now() - begin) / 1000} sec`}></Info>)
  57. // Timer.clearInterval(it)
  58. done()
  59. })
  60. } catch(err) {
  61. console.log(err)
  62. }
  63. })