Ver código fonte

test case for #44

Ben Hsieh 8 anos atrás
pai
commit
8c8e7faac1
2 arquivos alterados com 35 adições e 26 exclusões
  1. 33
    24
      test/test-firebase.js
  2. 2
    2
      test/test-init.js

+ 33
- 24
test/test-firebase.js Ver arquivo

@@ -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
+})

+ 2
- 2
test/test-init.js Ver arquivo

@@ -18,8 +18,8 @@ const { Assert, Comparer, Info, prop } = RNTest
18 18
 // test environment variables
19 19
 
20 20
 prop('FILENAME', `${Platform.OS}-0.7.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.16.70:8123')
22
+prop('TEST_SERVER_URL_SSL', 'https://192.168.16.70:8124')
23 23
 prop('DROPBOX_TOKEN', 'fsXcpmKPrHgAAAAAAAAAoXZhcXYWdgLpQMan6Tb_bzJ237DXhgQSev12hA-gUXt4')
24 24
 prop('styles', {
25 25
   image : {