No Description

test-0.9.2.js 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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.2',
  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('content-length header test', (report, done) => {
  31. RNFetchBlob.fetch('POST', `${TEST_SERVER_URL}/content-length`, {
  32. 'Content-Type' : 'text/plain',
  33. 'Content-Length' : '5'
  34. }, 'hello')
  35. .then((res) => {
  36. report(
  37. <Info key="response data">
  38. <Text>{res.text()}</Text>
  39. </Info>)
  40. done()
  41. })
  42. })