123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- import RNTest from './react-native-testkit/'
- import React from 'react'
- import RNFetchBlob from 'react-native-fetch-blob'
- import {
- StyleSheet,
- Text,
- View,
- ScrollView,
- Platform,
- Dimensions,
- Image,
- TouchableOpacity,
- } from 'react-native';
-
- window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest
- window.Blob = RNFetchBlob.polyfill.Blob
-
- const fs = RNFetchBlob.fs
- const { Assert, Comparer, Info, prop } = RNTest
- const describe = RNTest.config({
- group : '0.9.5',
- run : true,
- expand : false,
- timeout : 20000,
- })
- const { TEST_SERVER_URL, TEST_SERVER_URL_SSL, FILENAME, DROPBOX_TOKEN, styles } = prop()
- const dirs = RNFetchBlob.fs.dirs
-
- let prefix = ((Platform.OS === 'android') ? 'file://' : '')
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- describe('#131 status code != 200 should not throw an error', (report, done) => {
-
- let count = 0
- let codes = [404, 500, 501, 403]
-
- codes.forEach((code) => {
-
- RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/xhr-code/${code}`, {
- 'Cache-Control' : 'no-store'
- })
- .then(function(res) {
- report(<Assert key={`status code should be ${this}`} expect={Math.floor(this)} actual={Math.floor(res.info().status)}/>)
- count ++
- if(count >= 4)
- done()
- }.bind(code))
- .catch(function(err) {
- report(<Assert key={`status code ${this} should not cause error`} expect={true} actual={false}/>)
- count++
- }.bind(code))
-
- })
-
- })
|