|
@@ -10,13 +10,7 @@ import {
|
10
|
10
|
Dimensions,
|
11
|
11
|
Image,
|
12
|
12
|
} from 'react-native';
|
13
|
|
-
|
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()
|
|
13
|
+import DataStore from 'nedb'
|
20
|
14
|
|
21
|
15
|
const fs = RNFetchBlob.fs
|
22
|
16
|
const { Assert, Comparer, Info, prop } = RNTest
|
|
@@ -30,66 +24,8 @@ const { TEST_SERVER_URL, TEST_SERVER_URL_SSL, FILENAME, DROPBOX_TOKEN, styles }
|
30
|
24
|
const dirs = RNFetchBlob.fs.dirs
|
31
|
25
|
|
32
|
26
|
let prefix = ((Platform.OS === 'android') ? 'file://' : '')
|
|
27
|
+const db = new DataStore()
|
33
|
28
|
|
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
|
|
- // })
|
|
29
|
+describe('nedb constructor test', (report, done) =>{
|
94
|
30
|
|
95
|
31
|
})
|