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

Commit b7b5956

Browse files
committed
Modify test scripts
1 parent 6f9eed1 commit b7b5956

File tree

3 files changed

+28
-17
lines changed

3 files changed

+28
-17
lines changed

package.json

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fetchblob",
3-
"version": "0.4.0",
3+
"version": "0.4.2",
44
"private": true,
55
"scripts": {
66
"start": "node node_modules/react-native/local-cli/cli.js start",
@@ -11,10 +11,6 @@
1111
"chalk": "^1.1.3",
1212
"chokidar": "^1.5.1",
1313
"express": "^4.13.4",
14-
"multer": "^1.1.0",
15-
"npm": "^3.9.2"
16-
},
17-
"dependencies": {
18-
"react-native-fetch-blob": "file:src"
14+
"multer": "^1.1.0"
1915
}
2016
}

test-server/server.js

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* @author wkh237
3+
* @description react-native-fetch-blob test & dev server
4+
*/
5+
16
var express = require('express');
27
var bodyParser = require('body-parser');
38
var chokidar = require('chokidar');
@@ -74,10 +79,12 @@ app.use(upload.any())
7479

7580
app.use('/public', express.static('./public'))
7681

82+
// for redirect test
7783
app.get('/redirect', function(req, res) {
7884
res.redirect('/public/github.png')
7985
})
8086

87+
// handle octet-stream request
8188
app.post('/upload', function(req, res){
8289

8390
console.log(req.headers)
@@ -91,6 +98,12 @@ app.post('/upload', function(req, res){
9198

9299
})
93100

101+
// return an empty response
102+
app.all('/empty', function(req, res) {
103+
res.send('')
104+
})
105+
106+
// handle multipart/form-data request
94107
app.post('/upload-form', function(req, res) {
95108
console.log(req.headers)
96109
console.log(req.body)

test/tests.js

+13-11
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import {
1313
Image,
1414
} from 'react-native';
1515

16-
const FILENAME = `${Platform.OS}-0.4.0-${Date.now()}.png`
16+
const FILENAME = `${Platform.OS}-0.4.2-${Date.now()}.png`
1717
// paste your test config here
18-
const TEST_SERVER_URL = 'http://192.168.0.14:8123'
18+
const TEST_SERVER_URL = 'http://192.168.17.193:8123'
1919
const DROPBOX_TOKEN = 'fsXcpmKPrHgAAAAAAAAAoXZhcXYWdgLpQMan6Tb_bzJ237DXhgQSev12hA-gUXt4'
2020

2121
const ctx = new RNTest.TestContext()
@@ -100,18 +100,20 @@ ctx.describe('Compare uploaded multipart image', async function(report) {
100100
})
101101

102102
ctx.describe('Progress report test', (report) => new Promise((resolve) => {
103-
103+
let received = 0
104104
let p1 = RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/public/22mb-dummy`, {
105105
Authorization : 'Bearer abde123eqweje'
106106
})
107-
let log = []
108-
109-
p1.onProgress = (written, total) => {
110-
report(<Info key={`progress = ${written} bytes / ${total} bytes`}/>)
111-
if(written === total)
112-
report(<Assert key="progress goes to 100%" expect={written} actual={total}/>)
113-
resolve()
114-
}
107+
// .progress((written, total) => {
108+
// // report(<Info key={`progress = ${written} bytes / ${total} bytes`}/>)
109+
// if(written === total)
110+
// report(<Assert key="progress goes to 100%" expect={written} actual={total}/>)
111+
// })
112+
.then((resp) => {
113+
report(<Assert key="response data should be correct event with progress listener"
114+
expect={resp.text().substr(0,10)} actual={"1234567890"}/>)
115+
resolve()
116+
})
115117

116118
}))
117119

0 commit comments

Comments
 (0)