@@ -21,6 +21,14 @@ describe('storage() -> StorageReference', function () {
21
21
describe ( 'firebase v8 compatibility' , function ( ) {
22
22
before ( async function ( ) {
23
23
await seed ( PATH ) ;
24
+
25
+ // @ts -ignore
26
+ globalThis . RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = true ;
27
+ } ) ;
28
+
29
+ after ( async function afterEachTest ( ) {
30
+ // @ts -ignore
31
+ globalThis . RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = false ;
24
32
} ) ;
25
33
26
34
describe ( 'toString()' , function ( ) {
@@ -671,24 +679,24 @@ describe('storage() -> StorageReference', function () {
671
679
} ) ;
672
680
} ) ;
673
681
} ) ;
674
- } ) ;
675
682
676
- describe ( 'put secondaryApp' , function ( ) {
677
- it ( 'allows valid metadata properties for upload' , async function ( ) {
678
- const storageReference = firebase
679
- . storage ( firebase . app ( 'secondaryFromNative' ) )
680
- // .storage()
681
- . ref ( `${ PATH } /metadataTest.jpeg` ) ;
682
- await storageReference . put ( new ArrayBuffer ( ) , {
683
- contentType : 'image/jpg' ,
684
- md5hash : '123412341234' ,
685
- cacheControl : 'true' ,
686
- contentDisposition : 'disposed' ,
687
- contentEncoding : 'application/octet-stream' ,
688
- contentLanguage : 'de' ,
689
- customMetadata : {
690
- customMetadata1 : 'metadata1value' ,
691
- } ,
683
+ describe ( 'put secondaryApp' , function ( ) {
684
+ it ( 'allows valid metadata properties for upload' , async function ( ) {
685
+ const storageReference = firebase
686
+ . storage ( firebase . app ( 'secondaryFromNative' ) )
687
+ // .storage()
688
+ . ref ( `${ PATH } /metadataTest.jpeg` ) ;
689
+ await storageReference . put ( new ArrayBuffer ( ) , {
690
+ contentType : 'image/jpg' ,
691
+ md5hash : '123412341234' ,
692
+ cacheControl : 'true' ,
693
+ contentDisposition : 'disposed' ,
694
+ contentEncoding : 'application/octet-stream' ,
695
+ contentLanguage : 'de' ,
696
+ customMetadata : {
697
+ customMetadata1 : 'metadata1value' ,
698
+ } ,
699
+ } ) ;
692
700
} ) ;
693
701
} ) ;
694
702
} ) ;
@@ -700,8 +708,9 @@ describe('storage() -> StorageReference', function () {
700
708
before ( async function ( ) {
701
709
await seed ( PATH ) ;
702
710
711
+ const { getApp } = modular ;
703
712
const { getStorage } = storageModular ;
704
- secondStorage = getStorage ( firebase . app ( ) , secondStorageBucket ) ;
713
+ secondStorage = getStorage ( getApp ( ) , secondStorageBucket ) ;
705
714
} ) ;
706
715
707
716
describe ( 'second storage bucket writes to Storage emulator' , function ( ) {
@@ -737,12 +746,12 @@ describe('storage() -> StorageReference', function () {
737
746
738
747
describe ( 'toString()' , function ( ) {
739
748
it ( 'returns the correct bucket path to the file' , function ( ) {
749
+ const { getApp } = modular ;
740
750
const { getStorage, ref, toString } = storageModular ;
741
751
const storageReference = ref ( getStorage ( ) , `/uploadNope.jpeg` ) ;
742
- const app = firebase . app ( ) ;
743
752
744
753
toString ( storageReference ) . should . equal (
745
- `gs://${ app . options . storageBucket } /uploadNope.jpeg` ,
754
+ `gs://${ getApp ( ) . options . storageBucket } /uploadNope.jpeg` ,
746
755
) ;
747
756
} ) ;
748
757
} ) ;
@@ -768,10 +777,10 @@ describe('storage() -> StorageReference', function () {
768
777
769
778
describe ( 'bucket' , function ( ) {
770
779
it ( 'returns the storage bucket as a string' , function ( ) {
780
+ const { getApp } = modular ;
771
781
const { getStorage, ref } = storageModular ;
772
782
const storageReference = ref ( getStorage ( ) , '/foo/uploadNope.jpeg' ) ;
773
- const app = firebase . app ( ) ;
774
- storageReference . bucket . should . equal ( app . options . storageBucket ) ;
783
+ storageReference . bucket . should . equal ( getApp ( ) . options . storageBucket ) ;
775
784
} ) ;
776
785
} ) ;
777
786
@@ -879,14 +888,15 @@ describe('storage() -> StorageReference', function () {
879
888
880
889
describe ( 'getDownloadURL' , function ( ) {
881
890
it ( 'should return a download url for a file' , async function ( ) {
891
+ const { getApp } = modular ;
882
892
const { getStorage, ref, getDownloadURL } = storageModular ;
883
893
// This is frequently flaky in CI - but works sometimes. Skipping only in CI for now.
884
894
if ( ! isCI ) {
885
895
const storageReference = ref ( getStorage ( ) , `${ PATH } /list/file1.txt` ) ;
886
896
const downloadUrl = await getDownloadURL ( storageReference ) ;
887
897
downloadUrl . should . be . a . String ( ) ;
888
898
downloadUrl . should . containEql ( 'file1.txt' ) ;
889
- downloadUrl . should . containEql ( firebase . app ( ) . options . projectId ) ;
899
+ downloadUrl . should . containEql ( getApp ( ) . options . projectId ) ;
890
900
} else {
891
901
this . skip ( ) ;
892
902
}
@@ -931,6 +941,7 @@ describe('storage() -> StorageReference', function () {
931
941
932
942
describe ( 'getMetadata' , function ( ) {
933
943
it ( 'should return a metadata for a file' , async function ( ) {
944
+ const { getApp } = modular ;
934
945
const { getStorage, ref, getMetadata } = storageModular ;
935
946
const storageReference = ref ( getStorage ( ) , `${ PATH } /list/file1.txt` ) ;
936
947
const metadata = await getMetadata ( storageReference ) ;
@@ -950,7 +961,7 @@ describe('storage() -> StorageReference', function () {
950
961
metadata . contentEncoding . should . be . a . String ( ) ;
951
962
metadata . contentDisposition . should . be . a . String ( ) ;
952
963
metadata . contentType . should . equal ( 'text/plain' ) ;
953
- metadata . bucket . should . equal ( `${ firebase . app ( ) . options . projectId } .appspot.com` ) ;
964
+ metadata . bucket . should . equal ( `${ getApp ( ) . options . projectId } .appspot.com` ) ;
954
965
metadata . metageneration . should . be . a . String ( ) ;
955
966
metadata . md5Hash . should . be . a . String ( ) ;
956
967
// TODO against cloud storage cacheControl comes back null/undefined by default. Emulator has a difference
@@ -1119,6 +1130,7 @@ describe('storage() -> StorageReference', function () {
1119
1130
1120
1131
describe ( 'updateMetadata' , function ( ) {
1121
1132
it ( 'should return the updated metadata for a file' , async function ( ) {
1133
+ const { getApp } = modular ;
1122
1134
const { getStorage, ref, updateMetadata } = storageModular ;
1123
1135
const storageReference = ref ( getStorage ( ) , `${ PATH } /list/file1.txt` ) ;
1124
1136
@@ -1150,7 +1162,7 @@ describe('storage() -> StorageReference', function () {
1150
1162
metadata . timeCreated . should . be . a . String ( ) ;
1151
1163
metadata . metageneration . should . be . a . String ( ) ;
1152
1164
metadata . md5Hash . should . be . a . String ( ) ;
1153
- metadata . bucket . should . equal ( `${ firebase . app ( ) . options . projectId } .appspot.com` ) ;
1165
+ metadata . bucket . should . equal ( `${ getApp ( ) . options . projectId } .appspot.com` ) ;
1154
1166
1155
1167
// Things we just updated
1156
1168
metadata . cacheControl . should . equals ( 'cache-control' ) ;
@@ -1189,7 +1201,7 @@ describe('storage() -> StorageReference', function () {
1189
1201
metadata . timeCreated . should . be . a . String ( ) ;
1190
1202
metadata . metageneration . should . be . a . String ( ) ;
1191
1203
metadata . md5Hash . should . be . a . String ( ) ;
1192
- metadata . bucket . should . equal ( `${ firebase . app ( ) . options . projectId } .appspot.com` ) ;
1204
+ metadata . bucket . should . equal ( `${ getApp ( ) . options . projectId } .appspot.com` ) ;
1193
1205
1194
1206
// Things that we may set (or remove)
1195
1207
should . equal ( metadata . cacheControl , undefined ) ;
0 commit comments