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

Commit

Permalink
Modify test scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
wkh237 committed May 26, 2016
1 parent 6f9eed1 commit b7b5956
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fetchblob",
"version": "0.4.0",
"version": "0.4.2",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
Expand All @@ -11,10 +11,6 @@
"chalk": "^1.1.3",
"chokidar": "^1.5.1",
"express": "^4.13.4",
"multer": "^1.1.0",
"npm": "^3.9.2"
},
"dependencies": {
"react-native-fetch-blob": "file:src"
"multer": "^1.1.0"
}
}
13 changes: 13 additions & 0 deletions test-server/server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* @author wkh237
* @description react-native-fetch-blob test & dev server
*/

var express = require('express');
var bodyParser = require('body-parser');
var chokidar = require('chokidar');
Expand Down Expand Up @@ -74,10 +79,12 @@ app.use(upload.any())

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

// for redirect test
app.get('/redirect', function(req, res) {
res.redirect('/public/github.png')
})

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

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

})

// return an empty response
app.all('/empty', function(req, res) {
res.send('')
})

// handle multipart/form-data request
app.post('/upload-form', function(req, res) {
console.log(req.headers)
console.log(req.body)
Expand Down
24 changes: 13 additions & 11 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import {
Image,
} from 'react-native';

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

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

ctx.describe('Progress report test', (report) => new Promise((resolve) => {

let received = 0
let p1 = RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/public/22mb-dummy`, {
Authorization : 'Bearer abde123eqweje'
})
let log = []

p1.onProgress = (written, total) => {
report(<Info key={`progress = ${written} bytes / ${total} bytes`}/>)
if(written === total)
report(<Assert key="progress goes to 100%" expect={written} actual={total}/>)
resolve()
}
// .progress((written, total) => {
// // report(<Info key={`progress = ${written} bytes / ${total} bytes`}/>)
// if(written === total)
// report(<Assert key="progress goes to 100%" expect={written} actual={total}/>)
// })
.then((resp) => {
report(<Assert key="response data should be correct event with progress listener"
expect={resp.text().substr(0,10)} actual={"1234567890"}/>)
resolve()
})

}))

Expand Down

0 comments on commit b7b5956

Please sign in to comment.