|
@@ -17,6 +17,7 @@ import {
|
17
|
17
|
|
18
|
18
|
const fs = RNFetchBlob.fs
|
19
|
19
|
const Blob = RNFetchBlob.polyfill.Blob
|
|
20
|
+
|
20
|
21
|
window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest
|
21
|
22
|
window.Blob = Blob
|
22
|
23
|
|
|
@@ -48,6 +49,7 @@ describe('firebase login', (report, done) => {
|
48
|
49
|
.catch((err) => {
|
49
|
50
|
console.log('firebase sigin failed', err)
|
50
|
51
|
})
|
|
52
|
+
|
51
|
53
|
firebase.auth().onAuthStateChanged((user) => {
|
52
|
54
|
report(<Assert key="login status" uid="100"
|
53
|
55
|
expect={true}
|
|
@@ -60,27 +62,34 @@ describe('firebase login', (report, done) => {
|
60
|
62
|
})
|
61
|
63
|
|
62
|
64
|
|
63
|
|
-// describe('upload file to firebase', (report, done) => {
|
64
|
|
-//
|
65
|
|
-// try {
|
66
|
|
-// let storage = firebase.storage().ref()
|
67
|
|
-// let task = storage
|
68
|
|
-// .child(`testdata/firebase-test-${Platform.OS}.png`)
|
69
|
|
-// .put(new Blob(file, 'image/png'), { contentType : 'image/png' })
|
70
|
|
-//
|
71
|
|
-// task.on('state_change', null, (err) => {
|
72
|
|
-//
|
73
|
|
-// }, () => {
|
74
|
|
-// report(<Assert key="upload success"
|
75
|
|
-// expect={true}
|
76
|
|
-// actual={true}/>,
|
77
|
|
-// <Info key="uploaded file stat" >
|
78
|
|
-// <Text>{task.snapshot.totalBytes}</Text>
|
79
|
|
-// <Text>{JSON.stringify(task.snapshot.metadata)}</Text>
|
80
|
|
-// </Info>)
|
81
|
|
-// })
|
82
|
|
-// } catch(ex) {
|
83
|
|
-// console.log('firebase polyfill error', ex)
|
84
|
|
-// }
|
85
|
|
-//
|
86
|
|
-// })
|
|
65
|
+describe('upload file to firebase', (report, done) => {
|
|
66
|
+
|
|
67
|
+ try {
|
|
68
|
+ let blob = new Blob(RNTest.prop('image'), 'application/octet-binary')
|
|
69
|
+ blob.onCreated(() => {
|
|
70
|
+ console.log('BINGO')
|
|
71
|
+ let storage = firebase.storage().ref()
|
|
72
|
+ let task = storage
|
|
73
|
+ .child(`testdata/firebase-test-${Platform.OS}.png`)
|
|
74
|
+ .put(blob, { contentType : 'image/png' })
|
|
75
|
+
|
|
76
|
+ task.on('state_change', null, (err) => {
|
|
77
|
+
|
|
78
|
+ }, () => {
|
|
79
|
+ report(<Assert key="upload success"
|
|
80
|
+ expect={true}
|
|
81
|
+ actual={true}/>,
|
|
82
|
+ <Info key="uploaded file stat" >
|
|
83
|
+ <Text>{task.snapshot.totalBytes}</Text>
|
|
84
|
+ <Text>{JSON.stringify(task.snapshot.metadata)}</Text>
|
|
85
|
+ </Info>)
|
|
86
|
+ done()
|
|
87
|
+ })
|
|
88
|
+
|
|
89
|
+ })
|
|
90
|
+
|
|
91
|
+ } catch(ex) {
|
|
92
|
+ console.log('firebase polyfill error', ex)
|
|
93
|
+ }
|
|
94
|
+
|
|
95
|
+})
|