Skip to content

Commit 0a1d781

Browse files
committed
format
1 parent 6d99fb4 commit 0a1d781

File tree

3 files changed

+61
-32
lines changed

3 files changed

+61
-32
lines changed

packages/storage-compat/test/unit/service.test.ts

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,16 @@ import '@firebase/storage-compat/test/setup';
1818
import { expect } from 'chai';
1919
import { stub } from 'sinon';
2020
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';
2331
import firebase from '@firebase/app-compat';
2432

2533
const testCompatApp = firebase.initializeApp({});
@@ -30,7 +38,10 @@ const DEFAULT_HOST = 'firebasestorage.googleapis.com';
3038
describe.only('Firebase Storage > Service', () => {
3139
describe('useEmulator(host, port)', () => {
3240
it('calls connectStorageEmulator() correctly', () => {
33-
const connectStorageEmulatorStub = stub(modularStorage, 'connectStorageEmulator').callsFake(() => { });
41+
const connectStorageEmulatorStub = stub(
42+
modularStorage,
43+
'connectStorageEmulator'
44+
).callsFake(() => {});
3445
const service = makeTestCompatStorage(fakeApp, fakeStorage);
3546
service.useEmulator('test.host.org', 1234);
3647

@@ -43,25 +54,22 @@ describe.only('Firebase Storage > Service', () => {
4354
});
4455

4556
describe('refFromURL', () => {
46-
const service = makeTestCompatStorage(
47-
testCompatApp,
48-
testModularStorage
49-
);
57+
const service = makeTestCompatStorage(testCompatApp, testModularStorage);
5058
it('Works with gs:// URLs', () => {
5159
const ref = service.refFromURL('gs://mybucket/child/path/image.png');
5260
expect(ref.toString()).to.equal('gs://mybucket/child/path/image.png');
5361
});
5462
it('Works with http:// URLs', () => {
5563
const ref = service.refFromURL(
5664
`http://${DEFAULT_HOST}/v0/b/` +
57-
'mybucket/o/child%2Fpath%2Fimage.png?downloadToken=hello'
65+
'mybucket/o/child%2Fpath%2Fimage.png?downloadToken=hello'
5866
);
5967
expect(ref.toString()).to.equal('gs://mybucket/child/path/image.png');
6068
});
6169
it('Works with https:// URLs', () => {
6270
const ref = service.refFromURL(
6371
`https://${DEFAULT_HOST}/v0/b/` +
64-
'mybucket/o/child%2Fpath%2Fimage.png?downloadToken=hello'
72+
'mybucket/o/child%2Fpath%2Fimage.png?downloadToken=hello'
6573
);
6674
expect(ref.toString()).to.equal('gs://mybucket/child/path/image.png');
6775
});
@@ -101,29 +109,34 @@ GOOG4-RSA-SHA256`
101109
});
102110

103111
describe('Argument verification', () => {
104-
const service = makeTestCompatStorage(
105-
testCompatApp,
106-
testModularStorage
107-
);
112+
const service = makeTestCompatStorage(testCompatApp, testModularStorage);
108113

109114
describe('ref', () => {
110115
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+
);
112119
});
113120
});
114121

115122
describe('refFromURL', () => {
116123
it('Throws with a non-URL string arg', () => {
117-
expect(() => { service.refFromURL('child') }).to.throw(/expected a full URL but got a child path.*storage\/invalid-argument/i);
124+
expect(() => {
125+
service.refFromURL('child');
126+
}).to.throw(
127+
/expected a full URL but got a child path.*storage\/invalid-argument/i
128+
);
118129
});
119130
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');
121134
});
122135
});
123136

124137
describe('MaxUploadRetryTime', () => {
125138
const modularStorage = {} as FirebaseStorage;
126-
const service = makeTestCompatStorage(fakeApp, modularStorage)
139+
const service = makeTestCompatStorage(fakeApp, modularStorage);
127140
it('reads from the modular instance', () => {
128141
modularStorage.maxUploadRetryTime = 999;
129142
expect(service.maxUploadRetryTime).to.equal(999);
@@ -135,9 +148,8 @@ GOOG4-RSA-SHA256`
135148
});
136149
});
137150
describe('MaxOperationRetryTime', () => {
138-
139151
const modularStorage = {} as FirebaseStorage;
140-
const service = makeTestCompatStorage(fakeApp, modularStorage)
152+
const service = makeTestCompatStorage(fakeApp, modularStorage);
141153
it('reads from the modular instance', () => {
142154
modularStorage.maxOperationRetryTime = 999;
143155
expect(service.maxOperationRetryTime).to.equal(999);
@@ -151,10 +163,7 @@ GOOG4-RSA-SHA256`
151163
});
152164

153165
describe('Deletion', () => {
154-
const service = makeTestCompatStorage(
155-
testCompatApp,
156-
testModularStorage
157-
);
166+
const service = makeTestCompatStorage(testCompatApp, testModularStorage);
158167

159168
it('In-flight requests are canceled when the service is deleted', async () => {
160169
const ref = service.refFromURL('gs://mybucket/image.jpg');

packages/storage-compat/test/utils.ts

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,34 @@
1+
/**
2+
* @license
3+
* Copyright 2021 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
118
import { FirebaseApp } from '@firebase/app-types';
219
import { FirebaseStorage } from '@firebase/storage';
320
import { StorageServiceCompat } from '../src/service';
421

5-
export function makeTestCompatStorage(app: FirebaseApp, storage: FirebaseStorage): StorageServiceCompat {
6-
const storageServiceCompat: StorageServiceCompat = new StorageServiceCompat(
7-
app,
8-
storage
9-
);
10-
return storageServiceCompat;
22+
export function makeTestCompatStorage(
23+
app: FirebaseApp,
24+
storage: FirebaseStorage
25+
): StorageServiceCompat {
26+
const storageServiceCompat: StorageServiceCompat = new StorageServiceCompat(
27+
app,
28+
storage
29+
);
30+
return storageServiceCompat;
1131
}
1232

1333
export const fakeApp = {} as FirebaseApp;
14-
export const fakeStorage = {} as FirebaseStorage;
34+
export const fakeStorage = {} as FirebaseStorage;

packages/storage/test/unit/service.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,15 +376,15 @@ GOOG4-RSA-SHA256`
376376
describe('setMaxUploadRetryTime', () => {
377377
it('Throws on negative arg', () => {
378378
testShared.assertThrows(
379-
() => service.maxOperationRetryTime = -10,
379+
() => (service.maxOperationRetryTime = -10),
380380
'storage/invalid-argument'
381381
);
382382
});
383383
});
384384
describe('setMaxOperationRetryTime', () => {
385385
it('Throws on negative arg', () => {
386386
testShared.assertThrows(
387-
() => service.maxOperationRetryTime = -10,
387+
() => (service.maxOperationRetryTime = -10),
388388
'storage/invalid-argument'
389389
);
390390
});

0 commit comments

Comments
 (0)