Skip to content

Commit

Permalink
Fixed docgen for getDownloadURL (#2241)
Browse files Browse the repository at this point in the history
* Updated the comment

* Updated to use full uppercase

* Fixed tests

* Fixed other tests
  • Loading branch information
maneesht authored Jul 11, 2023
1 parent c21de1e commit aa1bb15
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion etc/firebase-admin.storage.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Bucket } from '@google-cloud/storage';
import { File } from '@google-cloud/storage';

// @public
export function getDownloadUrl(file: File): Promise<string>;
export function getDownloadURL(file: File): Promise<string>;

// Warning: (ae-forgotten-export) The symbol "App" needs to be exported by the entry point index.d.ts
//
Expand Down
6 changes: 3 additions & 3 deletions src/storage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,17 @@ export function getStorage(app?: App): Storage {


/**
* Gets the download URL for the given {@link @google-cloud/storage#File}.
* Gets the download URL for the given {@link https://cloud.google.com/nodejs/docs/reference/storage/latest/storage/file | File}.
*
* @example
* ```javascript
* // Get the downloadUrl for a given file ref
* const storage = getStorage();
* const myRef = ref(storage, 'images/mountains.jpg');
* const downloadUrl = await getDownloadUrl(myRef);
* const downloadUrl = await getDownloadURL(myRef);
* ```
*/
export async function getDownloadUrl(file: File): Promise<string> {
export async function getDownloadURL(file: File): Promise<string> {
const endpoint =
(process.env.STORAGE_EMULATOR_HOST ||
'https://firebasestorage.googleapis.com') + '/v0';
Expand Down
6 changes: 3 additions & 3 deletions test/integration/storage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import * as chaiAsPromised from 'chai-as-promised';
import { Bucket, File } from '@google-cloud/storage';

import { projectId } from './setup';
import { getDownloadUrl, getStorage } from '../../lib/storage/index';
import { getDownloadURL, getStorage } from '../../lib/storage/index';
import { getFirebaseMetadata } from '../../src/storage/utils';
import { FirebaseError } from '../../src/utils/error';

Expand Down Expand Up @@ -57,7 +57,7 @@ describe('admin.storage', () => {
currentRef
);
if (!metadata.downloadTokens) {
expect(getDownloadUrl(currentRef)).to.eventually.throw(
expect(getDownloadURL(currentRef)).to.eventually.throw(
new FirebaseError({
code: 'storage/invalid-argument',
message:
Expand All @@ -68,7 +68,7 @@ describe('admin.storage', () => {
);
return;
}
const downloadUrl = await getDownloadUrl(currentRef);
const downloadUrl = await getDownloadURL(currentRef);

const [token] = metadata.downloadTokens.split(',');
const storageEndpoint = `https://firebasestorage.googleapis.com/v0/b/${
Expand Down
10 changes: 5 additions & 5 deletions test/unit/storage/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import * as chaiAsPromised from 'chai-as-promised';
import * as mocks from '../../resources/mocks';
import { App } from '../../../src/app/index';
import * as StorageUtils from '../../../src/storage/utils';
import { getStorage, Storage, getDownloadUrl } from '../../../src/storage/index';
import { getStorage, Storage, getDownloadURL } from '../../../src/storage/index';

chai.should();
chai.use(sinonChai);
Expand Down Expand Up @@ -84,7 +84,7 @@ describe('Storage', () => {
.returns(Promise.resolve({} as StorageUtils.FirebaseMetadata));
const storage1 = getStorage(mockApp);
const fileRef = storage1.bucket('gs://mock').file('abc');
await expect(getDownloadUrl(fileRef)).to.be.rejectedWith(
await expect(getDownloadURL(fileRef)).to.be.rejectedWith(
'No download token available. Please create one in the Firebase Console.'
);
});
Expand All @@ -96,7 +96,7 @@ describe('Storage', () => {
.returns(Promise.reject(error));
const storage1 = getStorage(mockApp);
const fileRef = storage1.bucket('gs://mock').file('abc');
await expect(getDownloadUrl(fileRef)).to.be.rejectedWith(
await expect(getDownloadURL(fileRef)).to.be.rejectedWith(
error
);
});
Expand All @@ -111,7 +111,7 @@ describe('Storage', () => {
);
const storage1 = getStorage(mockApp);
const fileRef = storage1.bucket('gs://mock').file('abc');
await expect(getDownloadUrl(fileRef)).to.eventually.eq(
await expect(getDownloadURL(fileRef)).to.eventually.eq(
`https://firebasestorage.googleapis.com/v0/b/${fileRef.bucket.name}/o/${encodeURIComponent(fileRef.name)}?alt=media&token=${downloadTokens[0]}`
);
});
Expand All @@ -136,7 +136,7 @@ describe('Storage', () => {
// Need to create a new mock app to force `getStorage`'s checking of env vars.
const storage1 = getStorage(mocks.app(envName));
const fileRef = storage1.bucket('gs://mock').file('abc');
await expect(getDownloadUrl(fileRef)).to.eventually.eq(
await expect(getDownloadURL(fileRef)).to.eventually.eq(
`http://${HOST}/v0/b/${fileRef.bucket.name}/o/${encodeURIComponent(
fileRef.name
)}?alt=media&token=${downloadTokens[0]}`
Expand Down

0 comments on commit aa1bb15

Please # to comment.