瀏覽代碼

Uncomment firebase test cases

Ben Hsieh 8 年之前
父節點
當前提交
35174ea600
共有 1 個文件被更改,包括 86 次插入86 次删除
  1. 86
    86
      test/test-firebase.js

+ 86
- 86
test/test-firebase.js 查看文件

@@ -61,89 +61,89 @@ describe('firebase login', (report, done) => {
61 61
   })
62 62
 })
63 63
 
64
-// describe('upload file to firebase', (report, done) => {
65
-//
66
-//   // create Blob from BASE64 data
67
-//   let blob = new Blob(RNTest.prop('image'), { type : 'image/png;BASE64'})
68
-//   let testImage = `firebase-test-${Platform.OS}-${Date.now()}.png`
69
-//   RNTest.prop('firebase-image', testImage)
70
-//   // start test after Blob created
71
-//   blob.onCreated(() => {
72
-//     let storage = firebase.storage().ref('rnfbtest')
73
-//     let task = storage
74
-//       .child(RNTest.prop('firebase-image'))
75
-//       .put(blob, { contentType : 'image/png' })
76
-//       .then((snapshot) => {
77
-//         console.log(snapshot.metadata)
78
-//         report(<Assert key="upload success"
79
-//           expect={true}
80
-//           actual={true}/>,
81
-//         <Info key="uploaded file stat" >
82
-//           <Text>{snapshot.totalBytes}</Text>
83
-//           <Text>{JSON.stringify(snapshot.metadata)}</Text>
84
-//         </Info>)
85
-//         done()
86
-//       })
87
-//   })
88
-// })
89
-//
90
-// describe('download firebase storage item', (report, done) => {
91
-//   let storage = firebase.storage().ref('rnfbtest/' + RNTest.prop('firebase-image'))
92
-//   storage.getDownloadURL().then((url) => {
93
-//     console.log(url)
94
-//     report(<Info key="image viewer">
95
-//       <Image style={styles.image} source={{uri : url}}/>
96
-//     </Info>)
97
-//     done()
98
-//   })
99
-// })
100
-//
101
-// let tier2FileName = `firebase-test-${Platform.OS}-github2.jpg`
102
-//
103
-// describe('upload using file path', (report, done) => {
104
-//   RNFetchBlob
105
-//     .config({ fileCache : true, appendExt : 'jpg' })
106
-//     .fetch('GET', `${TEST_SERVER_URL}/public/github2.jpg`)
107
-//     .then((resp) => {
108
-//       report(<Info key="test image">
109
-//         <Image style={styles.image} source={{uri : prefix + resp.path()}}/>
110
-//       </Info>)
111
-//       let blob = new Blob(RNFetchBlob.wrap(resp.path()), { type : 'image/jpg' })
112
-//       blob.onCreated(() => {
113
-//         firebase.storage().ref('rnfbtest')
114
-//           .child(tier2FileName)
115
-//           .put(blob, { contentType : 'image/jpg' })
116
-//           .then(() => {
117
-//             report(<Assert key="upload finished" />)
118
-//             done()
119
-//           })
120
-//       })
121
-//     })
122
-// })
123
-//
124
-// let directURL = null
125
-//
126
-// describe('verify uploaded file', (report, done) => {
127
-//   firebase.storage().ref('rnfbtest/' + tier2FileName)
128
-//     .getDownloadURL()
129
-//     .then((url) => {
130
-//       directURL = url
131
-//       report(
132
-//         <Info key="image viewer">
133
-//           <Image style={styles.image} source={{uri : url}}/>
134
-//         </Info>)
135
-//       done()
136
-//     })
137
-// })
138
-//
139
-// describe('download to base64', (report, done) => {
140
-//   RNFetchBlob.fetch('GET', directURL).then((resp) => {
141
-//     report(
142
-//       <Info key="image data">
143
-//         <Image
144
-//           style={styles.image}
145
-//           source={{uri : 'data:image/jpg;base64 ,'+ resp.base64()}}/>
146
-//       </Info>)
147
-//     done()
148
-//   })
149
-// })
64
+describe('upload file to firebase', (report, done) => {
65
+
66
+  // create Blob from BASE64 data
67
+  let blob = new Blob(RNTest.prop('image'), { type : 'image/png;BASE64'})
68
+  let testImage = `firebase-test-${Platform.OS}-${Date.now()}.png`
69
+  RNTest.prop('firebase-image', testImage)
70
+  // start test after Blob created
71
+  blob.onCreated(() => {
72
+    let storage = firebase.storage().ref('rnfbtest')
73
+    let task = storage
74
+      .child(RNTest.prop('firebase-image'))
75
+      .put(blob, { contentType : 'image/png' })
76
+      .then((snapshot) => {
77
+        console.log(snapshot.metadata)
78
+        report(<Assert key="upload success"
79
+          expect={true}
80
+          actual={true}/>,
81
+        <Info key="uploaded file stat" >
82
+          <Text>{snapshot.totalBytes}</Text>
83
+          <Text>{JSON.stringify(snapshot.metadata)}</Text>
84
+        </Info>)
85
+        done()
86
+      })
87
+  })
88
+})
89
+
90
+describe('download firebase storage item', (report, done) => {
91
+  let storage = firebase.storage().ref('rnfbtest/' + RNTest.prop('firebase-image'))
92
+  storage.getDownloadURL().then((url) => {
93
+    console.log(url)
94
+    report(<Info key="image viewer">
95
+      <Image style={styles.image} source={{uri : url}}/>
96
+    </Info>)
97
+    done()
98
+  })
99
+})
100
+
101
+let tier2FileName = `firebase-test-${Platform.OS}-github2.jpg`
102
+
103
+describe('upload using file path', (report, done) => {
104
+  RNFetchBlob
105
+    .config({ fileCache : true, appendExt : 'jpg' })
106
+    .fetch('GET', `${TEST_SERVER_URL}/public/github2.jpg`)
107
+    .then((resp) => {
108
+      report(<Info key="test image">
109
+        <Image style={styles.image} source={{uri : prefix + resp.path()}}/>
110
+      </Info>)
111
+      let blob = new Blob(RNFetchBlob.wrap(resp.path()), { type : 'image/jpg' })
112
+      blob.onCreated(() => {
113
+        firebase.storage().ref('rnfbtest')
114
+          .child(tier2FileName)
115
+          .put(blob, { contentType : 'image/jpg' })
116
+          .then(() => {
117
+            report(<Assert key="upload finished" />)
118
+            done()
119
+          })
120
+      })
121
+    })
122
+})
123
+
124
+let directURL = null
125
+
126
+describe('verify uploaded file', (report, done) => {
127
+  firebase.storage().ref('rnfbtest/' + tier2FileName)
128
+    .getDownloadURL()
129
+    .then((url) => {
130
+      directURL = url
131
+      report(
132
+        <Info key="image viewer">
133
+          <Image style={styles.image} source={{uri : url}}/>
134
+        </Info>)
135
+      done()
136
+    })
137
+})
138
+
139
+describe('download to base64', (report, done) => {
140
+  RNFetchBlob.fetch('GET', directURL).then((resp) => {
141
+    report(
142
+      <Info key="image data">
143
+        <Image
144
+          style={styles.image}
145
+          source={{uri : 'data:image/jpg;base64 ,'+ resp.base64()}}/>
146
+      </Info>)
147
+    done()
148
+  })
149
+})