Нема описа

test-0.10.0.js 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import RNTest from './react-native-testkit/'
  2. import React from 'react'
  3. import RNFetchBlob from 'react-native-fetch-blob'
  4. import {
  5. StyleSheet,
  6. Text,
  7. View,
  8. ScrollView,
  9. Linking,
  10. Platform,
  11. Dimensions,
  12. Image,
  13. } from 'react-native';
  14. const JSONStream = RNFetchBlob.JSONStream
  15. const fs = RNFetchBlob.fs
  16. const { Assert, Comparer, Info, prop } = RNTest
  17. const describe = RNTest.config({
  18. group : '0.10.0',
  19. run : true,
  20. expand : true,
  21. timeout : 20000,
  22. })
  23. const { TEST_SERVER_URL, TEST_SERVER_URL_SSL, FILENAME, DROPBOX_TOKEN, styles } = prop()
  24. const dirs = RNFetchBlob.fs.dirs
  25. let prefix = ((Platform.OS === 'android') ? 'file://' : '')
  26. let begin = Date.now()
  27. describe('json stream via HTTP', (report, done) => {
  28. let count = 0
  29. JSONStream(`${TEST_SERVER_URL}/public/json-dummy.json`).node('name', (name) => {
  30. count++
  31. if(Date.now() - begin < 100)
  32. return
  33. begin = Date.now()
  34. report(<Info key="report" uid="100">
  35. <Text>{count} records</Text>
  36. </Info>)
  37. done()
  38. })
  39. })
  40. describe('json stream via fs', (report, done) => {
  41. let fetch2 = new RNFetchBlob.polyfill.Fetch({
  42. auto : true
  43. })
  44. let res = null
  45. let count = 0
  46. RNFetchBlob.config({
  47. fileCache : true
  48. })
  49. .fetch('GET',`${TEST_SERVER_URL}/public/json-dummy.json`)
  50. .then((resp) => {
  51. res = resp
  52. JSONStream({
  53. url : RNFetchBlob.wrap(res.path()),
  54. headers : { bufferSize : 10240 }
  55. }).node('name', (name) => {
  56. count++
  57. if(Date.now() - begin < 100)
  58. return
  59. begin = Date.now()
  60. report(<Info key="report" uid="100">
  61. <Text>{count} records</Text>
  62. </Info>)
  63. done()
  64. })
  65. })
  66. })