Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Commit 97e28f0

Browse files
committed
Change test cases
1 parent db217d9 commit 97e28f0

File tree

2 files changed

+99
-99
lines changed

2 files changed

+99
-99
lines changed

test/test-0.1.x-0.4.x.js

Lines changed: 96 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -19,102 +19,102 @@ const describe = RNTest.config({
1919

2020
let { TEST_SERVER_URL, FILENAME, DROPBOX_TOKEN, styles, image } = prop()
2121

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+
})
118118

119119

120120
describe('PUT request test', (report, done) => {

test/test-init.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ const { Assert, Comparer, Info, describe, prop } = RNTest
1818
// test environment variables
1919

2020
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')
2323
prop('DROPBOX_TOKEN', 'fsXcpmKPrHgAAAAAAAAAoXZhcXYWdgLpQMan6Tb_bzJ237DXhgQSev12hA-gUXt4')
2424
prop('styles', {
2525
image : {
@@ -56,4 +56,4 @@ require('./test-0.5.1')
5656
require('./test-0.5.2')
5757
require('./test-0.6.0')
5858
require('./test-fs')
59-
// require('./test-android')
59+
require('./test-android')

0 commit comments

Comments
 (0)