Ingen beskrivning

test-0.9.4.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. Platform,
  10. Dimensions,
  11. Image,
  12. } from 'react-native';
  13. window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest
  14. window.Blob = RNFetchBlob.polyfill.Blob
  15. // window.fetch = new RNFetchBlob.polyfill.Fetch({
  16. // auto : true,
  17. // binaryContentTypes : ['image/', 'video/', 'audio/']
  18. // }).build()
  19. const fs = RNFetchBlob.fs
  20. const { Assert, Comparer, Info, prop } = RNTest
  21. const describe = RNTest.config({
  22. group : '0.9.4',
  23. run : true,
  24. expand : true,
  25. timeout : 20000,
  26. })
  27. const { TEST_SERVER_URL, TEST_SERVER_URL_SSL, FILENAME, DROPBOX_TOKEN, styles } = prop()
  28. const dirs = RNFetchBlob.fs.dirs
  29. let prefix = ((Platform.OS === 'android') ? 'file://' : '')
  30. describe('issue #105', (report, done) => {
  31. let tmp = null
  32. RNFetchBlob
  33. .config({ fileCache : true })
  34. .fetch('GET', `${TEST_SERVER_URL}/public/github.png`)
  35. .then((res) => {
  36. tmp = res.path()
  37. return RNFetchBlob.fetch('POST', `${TEST_SERVER_URL}/upload-form`, {
  38. 'Content-Type' : 'multipart/form-data'
  39. }, [
  40. { name : 'data', data : 'issue#105 test' },
  41. { name : 'file', filename : 'github.png', data : RNFetchBlob.wrap(tmp) }
  42. ])
  43. })
  44. .then((res) => {
  45. done()
  46. })
  47. })
  48. describe('issue #106', (report, done) => {
  49. fetch('https://rnfb-test-app.firebaseapp.com/6m-json.json')
  50. .then((res) => {
  51. console.log('##',res)
  52. console.log('## converted')
  53. return res.json()
  54. })
  55. .then((data) => {
  56. console.log(data)
  57. done()
  58. })
  59. })