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

Commit e1207b8

Browse files
committed
wip commit
1 parent e5589d0 commit e1207b8

File tree

4 files changed

+90
-26
lines changed

4 files changed

+90
-26
lines changed

src/scripts/prelink.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ var fs = require('fs');
33
var MANIFEST_PATH = process.cwd() + '/android/app/src/main/AndroidManifest.xml';
44
var PACKAGE_JSON = process.cwd() + '/package.json';
55

6-
var hasNecessaryFile = fs.existsSync(MANIFEST_PATH) && fs.existsSync(MANIFEST_PATH);
6+
var hasNecessaryFile = fs.existsSync(MANIFEST_PATH) && fs.existsSync(PACKAGE_JSON);
77

88
if (!hasNecessaryFile) {
9-
throw 'RNFetchBlob could not found link Android automatically, some files could not be found.'
9+
throw 'RNFetchBlob could not link Android automatically, some files could not be found.'
1010
}
1111

1212
var package = JSON.parse(fs.readFileSync(PACKAGE_JSON));

test/.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
{ "src": "./node_modules/react-native-fetch-blob/node-polyfill/stream.js", "expose": "stream" }
1313
]]
1414
],
15-
"extends": "./node_modules/react-native/packager/react-packager/rn-babelrc.json",
15+
"extends": "./node_modules/react-native/packager/react-packager/rn-babelrc.json"
1616
}

test/test-0.10.0.js

Lines changed: 69 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import {
1111
Image,
1212
} from 'react-native';
1313

14-
window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest
15-
window.Blob = RNFetchBlob.polyfill.Blob
16-
window.fetch = new RNFetchBlob.polyfill.Fetch({
17-
auto : true,
18-
binaryContentTypes : ['image/', 'video/', 'audio/']
19-
}).build()
14+
// window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest
15+
// window.Blob = RNFetchBlob.polyfill.Blob
16+
// window.fetch = new RNFetchBlob.polyfill.Fetch({
17+
// auto : true,
18+
// binaryContentTypes : ['image/', 'video/', 'audio/']
19+
// }).build()
2020

2121
const fs = RNFetchBlob.fs
2222
const { Assert, Comparer, Info, prop } = RNTest
@@ -30,3 +30,66 @@ const { TEST_SERVER_URL, TEST_SERVER_URL_SSL, FILENAME, DROPBOX_TOKEN, styles }
3030
const dirs = RNFetchBlob.fs.dirs
3131

3232
let prefix = ((Platform.OS === 'android') ? 'file://' : '')
33+
34+
describe('test', (report, done) => {
35+
36+
console.log('start')
37+
38+
let image = RNTest.prop('image')
39+
let form = new FormData()
40+
form.append("FormData", true)
41+
form.append("access_token", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjU3YjgyZGQ2MTEwZDcwYmEwYjUxZjM5YyIsImlzTWVkaWMiOnRydWUsImlhdCI6MTQ3MTY4ODE1MiwiZXhwIjoxNDcxNzA2MTUyfQ.gPeql5g66Am4Txl1WqnbvOWJaD8srTK_6vihOJ6kFbY")
42+
form.append("Content-Type", "image/jpg")
43+
form.append('image', {
44+
uri : `data:image/png;base64, ${image}`,
45+
type : 'image/png'
46+
})
47+
48+
let xhr = new XMLHttpRequest()
49+
xhr.open('post', `${TEST_SERVER_URL}/upload-form`)
50+
xhr.send(form)
51+
console.log(form)
52+
xhr.onerror = function(e) {
53+
console.log('err', e)
54+
}
55+
xhr.onreadystatechange = function() {
56+
console.log('changed')
57+
if(this.readyState === this.DONE) {
58+
console.log(this.response)
59+
}
60+
}
61+
// fetch(`${TEST_SERVER_URL}/upload-form`, {
62+
// method : 'POST',
63+
// body : form
64+
// })
65+
// .then((res) => res.text())
66+
// .then((data) => {
67+
// console.log(data)
68+
// })
69+
70+
// let filename = 'test-from-storage-img-'+Date.now()+'.png'
71+
// RNFetchBlob.fetch('POST', `${TEST_SERVER_URL}/upload-form`, {
72+
// 'Content-Type' : 'multipart/form-data',
73+
// }, [
74+
// { name : 'test-text', filename : 'test-text.txt', data: RNFetchBlob.base64.encode('hello.txt')},
75+
// { name : 'field1', data : 'hello !!'},
76+
// { name : 'field2', data : 'hello2 !!'}
77+
// ])
78+
// .then((resp) => {
79+
// resp = resp.json()
80+
// report(
81+
// <Assert key="check posted form data #1" expect="hello !!" actual={resp.fields.field1}/>,
82+
// <Assert key="check posted form data #2" expect="hello2 !!" actual={resp.fields.field2}/>,
83+
// )
84+
// return RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/public/${filename}`)
85+
// })
86+
// .then((resp) => {
87+
// report(<Info key="uploaded image">
88+
// <Image
89+
// style={styles.image}
90+
// source={{ uri : 'data:image/png;base64, '+ resp.base64()}}/>
91+
// </Info>)
92+
// done()
93+
// })
94+
95+
})

test/test-init.js

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

2020
prop('FILENAME', `${Platform.OS}-0.8.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.0.12:8123')
22+
prop('TEST_SERVER_URL_SSL', 'https://192.168.0.12:8124')
2323
prop('DROPBOX_TOKEN', 'fsXcpmKPrHgAAAAAAAAAoXZhcXYWdgLpQMan6Tb_bzJ237DXhgQSev12hA-gUXt4')
2424
prop('styles', {
2525
image : {
@@ -59,20 +59,21 @@ describe('GET image from server', (report, done) => {
5959
})
6060

6161

62-
require('./test-0.1.x-0.4.x')
63-
require('./test-0.5.1')
64-
require('./test-0.5.2')
65-
require('./test-0.6.0')
66-
require('./test-0.6.2')
67-
require('./test-0.7.0')
68-
require('./test-0.8.0')
69-
require('./test-0.9.0')
70-
require('./test-0.9.2')
71-
require('./test-fetch')
72-
require('./test-fs')
73-
require('./test-xmlhttp')
74-
require('./test-blob')
75-
require('./test-firebase')
76-
require('./test-android')
62+
// require('./test-0.1.x-0.4.x')
63+
// require('./test-0.5.1')
64+
// require('./test-0.5.2')
65+
// require('./test-0.6.0')
66+
// require('./test-0.6.2')
67+
// require('./test-0.7.0')
68+
// require('./test-0.8.0')
69+
// require('./test-0.9.0')
70+
// require('./test-0.9.2')
71+
require('./test-0.10.0')
72+
// require('./test-fetch')
73+
// require('./test-fs')
74+
// require('./test-xmlhttp')
75+
// require('./test-blob')
76+
// require('./test-firebase')
77+
// require('./test-android')
7778
// require('./test-stress')
7879
// require('./benchmark')

0 commit comments

Comments
 (0)