Browse Source

Add test file

Ben Hsieh 8 years ago
parent
commit
2925f46bf2
2 changed files with 48 additions and 0 deletions
  1. 16
    0
      test/.babelrc
  2. 32
    0
      test/test-0.10.0.js

+ 16
- 0
test/.babelrc View File

@@ -0,0 +1,16 @@
1
+{
2
+  "plugins": [
3
+    ["module-alias", [
4
+      { "src": "./node_modules/react-native-fetch-blob/node-polyfill/events.js", "expose": "events" },
5
+      { "src": "./node_modules/react-native-fetch-blob/node-polyfill/http.js", "expose": "http" },
6
+      { "src": "./node_modules/react-native-fetch-blob/node-polyfill/path.js", "expose": "path" },
7
+      { "src": "./node_modules/react-native-fetch-blob/node-polyfill/fs.js", "expose": "fs" },
8
+      { "src": "./node_modules/react-native-fetch-blob/node-polyfill/url.js", "expose": "url" },
9
+      { "src": "./node_modules/react-native-fetch-blob/node-polyfill/querystring.js", "expose": "querystring" },
10
+      { "src": "./node_modules/react-native-fetch-blob/node-polyfill/net.js", "expose": "net" },
11
+      { "src": "./node_modules/react-native-fetch-blob/node-polyfill/crypto.js", "expose": "crypto" },
12
+      { "src": "./node_modules/react-native-fetch-blob/node-polyfill/stream.js", "expose": "stream" }
13
+    ]]
14
+  ],
15
+  "extends": "./node_modules/react-native/packager/react-packager/rn-babelrc.json",
16
+}

+ 32
- 0
test/test-0.10.0.js View File

@@ -0,0 +1,32 @@
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
+
14
+window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest
15
+window.Blob = RNFetchBlob.polyfill.Blob
16
+window.fetch = new RNFetchBlob.polyfill.Fetch({
17
+  auto : true,
18
+  binaryContentTypes : ['image/', 'video/', 'audio/']
19
+}).build()
20
+
21
+const fs = RNFetchBlob.fs
22
+const { Assert, Comparer, Info, prop } = RNTest
23
+const describe = RNTest.config({
24
+  group : '0.10.0',
25
+  run : true,
26
+  expand : true,
27
+  timeout : 20000,
28
+})
29
+const { TEST_SERVER_URL, TEST_SERVER_URL_SSL, FILENAME, DROPBOX_TOKEN, styles } = prop()
30
+const dirs = RNFetchBlob.fs.dirs
31
+
32
+let prefix = ((Platform.OS === 'android') ? 'file://' : '')