@@ -54,7 +54,7 @@ describe('AngularFireStorage', () => {
54
54
it ( 'should upload a file and observe the download url' , ( done ) => {
55
55
const data = { angular : "fire" } ;
56
56
const blob = new Blob ( [ JSON . stringify ( data ) ] , { type : 'application/json' } ) ;
57
- const ref = afStorage . ref ( 'afs .json' ) ;
57
+ const ref = afStorage . ref ( 'af .json' ) ;
58
58
const task = ref . put ( blob ) ;
59
59
const url$ = task . downloadURL ( ) ;
60
60
url$ . subscribe (
@@ -67,7 +67,7 @@ describe('AngularFireStorage', () => {
67
67
it ( 'should resolve the task as a promise' , ( done ) => {
68
68
const data = { angular : "promise" } ;
69
69
const blob = new Blob ( [ JSON . stringify ( data ) ] , { type : 'application/json' } ) ;
70
- const ref = afStorage . ref ( 'afs .json' ) ;
70
+ const ref = afStorage . ref ( 'af .json' ) ;
71
71
const task : AngularFireUploadTask = ref . put ( blob ) ;
72
72
task . then ( snap => {
73
73
expect ( snap ) . toBeDefined ( ) ;
@@ -118,7 +118,7 @@ describe('AngularFireStorage', () => {
118
118
} ) ;
119
119
120
120
const FIREBASE_APP_NAME_TOO = ( Math . random ( ) + 1 ) . toString ( 36 ) . substring ( 7 ) ;
121
- const FIREBASE_STORAGE_BUCKET = `gs://test- ${ ( Math . random ( ) + 1 ) . toString ( 36 ) . substring ( 7 ) } /` ;
121
+ const FIREBASE_STORAGE_BUCKET = 'angularfire2-test2' ;
122
122
123
123
describe ( 'AngularFireStorage w/options' , ( ) => {
124
124
let app : FirebaseApp ;
@@ -160,8 +160,25 @@ describe('AngularFireStorage w/options', () => {
160
160
expect ( afStorage . storage . app . name ) . toEqual ( FIREBASE_APP_NAME_TOO ) ;
161
161
} ) ;
162
162
163
- it ( 'should be pointing towards a different bucket' , ( ) => {
164
- expect ( afStorage . storage . ref ( ) . toString ( ) ) . toEqual ( FIREBASE_STORAGE_BUCKET ) ;
163
+ it ( 'storage be pointing towards a different bucket' , ( ) => {
164
+ expect ( afStorage . storage . ref ( ) . toString ( ) ) . toEqual ( `gs://${ FIREBASE_STORAGE_BUCKET } /` ) ;
165
+ } ) ;
166
+
167
+ it ( 'it should upload, download, and delete' , ( done ) => {
168
+ const data = { angular : "fire" } ;
169
+ const blob = new Blob ( [ JSON . stringify ( data ) ] , { type : 'application/json' } ) ;
170
+ const ref = afStorage . ref ( 'af.json' ) ;
171
+ const task = ref . put ( blob ) ;
172
+ // Wait for the upload
173
+ const sub = forkJoin ( task . snapshotChanges ( ) )
174
+ // get the url download
175
+ . mergeMap ( ( ) => ref . getDownloadURL ( ) )
176
+ // assert the URL
177
+ . do ( url => expect ( url ) . toMatch ( new RegExp ( `https:\\/\\/firebasestorage\\.googleapis\\.com\\/v0\\/b\\/${ FIREBASE_STORAGE_BUCKET } \\/o\\/af\\.json` ) ) )
178
+ // Delete the file
179
+ . mergeMap ( url => ref . delete ( ) )
180
+ // finish the test
181
+ . subscribe ( done , done . fail ) ;
165
182
} ) ;
166
183
167
184
} ) ;
0 commit comments