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

Commit 8f318b7

Browse files
committed
Add test cases for #33
1 parent 6117206 commit 8f318b7

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

test-server/server.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,17 @@ app.all('/params', function(req, res) {
7979
app.all('/empty', function(req, res) {
8080
res.send('')
8181
})
82+
83+
app.delete('/hey', function(req, res) {
84+
res.send('man')
85+
})
86+
8287
// handle multipart/form-data request
83-
app.post('/upload-form', function(req, res) {
88+
app.post('/upload-form', formUpload)
89+
90+
app.put('/upload-form', formUpload)
91+
92+
function formUpload(req, res) {
8493
console.log(req.headers)
8594
console.log(req.body)
8695
console.log(req.files)
@@ -94,7 +103,7 @@ app.post('/upload-form', function(req, res) {
94103
fields : req.body,
95104
files : req.files
96105
})
97-
})
106+
}
98107

99108
function watch(source, dest, ignore) {
100109
// watch files in test folder

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

+31
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,34 @@ describe('Progress report test', (report, done) => {
114114
})
115115

116116
})
117+
118+
119+
describe('PUT request test', (report, done) => {
120+
121+
RNFetchBlob.fetch('PUT', `${TEST_SERVER_URL}/upload-form`, {
122+
Authorization : "Bearer fsXcpmKPrHgAAAAAAAAAEGxFXwhejXM_E8fznZoXPhHbhbNhA-Lytbe6etp1Jznz",
123+
'Content-Type' : 'multipart/form-data',
124+
}, [
125+
{ name : 'test-img', filename : 'test-img.png', data: image},
126+
{ name : 'test-text', filename : 'test-text.txt', data: RNFetchBlob.base64.encode('hello.txt')},
127+
{ name : 'field1', data : 'hello !!'},
128+
{ name : 'field2', data : 'hello2 !!'}
129+
])
130+
.then((resp) => {
131+
resp = resp.json()
132+
report(
133+
<Assert key="check put form data #1" expect="hello !!" actual={resp.fields.field1}/>,
134+
<Assert key="check put form data #2" expect="hello2 !!" actual={resp.fields.field2}/>,
135+
)
136+
done()
137+
})
138+
})
139+
140+
describe('DELETE request test', (report, done) => {
141+
RNFetchBlob.fetch('DELETE', `${TEST_SERVER_URL}/hey`)
142+
.then((resp) => {
143+
report(
144+
<Assert key="check DELETE request result" expect={'man'} actual={resp.text()}/>,
145+
done()
146+
})
147+
})

0 commit comments

Comments
 (0)