暫無描述

test-0.8.2.js 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 = 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.8.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('whatwg-fetch - GET should work correctly', (report, done) => {
  31. console.log(fetch)
  32. fetch(`${TEST_SERVER_URL}/unicode`, {
  33. method : 'GET'
  34. })
  35. .then((res) => {
  36. return res.json()
  37. })
  38. .then((data) => {
  39. console.log(data)
  40. report(<Assert key="data should correct" expect={'你好!'} actual={data.data}/>)
  41. done()
  42. })
  43. })