暂无描述

test-0.10.1.js 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. BackAndroid,
  13. AsyncStorage,
  14. Image,
  15. } from 'react-native';
  16. window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest
  17. window.Blob = RNFetchBlob.polyfill.Blob
  18. const JSONStream = RNFetchBlob.JSONStream
  19. const fs = RNFetchBlob.fs
  20. const { Assert, Comparer, Info, prop } = RNTest
  21. const describe = RNTest.config({
  22. group : '0.10.1',
  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. let begin = Date.now()
  31. describe("Invalid promise.resolve call after task is canceled #176", (report, done) => {
  32. let task = RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/public/22mb-dummy`)
  33. task
  34. .then(() => {
  35. report(<Assert key="Promise should not resolved" expect={true} actual={false}/>);
  36. })
  37. .catch(() => {
  38. report(<Assert key="Promise should not resolved" expect={true} actual={true}/>);
  39. done()
  40. });
  41. task.progress((current, total) => {
  42. report(<Info key={`${Math.floor(current/1024)}kb of ${Math.floor(total/1024)}kb`} uid="report"/>)
  43. })
  44. setTimeout(() => {
  45. task.cancel();
  46. }, 2000)
  47. })