Нема описа

test-0.9.5.js 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. TouchableOpacity,
  13. } from 'react-native';
  14. window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest
  15. window.Blob = RNFetchBlob.polyfill.Blob
  16. const fs = RNFetchBlob.fs
  17. const { Assert, Comparer, Info, prop } = RNTest
  18. const describe = RNTest.config({
  19. group : '0.9.5',
  20. run : true,
  21. expand : false,
  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. describe('issue #122 force response data format', (report, done) => {
  28. RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/public/json-dummy.json`, {
  29. 'RNFB-Response' : 'base64'
  30. })
  31. .then((res) => {
  32. let r = RNFetchBlob.base64.decode(res.data)
  33. report(
  34. <Assert key="test data verify" expect="fetchblob-dev" actual={JSON.parse(r).name}/>,
  35. <Assert key="should successfully decode the data" expect={true} actual={true}/>)
  36. return RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/public/json-dummy.json`)
  37. })
  38. .then((res) => {
  39. report(
  40. <Assert key="response should in format of plain-text" expect="fetchblob-dev" actual={JSON.parse(res.data).name}/>)
  41. done()
  42. })
  43. .catch(() => {
  44. report(
  45. <Assert key="Should successfully decode the data" expect={true} actual={false}/>)
  46. done()
  47. })
  48. })