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
 describe('POST request with params', (report, done) => {
58
 describe('POST request with params', (report, done) => {
59
   let time = Date.now()
59
   let time = Date.now()
60
   RNFetchBlob.config({ fileCache : true })
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
     .then((resp) => {
65
     .then((resp) => {
63
       let file = resp.path()
66
       let file = resp.path()
64
       return RNFetchBlob.fs.readStream(resp.path(), 'utf8')
67
       return RNFetchBlob.fs.readStream(resp.path(), 'utf8')

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

183
   .config({fileCache : true})
183
   .config({fileCache : true})
184
   .fetch('GET', `${TEST_SERVER_URL}/public/beethoven.mp3`)
184
   .fetch('GET', `${TEST_SERVER_URL}/public/beethoven.mp3`)
185
   .then((resp) => {
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
       { name : 'image', filename : 'image', type : 'image/jpeg', data : RNFetchBlob.base64.encode('123456') },
189
       { name : 'image', filename : 'image', type : 'image/jpeg', data : RNFetchBlob.base64.encode('123456') },
188
       { name : 'mp3', filename : 'mp3', type : 'application/mp3', data : RNFetchBlob.base64.encode('123456') },
190
       { name : 'mp3', filename : 'mp3', type : 'application/mp3', data : RNFetchBlob.base64.encode('123456') },
189
       { name : 'mp3', filename : 'mp3', data : RNFetchBlob.base64.encode('123456') },
191
       { name : 'mp3', filename : 'mp3', data : RNFetchBlob.base64.encode('123456') },

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

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

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

24
 const describe = RNTest.config({
24
 const describe = RNTest.config({
25
   group : '0.9.0',
25
   group : '0.9.0',
26
   run : true,
26
   run : true,
27
-  expand : true,
27
+  expand : false,
28
   timeout : 20000,
28
   timeout : 20000,
29
 })
29
 })
30
 const { TEST_SERVER_URL, TEST_SERVER_URL_SSL, FILENAME, DROPBOX_TOKEN, styles } = prop()
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
 })
82
 })
83
 
83
 
84
 describe('Upload multipart/form-data', (report, done) => {
84
 describe('Upload multipart/form-data', (report, done) => {
85
-
85
+  let image = RNTest.prop('image')
86
   RNFetchBlob.fetch('POST', `${TEST_SERVER_URL}/upload-form`, {
86
   RNFetchBlob.fetch('POST', `${TEST_SERVER_URL}/upload-form`, {
87
       Authorization : "Bearer fsXcpmKPrHgAAAAAAAAAEGxFXwhejXM_E8fznZoXPhHbhbNhA-Lytbe6etp1Jznz",
87
       Authorization : "Bearer fsXcpmKPrHgAAAAAAAAAEGxFXwhejXM_E8fznZoXPhHbhbNhA-Lytbe6etp1Jznz",
88
       'Content-Type' : 'multipart/form-data',
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
       { name : 'field1', data : 'hello !!'},
92
       { name : 'field1', data : 'hello !!'},
93
       { name : 'field2', data : 'hello2 !!'}
93
       { name : 'field2', data : 'hello2 !!'}
94
     ])
94
     ])

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

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

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

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