Browse Source

Change test cases

Ben Hsieh 8 years ago
parent
commit
58205e563d
7 changed files with 18 additions and 10 deletions
  1. 4
    1
      test/test-0.5.2.js
  2. 3
    1
      test/test-0.6.2.js
  3. 2
    1
      test/test-0.7.0.js
  4. 1
    1
      test/test-0.9.0.js
  5. 3
    3
      test/test-0.9.2.js
  6. 3
    3
      test/test-firebase.js
  7. 2
    0
      test/test-fs.js

+ 4
- 1
test/test-0.5.2.js View File

@@ -58,7 +58,10 @@ describe('GET request with params', (report, done) => {
58 58
 describe('POST request with params', (report, done) => {
59 59
   let time = Date.now()
60 60
   RNFetchBlob.config({ fileCache : true })
61
-    .fetch('POST', encodeURI(`${TEST_SERVER_URL}/params?time=${time}&name=RNFetchBlobParams&lang=中文`), {}, RNFetchBlob.base64.encode('123'))
61
+    .fetch('POST', encodeURI(`${TEST_SERVER_URL}/params?time=${time}&name=RNFetchBlobParams&lang=中文`),
62
+    {
63
+      'Content-Type' : 'image/png;BASE64'
64
+    }, RNFetchBlob.base64.encode('123'))
62 65
     .then((resp) => {
63 66
       let file = resp.path()
64 67
       return RNFetchBlob.fs.readStream(resp.path(), 'utf8')

+ 3
- 1
test/test-0.6.2.js View File

@@ -183,7 +183,9 @@ describe('Check custom MIME type correctness',(report, done) => {
183 183
   .config({fileCache : true})
184 184
   .fetch('GET', `${TEST_SERVER_URL}/public/beethoven.mp3`)
185 185
   .then((resp) => {
186
-    return RNFetchBlob.fetch('POST', `${TEST_SERVER_URL}/mime`, null, [
186
+    return RNFetchBlob.fetch('POST', `${TEST_SERVER_URL}/mime`, {
187
+      'Content-Type' : 'multipart/form-data'
188
+    }, [
187 189
       { name : 'image', filename : 'image', type : 'image/jpeg', data : RNFetchBlob.base64.encode('123456') },
188 190
       { name : 'mp3', filename : 'mp3', type : 'application/mp3', data : RNFetchBlob.base64.encode('123456') },
189 191
       { name : 'mp3', filename : 'mp3', data : RNFetchBlob.base64.encode('123456') },

+ 2
- 1
test/test-0.7.0.js View File

@@ -36,7 +36,7 @@ describe('Upload and download large file', (report, done) => {
36 36
   RNFetchBlob.config({
37 37
     fileCache : true
38 38
   })
39
-  .fetch('GET', `${TEST_SERVER_URL}/public/22mb-dummy`)
39
+  .fetch('GET', `${TEST_SERVER_URL}/public/1mb-dummy`)
40 40
   .progress((now, total) => {
41 41
     if(begin === -1)
42 42
       begin = Date.now()
@@ -114,6 +114,7 @@ describe('cancel task should work properly', (report, done) => {
114 114
       report(<Assert key="task cancelled rejection should be catachable"
115 115
         expect={true}
116 116
         actual={true}/>)
117
+      done()
117 118
     })
118 119
 
119 120
 })

+ 1
- 1
test/test-0.9.0.js View File

@@ -24,7 +24,7 @@ const { Assert, Comparer, Info, prop } = RNTest
24 24
 const describe = RNTest.config({
25 25
   group : '0.9.0',
26 26
   run : true,
27
-  expand : true,
27
+  expand : false,
28 28
   timeout : 20000,
29 29
 })
30 30
 const { TEST_SERVER_URL, TEST_SERVER_URL_SSL, FILENAME, DROPBOX_TOKEN, styles } = prop()

+ 3
- 3
test/test-0.9.2.js View File

@@ -82,13 +82,13 @@ describe('slice test', (report, done) => {
82 82
 })
83 83
 
84 84
 describe('Upload multipart/form-data', (report, done) => {
85
-
85
+  let image = RNTest.prop('image')
86 86
   RNFetchBlob.fetch('POST', `${TEST_SERVER_URL}/upload-form`, {
87 87
       Authorization : "Bearer fsXcpmKPrHgAAAAAAAAAEGxFXwhejXM_E8fznZoXPhHbhbNhA-Lytbe6etp1Jznz",
88 88
       'Content-Type' : 'multipart/form-data',
89 89
     }, [
90
-      // { name : 'test-img', filename : 'test-img.png', data: image},
91
-      // { name : 'test-text', filename : 'test-text.txt', data: RNFetchBlob.base64.encode('hello.txt')},
90
+      { name : 'test-img', filename : 'test-img.png', data: image},
91
+      { name : 'test-text', filename : 'test-text.txt', data: RNFetchBlob.base64.encode('hello.txt')},
92 92
       { name : 'field1', data : 'hello !!'},
93 93
       { name : 'field2', data : 'hello2 !!'}
94 94
     ])

+ 3
- 3
test/test-firebase.js View File

@@ -16,10 +16,9 @@ import {
16 16
 } from 'react-native';
17 17
 
18 18
 const fs = RNFetchBlob.fs
19
-const Blob = RNFetchBlob.polyfill.Blob
20 19
 
21 20
 window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest
22
-window.Blob = Blob
21
+window.Blob = RNFetchBlob.polyfill.Blob
23 22
 
24 23
 const { Assert, Comparer, Info, prop } = RNTest
25 24
 const describe = RNTest.config({
@@ -41,10 +40,11 @@ var config = {
41 40
   databaseURL: "https://rnfb-test-app.firebaseio.com",
42 41
   storageBucket: "rnfb-test-app.appspot.com",
43 42
 };
44
-firebase.initializeApp(config);
43
+
45 44
 
46 45
 describe('firebase login', (report, done) => {
47 46
 
47
+  firebase.initializeApp(config);
48 48
   firebase.auth().signInWithEmailAndPassword('xeiyan@gmail.com', 'rnfbtest1024')
49 49
     .catch((err) => {
50 50
       console.log('firebase sigin failed', err)

+ 2
- 0
test/test-fs.js View File

@@ -7,6 +7,7 @@ import {
7 7
   Text,
8 8
   View,
9 9
   ScrollView,
10
+  Platform,
10 11
   Dimensions,
11 12
   Image,
12 13
 } from 'react-native';
@@ -20,6 +21,7 @@ const describe = RNTest.config({
20 21
 
21 22
 let { TEST_SERVER_URL, FILENAME, DROPBOX_TOKEN, styles, image } = prop()
22 23
 let dirs = RNFetchBlob.fs.dirs
24
+let prefix = ((Platform.OS === 'android') ? 'file://' : '')
23 25
 
24 26
 describe('Get storage folders', (report, done) => {
25 27
   report(