Browse Source

Ad test case #44

Ben Hsieh 8 years ago
parent
commit
fbdebf001b
4 changed files with 32 additions and 21 deletions
  1. 5
    1
      test/test-0.8.0.js
  2. 14
    6
      test/test-blob.js
  3. 13
    13
      test/test-init.js
  4. 0
    1
      test/test-xmlhttp.js

+ 5
- 1
test/test-0.8.0.js View File

25
 
25
 
26
 let prefix = ((Platform.OS === 'android') ? 'file://' : '')
26
 let prefix = ((Platform.OS === 'android') ? 'file://' : '')
27
 
27
 
28
-describe('URI encoding support', (report, done) => {
28
+describe('fs URI encoding support', (report, done) => {
29
 
29
 
30
   let testData1 = `test date write file from file ${Date.now()}`
30
   let testData1 = `test date write file from file ${Date.now()}`
31
   let testData2 = `test date write file from file ${Date.now()*Math.random()}`
31
   let testData2 = `test date write file from file ${Date.now()*Math.random()}`
55
     })
55
     })
56
 })
56
 })
57
 
57
 
58
+describe('request timeout working properly', (report, done) => {
59
+  done()
60
+})
61
+
58
 function getASCIIArray(str) {
62
 function getASCIIArray(str) {
59
   let r = []
63
   let r = []
60
   for(let i=0;i<str.length;i++) {
64
   for(let i=0;i<str.length;i++) {

+ 14
- 6
test/test-blob.js View File

103
   let expect = 'test-' + Date.now()
103
   let expect = 'test-' + Date.now()
104
   Blob.clearCache()
104
   Blob.clearCache()
105
       .then(() => Blob.build(expect))
105
       .then(() => Blob.build(expect))
106
+      .catch((err) => {
107
+        console.warn(err)
108
+      })
106
       .then((b) => fs.readFile(b.getRNFetchBlobRef(), 'utf8'))
109
       .then((b) => fs.readFile(b.getRNFetchBlobRef(), 'utf8'))
107
       .then((data) => {
110
       .then((data) => {
108
         report(
111
         report(
124
 describe('create blob using FormData', (report, done) => {
127
 describe('create blob using FormData', (report, done) => {
125
   let form = new FormData()
128
   let form = new FormData()
126
   let fname = 'blob-test' + Date.now()
129
   let fname = 'blob-test' + Date.now()
127
-  File.build(RNTest.prop('image'), { type:'image/png;base64' })
130
+  File.build('test.png', RNTest.prop('image'), { type:'image/png;base64' })
128
       .then((f) => {
131
       .then((f) => {
129
-        f.name = 'test.png'
130
         form.append('name', fname)
132
         form.append('name', fname)
131
         form.append('blob', f)
133
         form.append('blob', f)
132
         return Blob.build(form)
134
         return Blob.build(form)
133
       })
135
       })
134
-      .then((b) => RNFetchBlob
135
-                    .fetch('POST', `${TEST_SERVER_URL}/upload-form`, {
136
-                      'content-type' : 'multipart/form-data; boundary='+b.multipartBoundary
137
-                    }, RNFetchBlob.wrap(b.getRNFetchBlobRef())))
136
+      .then((b) => {
137
+        let body = RNFetchBlob.wrap(b.getRNFetchBlobRef())
138
+        return RNFetchBlob.fetch(
139
+          'POST',
140
+          `${TEST_SERVER_URL}/upload-form`,
141
+          {
142
+            'content-type' : 'multipart/form-data; boundary='+b.multipartBoundary
143
+          },
144
+          body)
145
+      })
138
       .then((resp) => {
146
       .then((resp) => {
139
         report(
147
         report(
140
           <Assert key="form data verification #1"
148
           <Assert key="form data verification #1"

+ 13
- 13
test/test-init.js View File

18
 // test environment variables
18
 // test environment variables
19
 
19
 
20
 prop('FILENAME', `${Platform.OS}-0.8.0-${Date.now()}.png`)
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.16.70:8124')
21
+prop('TEST_SERVER_URL', 'http://192.168.0.11:8123')
22
+prop('TEST_SERVER_URL_SSL', 'https://192.168.0.11:8124')
23
 prop('DROPBOX_TOKEN', 'fsXcpmKPrHgAAAAAAAAAoXZhcXYWdgLpQMan6Tb_bzJ237DXhgQSev12hA-gUXt4')
23
 prop('DROPBOX_TOKEN', 'fsXcpmKPrHgAAAAAAAAAoXZhcXYWdgLpQMan6Tb_bzJ237DXhgQSev12hA-gUXt4')
24
 prop('styles', {
24
 prop('styles', {
25
   image : {
25
   image : {
58
 })
58
 })
59
 
59
 
60
 
60
 
61
-// require('./test-0.1.x-0.4.x')
62
-// require('./test-0.5.1')
63
-// require('./test-0.5.2')
64
-// require('./test-0.6.0')
65
-// require('./test-0.6.2')
66
-// require('./test-0.6.3')
67
-// require('./test-0.7.0')
68
-// require('./test-0.8.0')
69
-// require('./test-fs')
70
-// require('./test-xmlhttp')
61
+require('./test-0.1.x-0.4.x')
62
+require('./test-0.5.1')
63
+require('./test-0.5.2')
64
+require('./test-0.6.0')
65
+require('./test-0.6.2')
66
+require('./test-0.6.3')
67
+require('./test-0.7.0')
68
+require('./test-0.8.0')
69
+require('./test-fs')
70
+require('./test-xmlhttp')
71
 require('./test-blob')
71
 require('./test-blob')
72
 require('./test-firebase')
72
 require('./test-firebase')
73
-// require('./test-android')
73
+require('./test-android')

+ 0
- 1
test/test-xmlhttp.js View File

19
 
19
 
20
 window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest
20
 window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest
21
 window.Blob = Blob
21
 window.Blob = Blob
22
-window.FormData = RNFetchBlob.polyfill.FormData
23
 window.ProgressEvent = RNFetchBlob.polyfill.ProgressEvent
22
 window.ProgressEvent = RNFetchBlob.polyfill.ProgressEvent
24
 
23
 
25
 const { Assert, Comparer, Info, prop } = RNTest
24
 const { Assert, Comparer, Info, prop } = RNTest