Browse Source

Add test case for 0.8.0

Ben Hsieh 8 years ago
parent
commit
dbc87d45cb
2 changed files with 70 additions and 4 deletions
  1. 65
    0
      test/test-0.8.0.js
  2. 5
    4
      test/test-init.js

+ 65
- 0
test/test-0.8.0.js View File

@@ -0,0 +1,65 @@
1
+import RNTest from './react-native-testkit/'
2
+import React from 'react'
3
+import RNFetchBlob from 'react-native-fetch-blob'
4
+
5
+import {
6
+  StyleSheet,
7
+  Text,
8
+  View,
9
+  ScrollView,
10
+  Platform,
11
+  Dimensions,
12
+  Image,
13
+} from 'react-native';
14
+
15
+const fs = RNFetchBlob.fs
16
+const { Assert, Comparer, Info, prop } = RNTest
17
+const describe = RNTest.config({
18
+  group : '0.8.0',
19
+  run : true,
20
+  expand : true,
21
+  timeout : 10000,
22
+})
23
+const { TEST_SERVER_URL_SSL, FILENAME, DROPBOX_TOKEN, styles } = prop()
24
+const  dirs = RNFetchBlob.fs.dirs
25
+
26
+let prefix = ((Platform.OS === 'android') ? 'file://' : '')
27
+
28
+describe('URI encoding support', (report, done) => {
29
+
30
+  let testData1 = `test date write file from file ${Date.now()}`
31
+  let testData2 = `test date write file from file ${Date.now()*Math.random()}`
32
+  let file1 = dirs.DocumentDir + '/testFiletFile1' + Date.now()
33
+  let file2 = dirs.DocumentDir + '/testFiletFile2' + Date.now()
34
+  let init = [fs.createFile(file1, testData1, 'utf8'),
35
+              fs.createFile(file2, testData2, 'utf8')]
36
+  Promise.all(init)
37
+    .then(() => fs.appendFile(file1, file2, 'uri'))
38
+    .then(() => fs.readFile(file1, 'utf8'))
39
+    .then((data) => {
40
+      report(
41
+        <Assert key="append content from URI should be correct"
42
+          expect={testData1 + testData2}
43
+          actual={data}
44
+        />)
45
+      return fs.writeFile(file1, file2, 'uri')
46
+    })
47
+    .then(() => fs.readFile(file1, 'utf8'))
48
+    .then((data) => {
49
+      report(
50
+        <Assert key="write content from URI should be correct"
51
+          expect={testData2}
52
+          actual={data}
53
+        />)
54
+      done()
55
+    })
56
+
57
+})
58
+
59
+function getASCIIArray(str) {
60
+  let r = []
61
+  for(let i=0;i<str.length;i++) {
62
+    r.push(str[i].charCodeAt(0))
63
+  }
64
+  return r
65
+}

+ 5
- 4
test/test-init.js View File

@@ -17,9 +17,9 @@ const { Assert, Comparer, Info, prop } = RNTest
17 17
 
18 18
 // test environment variables
19 19
 
20
-prop('FILENAME', `${Platform.OS}-0.7.0-${Date.now()}.png`)
21
-prop('TEST_SERVER_URL', 'http://192.168.0.11:8123')
22
-prop('TEST_SERVER_URL_SSL', 'https://192.168.0.11:8124')
20
+prop('FILENAME', `${Platform.OS}-0.8.0-${Date.now()}.png`)
21
+prop('TEST_SERVER_URL', 'http://192.168.16.70:8123')
22
+prop('TEST_SERVER_URL_SSL', 'https://192.168.1.70:8124')
23 23
 prop('DROPBOX_TOKEN', 'fsXcpmKPrHgAAAAAAAAAoXZhcXYWdgLpQMan6Tb_bzJ237DXhgQSev12hA-gUXt4')
24 24
 prop('styles', {
25 25
   image : {
@@ -65,6 +65,7 @@ describe('GET image from server', (report, done) => {
65 65
 // require('./test-0.6.2')
66 66
 // require('./test-0.6.3')
67 67
 // require('./test-0.7.0')
68
+require('./test-0.8.0')
68 69
 // require('./test-fs')
69
-require('./test-firebase')
70
+// require('./test-firebase')
70 71
 // require('./test-android')