@@ -18,8 +18,16 @@ import '@firebase/storage-compat/test/setup';
18
18
import { expect } from 'chai' ;
19
19
import { stub } from 'sinon' ;
20
20
import * as modularStorage from '@firebase/storage' ;
21
- import { makeTestCompatStorage , fakeApp , fakeStorage } from '@firebase/storage-compat/test/utils' ;
22
- import { FirebaseStorage , getStorage , FirebaseStorageError } from '@firebase/storage' ;
21
+ import {
22
+ makeTestCompatStorage ,
23
+ fakeApp ,
24
+ fakeStorage
25
+ } from '@firebase/storage-compat/test/utils' ;
26
+ import {
27
+ FirebaseStorage ,
28
+ getStorage ,
29
+ FirebaseStorageError
30
+ } from '@firebase/storage' ;
23
31
import firebase from '@firebase/app-compat' ;
24
32
25
33
const testCompatApp = firebase . initializeApp ( { } ) ;
@@ -30,7 +38,10 @@ const DEFAULT_HOST = 'firebasestorage.googleapis.com';
30
38
describe . only ( 'Firebase Storage > Service' , ( ) => {
31
39
describe ( 'useEmulator(host, port)' , ( ) => {
32
40
it ( 'calls connectStorageEmulator() correctly' , ( ) => {
33
- const connectStorageEmulatorStub = stub ( modularStorage , 'connectStorageEmulator' ) . callsFake ( ( ) => { } ) ;
41
+ const connectStorageEmulatorStub = stub (
42
+ modularStorage ,
43
+ 'connectStorageEmulator'
44
+ ) . callsFake ( ( ) => { } ) ;
34
45
const service = makeTestCompatStorage ( fakeApp , fakeStorage ) ;
35
46
service . useEmulator ( 'test.host.org' , 1234 ) ;
36
47
@@ -43,25 +54,22 @@ describe.only('Firebase Storage > Service', () => {
43
54
} ) ;
44
55
45
56
describe ( 'refFromURL' , ( ) => {
46
- const service = makeTestCompatStorage (
47
- testCompatApp ,
48
- testModularStorage
49
- ) ;
57
+ const service = makeTestCompatStorage ( testCompatApp , testModularStorage ) ;
50
58
it ( 'Works with gs:// URLs' , ( ) => {
51
59
const ref = service . refFromURL ( 'gs://mybucket/child/path/image.png' ) ;
52
60
expect ( ref . toString ( ) ) . to . equal ( 'gs://mybucket/child/path/image.png' ) ;
53
61
} ) ;
54
62
it ( 'Works with http:// URLs' , ( ) => {
55
63
const ref = service . refFromURL (
56
64
`http://${ DEFAULT_HOST } /v0/b/` +
57
- 'mybucket/o/child%2Fpath%2Fimage.png?downloadToken=hello'
65
+ 'mybucket/o/child%2Fpath%2Fimage.png?downloadToken=hello'
58
66
) ;
59
67
expect ( ref . toString ( ) ) . to . equal ( 'gs://mybucket/child/path/image.png' ) ;
60
68
} ) ;
61
69
it ( 'Works with https:// URLs' , ( ) => {
62
70
const ref = service . refFromURL (
63
71
`https://${ DEFAULT_HOST } /v0/b/` +
64
- 'mybucket/o/child%2Fpath%2Fimage.png?downloadToken=hello'
72
+ 'mybucket/o/child%2Fpath%2Fimage.png?downloadToken=hello'
65
73
) ;
66
74
expect ( ref . toString ( ) ) . to . equal ( 'gs://mybucket/child/path/image.png' ) ;
67
75
} ) ;
@@ -101,29 +109,34 @@ GOOG4-RSA-SHA256`
101
109
} ) ;
102
110
103
111
describe ( 'Argument verification' , ( ) => {
104
- const service = makeTestCompatStorage (
105
- testCompatApp ,
106
- testModularStorage
107
- ) ;
112
+ const service = makeTestCompatStorage ( testCompatApp , testModularStorage ) ;
108
113
109
114
describe ( 'ref' , ( ) => {
110
115
it ( 'Throws on gs:// argument' , ( ) => {
111
- expect ( ( ) => service . ref ( 'gs://yo' ) ) . to . throw ( 'storage/invalid-argument' ) ;
116
+ expect ( ( ) => service . ref ( 'gs://yo' ) ) . to . throw (
117
+ 'storage/invalid-argument'
118
+ ) ;
112
119
} ) ;
113
120
} ) ;
114
121
115
122
describe ( 'refFromURL' , ( ) => {
116
123
it ( 'Throws with a non-URL string arg' , ( ) => {
117
- expect ( ( ) => { service . refFromURL ( 'child' ) } ) . to . throw ( / e x p e c t e d a f u l l U R L b u t g o t a c h i l d p a t h .* s t o r a g e \/ i n v a l i d - a r g u m e n t / i) ;
124
+ expect ( ( ) => {
125
+ service . refFromURL ( 'child' ) ;
126
+ } ) . to . throw (
127
+ / e x p e c t e d a f u l l U R L b u t g o t a c h i l d p a t h .* s t o r a g e \/ i n v a l i d - a r g u m e n t / i
128
+ ) ;
118
129
} ) ;
119
130
it ( 'Throws with an invalid URL arg' , ( ) => {
120
- expect ( ( ) => { service . refFromURL ( 'notlegit://url' ) } ) . to . throw ( 'storage/invalid-argument' ) ;
131
+ expect ( ( ) => {
132
+ service . refFromURL ( 'notlegit://url' ) ;
133
+ } ) . to . throw ( 'storage/invalid-argument' ) ;
121
134
} ) ;
122
135
} ) ;
123
136
124
137
describe ( 'MaxUploadRetryTime' , ( ) => {
125
138
const modularStorage = { } as FirebaseStorage ;
126
- const service = makeTestCompatStorage ( fakeApp , modularStorage )
139
+ const service = makeTestCompatStorage ( fakeApp , modularStorage ) ;
127
140
it ( 'reads from the modular instance' , ( ) => {
128
141
modularStorage . maxUploadRetryTime = 999 ;
129
142
expect ( service . maxUploadRetryTime ) . to . equal ( 999 ) ;
@@ -135,9 +148,8 @@ GOOG4-RSA-SHA256`
135
148
} ) ;
136
149
} ) ;
137
150
describe ( 'MaxOperationRetryTime' , ( ) => {
138
-
139
151
const modularStorage = { } as FirebaseStorage ;
140
- const service = makeTestCompatStorage ( fakeApp , modularStorage )
152
+ const service = makeTestCompatStorage ( fakeApp , modularStorage ) ;
141
153
it ( 'reads from the modular instance' , ( ) => {
142
154
modularStorage . maxOperationRetryTime = 999 ;
143
155
expect ( service . maxOperationRetryTime ) . to . equal ( 999 ) ;
@@ -151,10 +163,7 @@ GOOG4-RSA-SHA256`
151
163
} ) ;
152
164
153
165
describe ( 'Deletion' , ( ) => {
154
- const service = makeTestCompatStorage (
155
- testCompatApp ,
156
- testModularStorage
157
- ) ;
166
+ const service = makeTestCompatStorage ( testCompatApp , testModularStorage ) ;
158
167
159
168
it ( 'In-flight requests are canceled when the service is deleted' , async ( ) => {
160
169
const ref = service . refFromURL ( 'gs://mybucket/image.jpg' ) ;
0 commit comments