Açıklama Yok

test-0.10.0.js 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. AsyncStorage,
  13. Image,
  14. } from 'react-native';
  15. const JSONStream = RNFetchBlob.JSONStream
  16. const fs = RNFetchBlob.fs
  17. const { Assert, Comparer, Info, prop } = RNTest
  18. const describe = RNTest.config({
  19. group : '0.10.0',
  20. run : true,
  21. expand : true,
  22. timeout : 20000,
  23. })
  24. const { TEST_SERVER_URL, TEST_SERVER_URL_SSL, FILENAME, DROPBOX_TOKEN, styles } = prop()
  25. const dirs = RNFetchBlob.fs.dirs
  26. let prefix = ((Platform.OS === 'android') ? 'file://' : '')
  27. let begin = Date.now()
  28. // describe('json stream via HTTP', (report, done) => {
  29. //
  30. // let count = 0
  31. // JSONStream(`${TEST_SERVER_URL}/public/json-dummy.json`).node('name', (name) => {
  32. // count++
  33. // if(Date.now() - begin < 100)
  34. // return
  35. // begin = Date.now()
  36. // report(<Info key="report" uid="100">
  37. // <Text>{count} records</Text>
  38. // </Info>)
  39. // done()
  40. // })
  41. //
  42. // })
  43. //
  44. // describe('json stream via fs', (report, done) => {
  45. //
  46. // let fetch2 = new RNFetchBlob.polyfill.Fetch({
  47. // auto : true
  48. // })
  49. // let res = null
  50. // let count = 0
  51. //
  52. // RNFetchBlob.config({
  53. // fileCache : true
  54. // })
  55. // .fetch('GET',`${TEST_SERVER_URL}/public/json-dummy.json`)
  56. // .then((resp) => {
  57. // res = resp
  58. // JSONStream({
  59. // url : RNFetchBlob.wrap(res.path()),
  60. // headers : { bufferSize : 10240 }
  61. // }).node('name', (name) => {
  62. // count++
  63. // if(Date.now() - begin < 100)
  64. // return
  65. // begin = Date.now()
  66. // report(<Info key="report" uid="100">
  67. // <Text>{count} records</Text>
  68. // </Info>)
  69. // done()
  70. // })
  71. // })
  72. // })
  73. //
  74. // describe('issue #102', (report, done) => {
  75. // let tmp = null
  76. // RNFetchBlob.config({ fileCache: true, appendExt : 'png' })
  77. // .fetch('GET', `${TEST_SERVER_URL}/public/github.png`)
  78. // .then((res) => {
  79. // tmp = res
  80. // RNFetchBlob.ios.previewDocument(res.path())
  81. // return RNFetchBlob.fetch('POST', `${TEST_SERVER_URL}/upload-form`, {},
  82. // [{ name : String(1), data : RNFetchBlob.wrap(res.path()), filename: '#102-test-image.png' }])
  83. // })
  84. // .then((res) => tmp.flush())
  85. // .then(() => {
  86. // done()
  87. // })
  88. //
  89. // })
  90. describe('cookie test', (report, done) => {
  91. RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/cookie`)
  92. .then((res) => {
  93. return RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/xhr-header`)
  94. })
  95. .then((res) => {
  96. console.log(res)
  97. RNFetchBlob.net.getCookies(`${TEST_SERVER_URL}`)
  98. .then((cookies) => {
  99. console.log(cookies)
  100. })
  101. })
  102. })