@@ -6,9 +6,7 @@ import { FirebaseApp, FirebaseAppConfig, AngularFireModule } from 'angularfire2'
6
6
import { AngularFireStorageModule , AngularFireStorage } from 'angularfire2/storage' ;
7
7
import { COMMON_CONFIG } from './test-config' ;
8
8
9
- console . log ( AngularFireStorageModule ) ;
10
-
11
- fdescribe ( 'AngularFireStorage' , ( ) => {
9
+ describe ( 'AngularFireStorage' , ( ) => {
12
10
let app : firebase . app . App ;
13
11
let afStorage : AngularFireStorage ;
14
12
@@ -62,10 +60,32 @@ fdescribe('AngularFireStorage', () => {
62
60
const blob = new Blob ( [ JSON . stringify ( data ) ] , { type : 'application/json' } ) ;
63
61
const ref = afStorage . ref ( 'af.json' ) ;
64
62
const task = ref . put ( blob ) ;
63
+ // Wait for the upload
65
64
const sub = forkJoin ( task . snapshotChanges ( ) )
65
+ // get the url download
66
66
. mergeMap ( ( ) => ref . getDownloadURL ( ) )
67
+ // assert the URL
67
68
. do ( url => expect ( url ) . toBeDefined ( ) )
69
+ // Delete the file
68
70
. mergeMap ( url => ref . delete ( ) )
71
+ // finish the test
72
+ . subscribe ( done , done . fail ) ;
73
+ } ) ;
74
+
75
+ it ( 'should upload, get metadata, and delete' , ( done ) => {
76
+ const data = { angular : "fire" } ;
77
+ const blob = new Blob ( [ JSON . stringify ( data ) ] , { type : 'application/json' } ) ;
78
+ const ref = afStorage . ref ( 'af.json' ) ;
79
+ const task = ref . put ( blob , { customMetadata : { blah : 'blah' } } ) ;
80
+ // Wait for the upload
81
+ const sub = forkJoin ( task . snapshotChanges ( ) )
82
+ // get the metadata download
83
+ . mergeMap ( ( ) => ref . getMetadata ( ) )
84
+ // assert the URL
85
+ . do ( meta => expect ( meta . customMetadata ) . toEqual ( { blah : 'blah' } ) )
86
+ // Delete the file
87
+ . mergeMap ( meta => ref . delete ( ) )
88
+ // finish the test
69
89
. subscribe ( done , done . fail ) ;
70
90
} ) ;
71
91
0 commit comments