From aa1bb158f8b95e19b84cead6276e601360ec1957 Mon Sep 17 00:00:00 2001 From: Maneesh Tewani Date: Tue, 11 Jul 2023 07:49:32 -0700 Subject: [PATCH] Fixed docgen for `getDownloadURL` (#2241) * Updated the comment * Updated to use full uppercase * Fixed tests * Fixed other tests --- etc/firebase-admin.storage.api.md | 2 +- src/storage/index.ts | 6 +++--- test/integration/storage.spec.ts | 6 +++--- test/unit/storage/index.spec.ts | 10 +++++----- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/etc/firebase-admin.storage.api.md b/etc/firebase-admin.storage.api.md index f4859bc5f1..b3727679ce 100644 --- a/etc/firebase-admin.storage.api.md +++ b/etc/firebase-admin.storage.api.md @@ -11,7 +11,7 @@ import { Bucket } from '@google-cloud/storage'; import { File } from '@google-cloud/storage'; // @public -export function getDownloadUrl(file: File): Promise; +export function getDownloadURL(file: File): Promise; // Warning: (ae-forgotten-export) The symbol "App" needs to be exported by the entry point index.d.ts // diff --git a/src/storage/index.ts b/src/storage/index.ts index b016aec27d..7b963593e8 100644 --- a/src/storage/index.ts +++ b/src/storage/index.ts @@ -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 { +export async function getDownloadURL(file: File): Promise { const endpoint = (process.env.STORAGE_EMULATOR_HOST || 'https://firebasestorage.googleapis.com') + '/v0'; diff --git a/test/integration/storage.spec.ts b/test/integration/storage.spec.ts index 0dd4045468..78d1c731b5 100644 --- a/test/integration/storage.spec.ts +++ b/test/integration/storage.spec.ts @@ -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'; @@ -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: @@ -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/${ diff --git a/test/unit/storage/index.spec.ts b/test/unit/storage/index.spec.ts index 5671e31f4e..7924f8a61c 100644 --- a/test/unit/storage/index.spec.ts +++ b/test/unit/storage/index.spec.ts @@ -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); @@ -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.' ); }); @@ -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 ); }); @@ -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]}` ); }); @@ -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]}`