Ben Hsieh пре 8 година
родитељ
комит
97e28f0296
2 измењених фајлова са 99 додато и 99 уклоњено
  1. 96
    96
      test/test-0.1.x-0.4.x.js
  2. 3
    3
      test/test-init.js

+ 96
- 96
test/test-0.1.x-0.4.x.js Прегледај датотеку

@@ -19,102 +19,102 @@ const describe = RNTest.config({
19 19
 
20 20
 let { TEST_SERVER_URL, FILENAME, DROPBOX_TOKEN, styles, image } = prop()
21 21
 
22
-// describe('The check if it follows 301/302 redirection', (report, done) => {
23
-//
24
-//   image = RNTest.prop('image')
25
-//
26
-//   RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/redirect`)
27
-//   .then((resp) => {
28
-//     report(
29
-//       <Assert key="check image size" expect={image.length} actual={resp.base64().length}/>,
30
-//       <Info key="Response image">
31
-//         <Image
32
-//           style={{width:Dimensions.get('window').width*0.9, height : Dimensions.get('window').width*0.9,margin :16}}
33
-//           source={{uri : `data:image/png;base64, ${image}`}}/>
34
-//       </Info>)
35
-//       done()
36
-//   })
37
-//
38
-// })
39
-//
40
-// describe('Upload octet-stream image to Dropbox', (report, done) => {
41
-//
42
-//   RNFetchBlob.fetch('POST', 'https://content.dropboxapi.com/2/files/upload', {
43
-//     Authorization : `Bearer ${DROPBOX_TOKEN}`,
44
-//     'Dropbox-API-Arg': '{\"path\": \"/rn-upload/'+FILENAME+'\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}',
45
-//     'Content-Type' : 'application/octet-stream',
46
-//   }, image)
47
-//   .then((resp) => {
48
-//     resp = resp.json()
49
-//     report(
50
-//       <Assert key="confirm the file has been uploaded" expect={FILENAME} actual={resp.name}/>
51
-//     )
52
-//     done()
53
-//   })
54
-//
55
-// })
56
-//
57
-// describe('Upload multipart/form-data', (report, done) => {
58
-//
59
-//   RNFetchBlob.fetch('POST', `${TEST_SERVER_URL}/upload-form`, {
60
-//       Authorization : "Bearer fsXcpmKPrHgAAAAAAAAAEGxFXwhejXM_E8fznZoXPhHbhbNhA-Lytbe6etp1Jznz",
61
-//       'Content-Type' : 'multipart/form-data',
62
-//     }, [
63
-//       { name : 'test-img', filename : 'test-img.png', data: image},
64
-//       { name : 'test-text', filename : 'test-text.txt', data: RNFetchBlob.base64.encode('hello.txt')},
65
-//       { name : 'field1', data : 'hello !!'},
66
-//       { name : 'field2', data : 'hello2 !!'}
67
-//     ])
68
-//   .then((resp) => {
69
-//     resp = resp.json()
70
-//     report(
71
-//       <Assert key="check posted form data #1" expect="hello !!" actual={resp.fields.field1}/>,
72
-//       <Assert key="check posted form data #2" expect="hello2 !!" actual={resp.fields.field2}/>,
73
-//     )
74
-//     done()
75
-//   })
76
-//
77
-//
78
-// })
79
-//
80
-// describe('Compare uploaded multipart image', (report, done) => {
81
-//   let r1 = null
82
-//   RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/public/test-img.png`)
83
-//     .then((resp) => {
84
-//       r1 = resp
85
-//       return RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/public/test-text.txt`)
86
-//     })
87
-//     .then((resp) => {
88
-//       report(
89
-//         <Assert key="check file length" expect={image.length} actual={r1.base64().length}/>,
90
-//         <Assert key="check file content" expect={'hello.txt'} actual={resp.text()}/>
91
-//       )
92
-//       done()
93
-//     })
94
-//
95
-// })
96
-//
97
-// // added after 0.4.2
98
-//
99
-// describe('Progress report test', (report, done) => {
100
-//   let actual = 0, expect = -1
101
-//   RNFetchBlob
102
-//     .fetch('GET', `${TEST_SERVER_URL}/public/1mb-dummy`, {
103
-//       Authorization : 'Bearer abde123eqweje'
104
-//     })
105
-//     .progress((received, total) => {
106
-//       actual = received
107
-//       expect = total
108
-//     })
109
-//     .then((resp) => {
110
-//       report(
111
-//         <Assert key="download progress correct" expect={expect} actual={actual}/>,
112
-//         <Assert key="response data should be correct event with progress listener"
113
-//           expect={resp.text().substr(0,10)} actual={"1234567890"}/>)
114
-//       done()
115
-//     })
116
-//
117
-// })
22
+describe('The check if it follows 301/302 redirection', (report, done) => {
23
+
24
+  image = RNTest.prop('image')
25
+
26
+  RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/redirect`)
27
+  .then((resp) => {
28
+    report(
29
+      <Assert key="check image size" expect={image.length} actual={resp.base64().length}/>,
30
+      <Info key="Response image">
31
+        <Image
32
+          style={{width:Dimensions.get('window').width*0.9, height : Dimensions.get('window').width*0.9,margin :16}}
33
+          source={{uri : `data:image/png;base64, ${image}`}}/>
34
+      </Info>)
35
+      done()
36
+  })
37
+
38
+})
39
+
40
+describe('Upload octet-stream image to Dropbox', (report, done) => {
41
+
42
+  RNFetchBlob.fetch('POST', 'https://content.dropboxapi.com/2/files/upload', {
43
+    Authorization : `Bearer ${DROPBOX_TOKEN}`,
44
+    'Dropbox-API-Arg': '{\"path\": \"/rn-upload/'+FILENAME+'\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}',
45
+    'Content-Type' : 'application/octet-stream',
46
+  }, image)
47
+  .then((resp) => {
48
+    resp = resp.json()
49
+    report(
50
+      <Assert key="confirm the file has been uploaded" expect={FILENAME} actual={resp.name}/>
51
+    )
52
+    done()
53
+  })
54
+
55
+})
56
+
57
+describe('Upload multipart/form-data', (report, done) => {
58
+
59
+  RNFetchBlob.fetch('POST', `${TEST_SERVER_URL}/upload-form`, {
60
+      Authorization : "Bearer fsXcpmKPrHgAAAAAAAAAEGxFXwhejXM_E8fznZoXPhHbhbNhA-Lytbe6etp1Jznz",
61
+      'Content-Type' : 'multipart/form-data',
62
+    }, [
63
+      { name : 'test-img', filename : 'test-img.png', data: image},
64
+      { name : 'test-text', filename : 'test-text.txt', data: RNFetchBlob.base64.encode('hello.txt')},
65
+      { name : 'field1', data : 'hello !!'},
66
+      { name : 'field2', data : 'hello2 !!'}
67
+    ])
68
+  .then((resp) => {
69
+    resp = resp.json()
70
+    report(
71
+      <Assert key="check posted form data #1" expect="hello !!" actual={resp.fields.field1}/>,
72
+      <Assert key="check posted form data #2" expect="hello2 !!" actual={resp.fields.field2}/>,
73
+    )
74
+    done()
75
+  })
76
+
77
+
78
+})
79
+
80
+describe('Compare uploaded multipart image', (report, done) => {
81
+  let r1 = null
82
+  RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/public/test-img.png`)
83
+    .then((resp) => {
84
+      r1 = resp
85
+      return RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/public/test-text.txt`)
86
+    })
87
+    .then((resp) => {
88
+      report(
89
+        <Assert key="check file length" expect={image.length} actual={r1.base64().length}/>,
90
+        <Assert key="check file content" expect={'hello.txt'} actual={resp.text()}/>
91
+      )
92
+      done()
93
+    })
94
+
95
+})
96
+
97
+// added after 0.4.2
98
+
99
+describe('Progress report test', (report, done) => {
100
+  let actual = 0, expect = -1
101
+  RNFetchBlob
102
+    .fetch('GET', `${TEST_SERVER_URL}/public/1mb-dummy`, {
103
+      Authorization : 'Bearer abde123eqweje'
104
+    })
105
+    .progress((received, total) => {
106
+      actual = received
107
+      expect = total
108
+    })
109
+    .then((resp) => {
110
+      report(
111
+        <Assert key="download progress correct" expect={expect} actual={actual}/>,
112
+        <Assert key="response data should be correct event with progress listener"
113
+          expect={resp.text().substr(0,10)} actual={"1234567890"}/>)
114
+      done()
115
+    })
116
+
117
+})
118 118
 
119 119
 
120 120
 describe('PUT request test', (report, done) => {

+ 3
- 3
test/test-init.js Прегледај датотеку

@@ -18,8 +18,8 @@ const { Assert, Comparer, Info, describe, prop } = RNTest
18 18
 // test environment variables
19 19
 
20 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')
21
+prop('TEST_SERVER_URL', 'http://192.168.16.70:8123')
22
+prop('TEST_SERVER_URL_SSL', 'https://192.168.16.70:8124')
23 23
 prop('DROPBOX_TOKEN', 'fsXcpmKPrHgAAAAAAAAAoXZhcXYWdgLpQMan6Tb_bzJ237DXhgQSev12hA-gUXt4')
24 24
 prop('styles', {
25 25
   image : {
@@ -56,4 +56,4 @@ require('./test-0.5.1')
56 56
 require('./test-0.5.2')
57 57
 require('./test-0.6.0')
58 58
 require('./test-fs')
59
-// require('./test-android')
59
+require('./test-android')