From 9c066799daa35838e41f4196746256eac569d355 Mon Sep 17 00:00:00 2001 From: MathBunny Date: Thu, 9 Jul 2020 15:48:03 -0400 Subject: [PATCH 1/2] Add ESLint rule for curly braces, apply fix --- .eslintrc.js | 1 + package.json | 4 +- src/auth/action-code-settings-builder.ts | 2 +- src/auth/auth-api-request.ts | 40 +-- src/auth/auth-config.ts | 6 +- src/auth/auth.ts | 14 +- src/auth/credential.ts | 6 +- src/auth/tenant-manager.ts | 8 +- src/auth/tenant.ts | 2 +- src/auth/token-generator.ts | 6 +- src/auth/token-verifier.ts | 2 +- src/auth/user-import-builder.ts | 6 +- src/auth/user-record.ts | 6 +- src/database/database.ts | 12 +- src/default-namespace.ts | 2 +- src/firebase-app.ts | 38 +- src/firebase-namespace.ts | 40 +-- src/firebase-service.ts | 2 +- src/firestore/firestore.ts | 12 +- src/instance-id/instance-id-request.ts | 4 +- src/instance-id/instance-id.ts | 8 +- src/machine-learning/machine-learning.ts | 16 +- src/messaging/messaging-api-request.ts | 2 +- src/messaging/messaging-errors.ts | 4 +- src/messaging/messaging-types.ts | 2 +- src/messaging/messaging.ts | 14 +- .../security-rules-api-client.ts | 2 +- src/storage/storage.ts | 10 +- src/utils/api-request.ts | 10 +- src/utils/error.ts | 8 +- src/utils/index.ts | 4 +- test/integration/app.spec.ts | 2 +- test/integration/auth.spec.ts | 72 ++-- test/integration/database.spec.ts | 2 +- test/integration/firestore.spec.ts | 6 +- test/integration/machine-learning.spec.ts | 40 +-- test/integration/messaging.spec.ts | 2 +- test/integration/setup.ts | 2 +- test/integration/storage.spec.ts | 4 +- .../typescript/src/example.test.ts | 6 +- test/resources/mocks.ts | 8 +- .../auth/action-code-settings-builder.spec.ts | 8 +- test/unit/auth/auth-api-request.spec.ts | 332 +++++++++--------- test/unit/auth/auth-config.spec.ts | 14 +- test/unit/auth/auth.spec.ts | 68 ++-- test/unit/auth/credential.spec.ts | 8 +- test/unit/auth/tenant-manager.spec.ts | 22 +- test/unit/auth/tenant.spec.ts | 4 +- test/unit/auth/token-generator.spec.ts | 14 +- test/unit/auth/token-verifier.spec.ts | 6 +- test/unit/auth/user-import-builder.spec.ts | 72 ++-- test/unit/auth/user-record.spec.ts | 14 +- test/unit/database/database.spec.ts | 16 +- test/unit/firebase-app.spec.ts | 28 +- test/unit/firebase-namespace.spec.ts | 16 +- test/unit/firebase.spec.ts | 2 +- test/unit/firestore/firestore.spec.ts | 6 +- .../instance-id/instance-id-request.spec.ts | 8 +- test/unit/instance-id/instance-id.spec.ts | 8 +- .../machine-learning-api-client.spec.ts | 24 +- .../machine-learning/machine-learning.spec.ts | 6 +- test/unit/messaging/batch-requests.spec.ts | 40 +-- test/unit/messaging/messaging.spec.ts | 166 ++++----- .../security-rules/security-rules.spec.ts | 6 +- test/unit/storage/storage.spec.ts | 8 +- test/unit/utils.ts | 4 +- test/unit/utils/api-request.spec.ts | 114 +++--- test/unit/utils/error.spec.ts | 4 +- test/unit/utils/index.spec.ts | 6 +- test/unit/utils/validator.spec.ts | 4 +- 70 files changed, 733 insertions(+), 732 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index c3d03a4f68..353fcd665a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -36,6 +36,7 @@ module.exports = { // Required checks 'indent': ['error', 2], + "object-curly-spacing": [2, "always"], '@typescript-eslint/explicit-function-return-type': [ 'error', { diff --git a/package.json b/package.json index 4d6791b7a1..453ae3933e 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,8 @@ "test:unit": "mocha test/unit/*.spec.ts --require ts-node/register", "test:integration": "mocha test/integration/*.ts --slow 5000 --timeout 20000 --require ts-node/register", "test:coverage": "nyc npm run test:unit", - "lint:src": "eslint src/ --ext .ts", - "lint:test": "eslint test/ --ext .ts", + "lint:src": "eslint src/ --ext .ts --fix", + "lint:test": "eslint test/ --ext .ts --fix", "apidocs": "node docgen/generate-docs.js --api node" }, "nyc": { diff --git a/src/auth/action-code-settings-builder.ts b/src/auth/action-code-settings-builder.ts index 159e78af48..f2fc01d605 100644 --- a/src/auth/action-code-settings-builder.ts +++ b/src/auth/action-code-settings-builder.ts @@ -15,7 +15,7 @@ */ import * as validator from '../utils/validator'; -import {AuthClientErrorCode, FirebaseAuthError} from '../utils/error'; +import { AuthClientErrorCode, FirebaseAuthError } from '../utils/error'; /** Defines the ActionCodeSettings interface. */ export interface ActionCodeSettings { diff --git a/src/auth/auth-api-request.ts b/src/auth/auth-api-request.ts index faa56a917b..359bc90c4d 100755 --- a/src/auth/auth-api-request.ts +++ b/src/auth/auth-api-request.ts @@ -16,30 +16,30 @@ import * as validator from '../utils/validator'; -import {deepCopy, deepExtend} from '../utils/deep-copy'; +import { deepCopy, deepExtend } from '../utils/deep-copy'; import { UserIdentifier, isUidIdentifier, isEmailIdentifier, isPhoneIdentifier, isProviderIdentifier, UidIdentifier, EmailIdentifier, PhoneIdentifier, ProviderIdentifier, } from './identifier'; -import {FirebaseApp} from '../firebase-app'; -import {AuthClientErrorCode, FirebaseAuthError} from '../utils/error'; +import { FirebaseApp } from '../firebase-app'; +import { AuthClientErrorCode, FirebaseAuthError } from '../utils/error'; import { ApiSettings, AuthorizedHttpClient, HttpRequestConfig, HttpError, } from '../utils/api-request'; -import {CreateRequest, UpdateRequest} from './user-record'; +import { CreateRequest, UpdateRequest } from './user-record'; import { UserImportBuilder, UserImportOptions, UserImportRecord, UserImportResult, AuthFactorInfo, convertMultiFactorInfoToServerFormat, } from './user-import-builder'; import * as utils from '../utils/index'; -import {ActionCodeSettings, ActionCodeSettingsBuilder} from './action-code-settings-builder'; +import { ActionCodeSettings, ActionCodeSettingsBuilder } from './action-code-settings-builder'; import { SAMLConfig, OIDCConfig, OIDCConfigServerResponse, SAMLConfigServerResponse, OIDCConfigServerRequest, SAMLConfigServerRequest, AuthProviderConfig, OIDCUpdateAuthProviderRequest, SAMLUpdateAuthProviderRequest, } from './auth-config'; -import {Tenant, TenantOptions, TenantServerResponse} from './tenant'; +import { Tenant, TenantOptions, TenantServerResponse } from './tenant'; /** Firebase Auth request header. */ @@ -195,7 +195,7 @@ class TenantAwareAuthResourceUrlBuilder extends AuthResourceUrlBuilder { public getUrl(api?: string, params?: object): Promise { return super.getUrl(api, params) .then((url) => { - return utils.formatString(url, {tenantId: this.tenantId}); + return utils.formatString(url, { tenantId: this.tenantId }); }); } } @@ -1039,7 +1039,7 @@ export abstract class AbstractAuthRequestHandler { */ public getAccountInfoByIdentifiers(identifiers: UserIdentifier[]): Promise { if (identifiers.length === 0) { - return Promise.resolve({users: []}); + return Promise.resolve({ users: [] }); } else if (identifiers.length > MAX_GET_ACCOUNTS_BATCH_SIZE) { throw new FirebaseAuthError( AuthClientErrorCode.MAXIMUM_USER_COUNT_EXCEEDED, @@ -1428,7 +1428,7 @@ export abstract class AbstractAuthRequestHandler { public getEmailActionLink( requestType: string, email: string, actionCodeSettings?: ActionCodeSettings): Promise { - let request = {requestType, email, returnOobLink: true}; + let request = { requestType, email, returnOobLink: true }; // ActionCodeSettings required for email link sign-in to determine the url where the sign-in will // be completed. if (typeof actionCodeSettings === 'undefined' && requestType === 'EMAIL_SIGNIN') { @@ -1464,7 +1464,7 @@ export abstract class AbstractAuthRequestHandler { if (!OIDCConfig.isProviderId(providerId)) { return Promise.reject(new FirebaseAuthError(AuthClientErrorCode.INVALID_PROVIDER_ID)); } - return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), GET_OAUTH_IDP_CONFIG, {}, {providerId}); + return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), GET_OAUTH_IDP_CONFIG, {}, { providerId }); } /** @@ -1510,7 +1510,7 @@ export abstract class AbstractAuthRequestHandler { if (!OIDCConfig.isProviderId(providerId)) { return Promise.reject(new FirebaseAuthError(AuthClientErrorCode.INVALID_PROVIDER_ID)); } - return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), DELETE_OAUTH_IDP_CONFIG, {}, {providerId}) + return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), DELETE_OAUTH_IDP_CONFIG, {}, { providerId }) .then(() => { // Return nothing. }); @@ -1532,7 +1532,7 @@ export abstract class AbstractAuthRequestHandler { return Promise.reject(e); } const providerId = options.providerId; - return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), CREATE_OAUTH_IDP_CONFIG, request, {providerId}) + return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), CREATE_OAUTH_IDP_CONFIG, request, { providerId }) .then((response: any) => { if (!OIDCConfig.getProviderIdFromResourceName(response.name)) { throw new FirebaseAuthError( @@ -1565,7 +1565,7 @@ export abstract class AbstractAuthRequestHandler { } const updateMask = utils.generateUpdateMask(request); return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), UPDATE_OAUTH_IDP_CONFIG, request, - {providerId, updateMask: updateMask.join(',')}) + { providerId, updateMask: updateMask.join(',') }) .then((response: any) => { if (!OIDCConfig.getProviderIdFromResourceName(response.name)) { throw new FirebaseAuthError( @@ -1586,7 +1586,7 @@ export abstract class AbstractAuthRequestHandler { if (!SAMLConfig.isProviderId(providerId)) { return Promise.reject(new FirebaseAuthError(AuthClientErrorCode.INVALID_PROVIDER_ID)); } - return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), GET_INBOUND_SAML_CONFIG, {}, {providerId}); + return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), GET_INBOUND_SAML_CONFIG, {}, { providerId }); } /** @@ -1632,7 +1632,7 @@ export abstract class AbstractAuthRequestHandler { if (!SAMLConfig.isProviderId(providerId)) { return Promise.reject(new FirebaseAuthError(AuthClientErrorCode.INVALID_PROVIDER_ID)); } - return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), DELETE_INBOUND_SAML_CONFIG, {}, {providerId}) + return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), DELETE_INBOUND_SAML_CONFIG, {}, { providerId }) .then(() => { // Return nothing. }); @@ -1655,7 +1655,7 @@ export abstract class AbstractAuthRequestHandler { } const providerId = options.providerId; return this.invokeRequestHandler( - this.getProjectConfigUrlBuilder(), CREATE_INBOUND_SAML_CONFIG, request, {providerId}) + this.getProjectConfigUrlBuilder(), CREATE_INBOUND_SAML_CONFIG, request, { providerId }) .then((response: any) => { if (!SAMLConfig.getProviderIdFromResourceName(response.name)) { throw new FirebaseAuthError( @@ -1688,7 +1688,7 @@ export abstract class AbstractAuthRequestHandler { } const updateMask = utils.generateUpdateMask(request); return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), UPDATE_INBOUND_SAML_CONFIG, request, - {providerId, updateMask: updateMask.join(',')}) + { providerId, updateMask: updateMask.join(',') }) .then((response: any) => { if (!SAMLConfig.getProviderIdFromResourceName(response.name)) { throw new FirebaseAuthError( @@ -1893,7 +1893,7 @@ export class AuthRequestHandler extends AbstractAuthRequestHandler { if (!validator.isNonEmptyString(tenantId)) { return Promise.reject(new FirebaseAuthError(AuthClientErrorCode.INVALID_TENANT_ID)); } - return this.invokeRequestHandler(this.tenantMgmtResourceBuilder, GET_TENANT, {}, {tenantId}) + return this.invokeRequestHandler(this.tenantMgmtResourceBuilder, GET_TENANT, {}, { tenantId }) .then((response: any) => { return response as TenantServerResponse; }); @@ -1943,7 +1943,7 @@ export class AuthRequestHandler extends AbstractAuthRequestHandler { if (!validator.isNonEmptyString(tenantId)) { return Promise.reject(new FirebaseAuthError(AuthClientErrorCode.INVALID_TENANT_ID)); } - return this.invokeRequestHandler(this.tenantMgmtResourceBuilder, DELETE_TENANT, {}, {tenantId}) + return this.invokeRequestHandler(this.tenantMgmtResourceBuilder, DELETE_TENANT, {}, { tenantId }) .then(() => { // Return nothing. }); @@ -1984,7 +1984,7 @@ export class AuthRequestHandler extends AbstractAuthRequestHandler { const request = Tenant.buildServerRequest(tenantOptions, false); const updateMask = utils.generateUpdateMask(request); return this.invokeRequestHandler(this.tenantMgmtResourceBuilder, UPDATE_TENANT, request, - {tenantId, updateMask: updateMask.join(',')}) + { tenantId, updateMask: updateMask.join(',') }) .then((response: any) => { return response as TenantServerResponse; }); diff --git a/src/auth/auth-config.ts b/src/auth/auth-config.ts index 95527eb1a7..97fddbdaca 100755 --- a/src/auth/auth-config.ts +++ b/src/auth/auth-config.ts @@ -15,8 +15,8 @@ */ import * as validator from '../utils/validator'; -import {deepCopy} from '../utils/deep-copy'; -import {AuthClientErrorCode, FirebaseAuthError} from '../utils/error'; +import { deepCopy } from '../utils/deep-copy'; +import { AuthClientErrorCode, FirebaseAuthError } from '../utils/error'; /** The filter interface used for listing provider configurations. */ @@ -306,7 +306,7 @@ export class SAMLConfig implements SAMLAuthProviderConfig { }; if (options.x509Certificates) { for (const cert of (options.x509Certificates || [])) { - request.idpConfig!.idpCertificates!.push({x509Certificate: cert}); + request.idpConfig!.idpCertificates!.push({ x509Certificate: cert }); } } } diff --git a/src/auth/auth.ts b/src/auth/auth.ts index cf83e7b430..88e6f881a8 100755 --- a/src/auth/auth.ts +++ b/src/auth/auth.ts @@ -14,17 +14,17 @@ * limitations under the License. */ -import {UserRecord, CreateRequest, UpdateRequest} from './user-record'; +import { UserRecord, CreateRequest, UpdateRequest } from './user-record'; import { UserIdentifier, isUidIdentifier, isEmailIdentifier, isPhoneIdentifier, isProviderIdentifier, } from './identifier'; -import {FirebaseApp} from '../firebase-app'; -import {FirebaseTokenGenerator, cryptoSignerFromApp} from './token-generator'; +import { FirebaseApp } from '../firebase-app'; +import { FirebaseTokenGenerator, cryptoSignerFromApp } from './token-generator'; import { AbstractAuthRequestHandler, AuthRequestHandler, TenantAwareAuthRequestHandler, } from './auth-api-request'; -import {AuthClientErrorCode, FirebaseAuthError, ErrorInfo, FirebaseArrayIndexError} from '../utils/error'; -import {FirebaseServiceInterface, FirebaseServiceInternalsInterface} from '../firebase-service'; +import { AuthClientErrorCode, FirebaseAuthError, ErrorInfo, FirebaseArrayIndexError } from '../utils/error'; +import { FirebaseServiceInterface, FirebaseServiceInternalsInterface } from '../firebase-service'; import { UserImportOptions, UserImportRecord, UserImportResult, } from './user-import-builder'; @@ -32,12 +32,12 @@ import { import * as utils from '../utils/index'; import * as validator from '../utils/validator'; import { FirebaseTokenVerifier, createSessionCookieVerifier, createIdTokenVerifier } from './token-verifier'; -import {ActionCodeSettings} from './action-code-settings-builder'; +import { ActionCodeSettings } from './action-code-settings-builder'; import { AuthProviderConfig, AuthProviderConfigFilter, ListProviderConfigResults, UpdateAuthProviderRequest, SAMLConfig, OIDCConfig, OIDCConfigServerResponse, SAMLConfigServerResponse, } from './auth-config'; -import {TenantManager} from './tenant-manager'; +import { TenantManager } from './tenant-manager'; /** diff --git a/src/auth/credential.ts b/src/auth/credential.ts index 43de4d3ed3..9770185ac6 100644 --- a/src/auth/credential.ts +++ b/src/auth/credential.ts @@ -19,9 +19,9 @@ import fs = require('fs'); import os = require('os'); import path = require('path'); -import {AppErrorCodes, FirebaseAppError} from '../utils/error'; -import {HttpClient, HttpRequestConfig, HttpError, HttpResponse} from '../utils/api-request'; -import {Agent} from 'http'; +import { AppErrorCodes, FirebaseAppError } from '../utils/error'; +import { HttpClient, HttpRequestConfig, HttpError, HttpResponse } from '../utils/api-request'; +import { Agent } from 'http'; import * as util from '../utils/validator'; const GOOGLE_TOKEN_AUDIENCE = 'https://accounts.google.com/o/oauth2/token'; diff --git a/src/auth/tenant-manager.ts b/src/auth/tenant-manager.ts index 73950a76bd..4f0b1c39cb 100644 --- a/src/auth/tenant-manager.ts +++ b/src/auth/tenant-manager.ts @@ -14,13 +14,13 @@ * limitations under the License. */ -import {AuthRequestHandler} from './auth-api-request'; -import {FirebaseApp} from '../firebase-app'; -import {TenantAwareAuth} from './auth'; +import { AuthRequestHandler } from './auth-api-request'; +import { FirebaseApp } from '../firebase-app'; +import { TenantAwareAuth } from './auth'; import { Tenant, TenantServerResponse, ListTenantsResult, TenantOptions, } from './tenant'; -import {AuthClientErrorCode, FirebaseAuthError} from '../utils/error'; +import { AuthClientErrorCode, FirebaseAuthError } from '../utils/error'; import * as validator from '../utils/validator'; /** diff --git a/src/auth/tenant.ts b/src/auth/tenant.ts index 0b2ed1dca9..2d449035fe 100755 --- a/src/auth/tenant.ts +++ b/src/auth/tenant.ts @@ -15,7 +15,7 @@ */ import * as validator from '../utils/validator'; -import {AuthClientErrorCode, FirebaseAuthError} from '../utils/error'; +import { AuthClientErrorCode, FirebaseAuthError } from '../utils/error'; import { EmailSignInConfig, EmailSignInConfigServerRequest, EmailSignInProviderConfig, } from './auth-config'; diff --git a/src/auth/token-generator.ts b/src/auth/token-generator.ts index 1cdebd49bd..929986b92e 100644 --- a/src/auth/token-generator.ts +++ b/src/auth/token-generator.ts @@ -15,8 +15,8 @@ */ import { FirebaseApp } from '../firebase-app'; -import {ServiceAccountCredential} from './credential'; -import {AuthClientErrorCode, FirebaseAuthError } from '../utils/error'; +import { ServiceAccountCredential } from './credential'; +import { AuthClientErrorCode, FirebaseAuthError } from '../utils/error'; import { AuthorizedHttpClient, HttpError, HttpRequestConfig, HttpClient } from '../utils/api-request'; import * as validator from '../utils/validator'; @@ -152,7 +152,7 @@ export class IAMSigner implements CryptoSigner { const request: HttpRequestConfig = { method: 'POST', url: `https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/${serviceAccount}:signBlob`, - data: {payload: buffer.toString('base64')}, + data: { payload: buffer.toString('base64') }, }; return this.httpClient.send(request); }).then((response: any) => { diff --git a/src/auth/token-verifier.ts b/src/auth/token-verifier.ts index cc0c4f4c02..1f8e3e825a 100644 --- a/src/auth/token-verifier.ts +++ b/src/auth/token-verifier.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import {AuthClientErrorCode, FirebaseAuthError, ErrorInfo} from '../utils/error'; +import { AuthClientErrorCode, FirebaseAuthError, ErrorInfo } from '../utils/error'; import * as util from '../utils/index'; import * as validator from '../utils/validator'; diff --git a/src/auth/user-import-builder.ts b/src/auth/user-import-builder.ts index 852f7740ce..1f1b784a03 100755 --- a/src/auth/user-import-builder.ts +++ b/src/auth/user-import-builder.ts @@ -14,10 +14,10 @@ * limitations under the License. */ -import {deepCopy, deepExtend} from '../utils/deep-copy'; +import { deepCopy, deepExtend } from '../utils/deep-copy'; import * as utils from '../utils'; import * as validator from '../utils/validator'; -import {AuthClientErrorCode, FirebaseAuthError, FirebaseArrayIndexError} from '../utils/error'; +import { AuthClientErrorCode, FirebaseAuthError, FirebaseArrayIndexError } from '../utils/error'; /** Firebase Auth supported hashing algorithms for import operations. */ export type HashAlgorithmType = 'SCRYPT' | 'STANDARD_SCRYPT' | 'HMAC_SHA512' | @@ -333,7 +333,7 @@ export class UserImportBuilder { const users = this.validatedUsers.map((user) => { return deepCopy(user); }); - return deepExtend({users}, deepCopy(this.validatedOptions)) as UploadAccountRequest; + return deepExtend({ users }, deepCopy(this.validatedOptions)) as UploadAccountRequest; } /** diff --git a/src/auth/user-record.ts b/src/auth/user-record.ts index 7d0ebef81b..156f82b610 100644 --- a/src/auth/user-record.ts +++ b/src/auth/user-record.ts @@ -14,10 +14,10 @@ * limitations under the License. */ -import {deepCopy} from '../utils/deep-copy'; -import {isNonNullObject} from '../utils/validator'; +import { deepCopy } from '../utils/deep-copy'; +import { isNonNullObject } from '../utils/validator'; import * as utils from '../utils'; -import {AuthClientErrorCode, FirebaseAuthError} from '../utils/error'; +import { AuthClientErrorCode, FirebaseAuthError } from '../utils/error'; /** * 'REDACTED', encoded as a base64 string. diff --git a/src/database/database.ts b/src/database/database.ts index 3da2a356ba..cb013e6469 100644 --- a/src/database/database.ts +++ b/src/database/database.ts @@ -1,10 +1,10 @@ -import {URL} from 'url'; +import { URL } from 'url'; import * as path from 'path'; -import {FirebaseApp} from '../firebase-app'; -import {FirebaseDatabaseError, AppErrorCodes, FirebaseAppError} from '../utils/error'; -import {FirebaseServiceInterface, FirebaseServiceInternalsInterface} from '../firebase-service'; -import {Database} from '@firebase/database'; +import { FirebaseApp } from '../firebase-app'; +import { FirebaseDatabaseError, AppErrorCodes, FirebaseAppError } from '../utils/error'; +import { FirebaseServiceInterface, FirebaseServiceInternalsInterface } from '../firebase-service'; +import { Database } from '@firebase/database'; import * as validator from '../utils/validator'; import { AuthorizedHttpClient, HttpRequestConfig, HttpError } from '../utils/api-request'; @@ -160,7 +160,7 @@ class DatabaseRulesClient { const req: HttpRequestConfig = { method: 'GET', url: this.dbUrl, - data: {format: 'strict'}, + data: { format: 'strict' }, }; return this.httpClient.send(req) .then((resp) => { diff --git a/src/default-namespace.ts b/src/default-namespace.ts index e82e6b6b7a..a90d81089b 100644 --- a/src/default-namespace.ts +++ b/src/default-namespace.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import {FirebaseNamespace} from './firebase-namespace'; +import { FirebaseNamespace } from './firebase-namespace'; const firebaseAdmin = new FirebaseNamespace(); diff --git a/src/firebase-app.ts b/src/firebase-app.ts index d9fce0055b..4baf2de08d 100644 --- a/src/firebase-app.ts +++ b/src/firebase-app.ts @@ -14,28 +14,28 @@ * limitations under the License. */ -import {Credential, GoogleOAuthAccessToken, getApplicationDefault} from './auth/credential'; +import { Credential, GoogleOAuthAccessToken, getApplicationDefault } from './auth/credential'; import * as validator from './utils/validator'; -import {deepCopy, deepExtend} from './utils/deep-copy'; -import {FirebaseServiceInterface} from './firebase-service'; -import {FirebaseNamespaceInternals} from './firebase-namespace'; -import {AppErrorCodes, FirebaseAppError} from './utils/error'; - -import {Auth} from './auth/auth'; -import {MachineLearning} from './machine-learning/machine-learning'; -import {Messaging} from './messaging/messaging'; -import {Storage} from './storage/storage'; -import {Database} from '@firebase/database'; -import {DatabaseService} from './database/database'; -import {Firestore} from '@google-cloud/firestore'; -import {FirestoreService} from './firestore/firestore'; -import {InstanceId} from './instance-id/instance-id'; - -import {ProjectManagement} from './project-management/project-management'; -import {SecurityRules} from './security-rules/security-rules'; +import { deepCopy, deepExtend } from './utils/deep-copy'; +import { FirebaseServiceInterface } from './firebase-service'; +import { FirebaseNamespaceInternals } from './firebase-namespace'; +import { AppErrorCodes, FirebaseAppError } from './utils/error'; + +import { Auth } from './auth/auth'; +import { MachineLearning } from './machine-learning/machine-learning'; +import { Messaging } from './messaging/messaging'; +import { Storage } from './storage/storage'; +import { Database } from '@firebase/database'; +import { DatabaseService } from './database/database'; +import { Firestore } from '@google-cloud/firestore'; +import { FirestoreService } from './firestore/firestore'; +import { InstanceId } from './instance-id/instance-id'; + +import { ProjectManagement } from './project-management/project-management'; +import { SecurityRules } from './security-rules/security-rules'; import { RemoteConfig } from './remote-config/remote-config'; -import {Agent} from 'http'; +import { Agent } from 'http'; /** * Type representing a callback which is called every time an app lifecycle event occurs. diff --git a/src/firebase-namespace.ts b/src/firebase-namespace.ts index 2247387d18..a9caf80802 100644 --- a/src/firebase-namespace.ts +++ b/src/firebase-namespace.ts @@ -15,11 +15,11 @@ */ import fs = require('fs'); -import {Agent} from 'http'; -import {deepExtend} from './utils/deep-copy'; -import {AppErrorCodes, FirebaseAppError} from './utils/error'; -import {AppHook, FirebaseApp, FirebaseAppOptions} from './firebase-app'; -import {FirebaseServiceFactory, FirebaseServiceInterface} from './firebase-service'; +import { Agent } from 'http'; +import { deepExtend } from './utils/deep-copy'; +import { AppErrorCodes, FirebaseAppError } from './utils/error'; +import { AppHook, FirebaseApp, FirebaseAppOptions } from './firebase-app'; +import { FirebaseServiceFactory, FirebaseServiceInterface } from './firebase-service'; import { Credential, RefreshTokenCredential, @@ -27,14 +27,14 @@ import { getApplicationDefault, } from './auth/credential'; -import {Auth} from './auth/auth'; -import {MachineLearning} from './machine-learning/machine-learning'; -import {Messaging} from './messaging/messaging'; -import {Storage} from './storage/storage'; -import {Database} from '@firebase/database'; -import {Firestore} from '@google-cloud/firestore'; -import {InstanceId} from './instance-id/instance-id'; -import {ProjectManagement} from './project-management/project-management'; +import { Auth } from './auth/auth'; +import { MachineLearning } from './machine-learning/machine-learning'; +import { Messaging } from './messaging/messaging'; +import { Storage } from './storage/storage'; +import { Database } from '@firebase/database'; +import { Firestore } from '@google-cloud/firestore'; +import { InstanceId } from './instance-id/instance-id'; +import { ProjectManagement } from './project-management/project-management'; import { SecurityRules } from './security-rules/security-rules'; import { RemoteConfig } from './remote-config/remote-config'; @@ -331,7 +331,7 @@ export class FirebaseNamespace { return this.ensureApp(app).auth(); }; const auth = require('./auth/auth').Auth; - return Object.assign(fn, {Auth: auth}); + return Object.assign(fn, { Auth: auth }); } /** @@ -356,7 +356,7 @@ export class FirebaseNamespace { return this.ensureApp(app).messaging(); }; const messaging = require('./messaging/messaging').Messaging; - return Object.assign(fn, {Messaging: messaging}); + return Object.assign(fn, { Messaging: messaging }); } /** @@ -368,7 +368,7 @@ export class FirebaseNamespace { return this.ensureApp(app).storage(); }; const storage = require('./storage/storage').Storage; - return Object.assign(fn, {Storage: storage}); + return Object.assign(fn, { Storage: storage }); } /** @@ -413,7 +413,7 @@ export class FirebaseNamespace { }; const machineLearning = require('./machine-learning/machine-learning').MachineLearning; - return Object.assign(fn, {MachineLearning: machineLearning}); + return Object.assign(fn, { MachineLearning: machineLearning }); } /** @@ -425,7 +425,7 @@ export class FirebaseNamespace { return this.ensureApp(app).instanceId(); }; const instanceId = require('./instance-id/instance-id').InstanceId; - return Object.assign(fn, {InstanceId: instanceId}); + return Object.assign(fn, { InstanceId: instanceId }); } /** @@ -437,7 +437,7 @@ export class FirebaseNamespace { return this.ensureApp(app).projectManagement(); }; const projectManagement = require('./project-management/project-management').ProjectManagement; - return Object.assign(fn, {ProjectManagement: projectManagement}); + return Object.assign(fn, { ProjectManagement: projectManagement }); } /** @@ -449,7 +449,7 @@ export class FirebaseNamespace { return this.ensureApp(app).securityRules(); }; const securityRules = require('./security-rules/security-rules').SecurityRules; - return Object.assign(fn, {SecurityRules: securityRules}); + return Object.assign(fn, { SecurityRules: securityRules }); } /** diff --git a/src/firebase-service.ts b/src/firebase-service.ts index 8d8fd64387..15e3168ee3 100644 --- a/src/firebase-service.ts +++ b/src/firebase-service.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import {FirebaseApp} from './firebase-app'; +import { FirebaseApp } from './firebase-app'; /** diff --git a/src/firestore/firestore.ts b/src/firestore/firestore.ts index 89e7fe2771..28bf7e0272 100644 --- a/src/firestore/firestore.ts +++ b/src/firestore/firestore.ts @@ -14,11 +14,11 @@ * limitations under the License. */ -import {FirebaseApp} from '../firebase-app'; -import {FirebaseFirestoreError} from '../utils/error'; -import {FirebaseServiceInterface, FirebaseServiceInternalsInterface} from '../firebase-service'; -import {ServiceAccountCredential, isApplicationDefault} from '../auth/credential'; -import {Firestore, Settings} from '@google-cloud/firestore'; +import { FirebaseApp } from '../firebase-app'; +import { FirebaseFirestoreError } from '../utils/error'; +import { FirebaseServiceInterface, FirebaseServiceInternalsInterface } from '../firebase-service'; +import { ServiceAccountCredential, isApplicationDefault } from '../auth/credential'; +import { Firestore, Settings } from '@google-cloud/firestore'; import * as validator from '../utils/validator'; import * as utils from '../utils/index'; @@ -90,7 +90,7 @@ export function getFirestoreOptions(app: FirebaseApp): Settings { // Try to use the Google application default credentials. // If an explicit project ID is not available, let Firestore client discover one from the // environment. This prevents the users from having to set GOOGLE_CLOUD_PROJECT in GCP runtimes. - return validator.isNonEmptyString(projectId) ? {projectId, firebaseVersion} : {firebaseVersion}; + return validator.isNonEmptyString(projectId) ? { projectId, firebaseVersion } : { firebaseVersion }; } throw new FirebaseFirestoreError({ diff --git a/src/instance-id/instance-id-request.ts b/src/instance-id/instance-id-request.ts index b683ff038b..bab069faf1 100644 --- a/src/instance-id/instance-id-request.ts +++ b/src/instance-id/instance-id-request.ts @@ -14,8 +14,8 @@ * limitations under the License. */ -import {FirebaseApp} from '../firebase-app'; -import {FirebaseInstanceIdError, InstanceIdClientErrorCode} from '../utils/error'; +import { FirebaseApp } from '../firebase-app'; +import { FirebaseInstanceIdError, InstanceIdClientErrorCode } from '../utils/error'; import { ApiSettings, AuthorizedHttpClient, HttpRequestConfig, HttpError, } from '../utils/api-request'; diff --git a/src/instance-id/instance-id.ts b/src/instance-id/instance-id.ts index 27e807528d..be63c8af89 100644 --- a/src/instance-id/instance-id.ts +++ b/src/instance-id/instance-id.ts @@ -14,10 +14,10 @@ * limitations under the License. */ -import {FirebaseApp} from '../firebase-app'; -import {FirebaseInstanceIdError, InstanceIdClientErrorCode} from '../utils/error'; -import {FirebaseServiceInterface, FirebaseServiceInternalsInterface} from '../firebase-service'; -import {FirebaseInstanceIdRequestHandler} from './instance-id-request'; +import { FirebaseApp } from '../firebase-app'; +import { FirebaseInstanceIdError, InstanceIdClientErrorCode } from '../utils/error'; +import { FirebaseServiceInterface, FirebaseServiceInternalsInterface } from '../firebase-service'; +import { FirebaseInstanceIdRequestHandler } from './instance-id-request'; import * as validator from '../utils/validator'; diff --git a/src/machine-learning/machine-learning.ts b/src/machine-learning/machine-learning.ts index 2879e5d460..9d2330aa92 100644 --- a/src/machine-learning/machine-learning.ts +++ b/src/machine-learning/machine-learning.ts @@ -14,14 +14,14 @@ * limitations under the License. */ -import {FirebaseApp} from '../firebase-app'; -import {FirebaseServiceInterface, FirebaseServiceInternalsInterface} from '../firebase-service'; -import {MachineLearningApiClient, ModelResponse, OperationResponse, - ModelOptions, ModelUpdateOptions, ListModelsOptions} from './machine-learning-api-client'; -import {FirebaseError} from '../utils/error'; +import { FirebaseApp } from '../firebase-app'; +import { FirebaseServiceInterface, FirebaseServiceInternalsInterface } from '../firebase-service'; +import { MachineLearningApiClient, ModelResponse, OperationResponse, + ModelOptions, ModelUpdateOptions, ListModelsOptions } from './machine-learning-api-client'; +import { FirebaseError } from '../utils/error'; import * as validator from '../utils/validator'; -import {FirebaseMachineLearningError} from './machine-learning-utils'; +import { FirebaseMachineLearningError } from './machine-learning-utils'; import { deepCopy } from '../utils/deep-copy'; import * as utils from '../utils'; @@ -166,7 +166,7 @@ export class MachineLearning implements FirebaseServiceInterface { if (resp.models) { models = resp.models.map((rs) => new Model(rs)); } - const result: ListModelsResult = {models}; + const result: ListModelsResult = { models }; if (resp.nextPageToken) { result.pageToken = resp.nextPageToken; } @@ -185,7 +185,7 @@ export class MachineLearning implements FirebaseServiceInterface { private setPublishStatus(modelId: string, publish: boolean): Promise { const updateMask = ['state.published']; - const options: ModelUpdateOptions = {state: {published: publish}}; + const options: ModelUpdateOptions = { state: { published: publish } }; return this.client.updateModel(modelId, options, updateMask) .then((operation) => handleOperation(operation)); } diff --git a/src/messaging/messaging-api-request.ts b/src/messaging/messaging-api-request.ts index 9af1ff8571..6a44ac67f6 100644 --- a/src/messaging/messaging-api-request.ts +++ b/src/messaging/messaging-api-request.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import {FirebaseApp} from '../firebase-app'; +import { FirebaseApp } from '../firebase-app'; import { HttpMethod, AuthorizedHttpClient, HttpRequestConfig, HttpError, HttpResponse, } from '../utils/api-request'; diff --git a/src/messaging/messaging-errors.ts b/src/messaging/messaging-errors.ts index b317404087..ecd3155bae 100644 --- a/src/messaging/messaging-errors.ts +++ b/src/messaging/messaging-errors.ts @@ -14,8 +14,8 @@ * limitations under the License. */ -import {HttpError} from '../utils/api-request'; -import {FirebaseMessagingError, MessagingClientErrorCode} from '../utils/error'; +import { HttpError } from '../utils/api-request'; +import { FirebaseMessagingError, MessagingClientErrorCode } from '../utils/error'; import * as validator from '../utils/validator'; /** diff --git a/src/messaging/messaging-types.ts b/src/messaging/messaging-types.ts index 27891d27ed..795d0c1fb2 100644 --- a/src/messaging/messaging-types.ts +++ b/src/messaging/messaging-types.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import {renameProperties} from '../utils/index'; +import { renameProperties } from '../utils/index'; import { MessagingClientErrorCode, FirebaseMessagingError, FirebaseArrayIndexError, FirebaseError, } from '../utils/error'; diff --git a/src/messaging/messaging.ts b/src/messaging/messaging.ts index 6cabb1104b..e9eab2b43e 100644 --- a/src/messaging/messaging.ts +++ b/src/messaging/messaging.ts @@ -14,17 +14,17 @@ * limitations under the License. */ -import {FirebaseApp} from '../firebase-app'; -import {deepCopy, deepExtend} from '../utils/deep-copy'; -import {SubRequest} from './batch-request'; +import { FirebaseApp } from '../firebase-app'; +import { deepCopy, deepExtend } from '../utils/deep-copy'; +import { SubRequest } from './batch-request'; import { Message, validateMessage, MessagingDevicesResponse, MessagingDeviceGroupResponse, MessagingTopicManagementResponse, MessagingPayload, MessagingOptions, MessagingTopicResponse, MessagingConditionResponse, BatchResponse, MulticastMessage, DataMessagePayload, NotificationMessagePayload, } from './messaging-types'; -import {FirebaseMessagingRequestHandler} from './messaging-api-request'; -import {FirebaseServiceInterface, FirebaseServiceInternalsInterface} from '../firebase-service'; +import { FirebaseMessagingRequestHandler } from './messaging-api-request'; +import { FirebaseServiceInterface, FirebaseServiceInternalsInterface } from '../firebase-service'; import { ErrorInfo, MessagingClientErrorCode, FirebaseMessagingError, } from '../utils/error'; @@ -253,7 +253,7 @@ export class Messaging implements FirebaseServiceInterface { } return this.getUrlPath() .then((urlPath) => { - const request: {message: Message; validate_only?: boolean} = {message: copy}; + const request: {message: Message; validate_only?: boolean} = { message: copy }; if (dryRun) { request.validate_only = true; } @@ -306,7 +306,7 @@ export class Messaging implements FirebaseServiceInterface { .then((urlPath) => { const requests: SubRequest[] = copy.map((message) => { validateMessage(message); - const request: {message: Message; validate_only?: boolean} = {message}; + const request: {message: Message; validate_only?: boolean} = { message }; if (dryRun) { request.validate_only = true; } diff --git a/src/security-rules/security-rules-api-client.ts b/src/security-rules/security-rules-api-client.ts index 37989081fb..87e379513f 100644 --- a/src/security-rules/security-rules-api-client.ts +++ b/src/security-rules/security-rules-api-client.ts @@ -170,7 +170,7 @@ export class SecurityRulesApiClient { const request: HttpRequestConfig = { method: 'PATCH', url: `${url}/releases/${name}`, - data: {release}, + data: { release }, }; return this.sendRequest(request); }); diff --git a/src/storage/storage.ts b/src/storage/storage.ts index afd3b003de..af490eedd5 100644 --- a/src/storage/storage.ts +++ b/src/storage/storage.ts @@ -14,11 +14,11 @@ * limitations under the License. */ -import {FirebaseApp} from '../firebase-app'; -import {FirebaseError} from '../utils/error'; -import {FirebaseServiceInterface, FirebaseServiceInternalsInterface} from '../firebase-service'; -import {ServiceAccountCredential, isApplicationDefault} from '../auth/credential'; -import {Bucket, Storage as StorageClient} from '@google-cloud/storage'; +import { FirebaseApp } from '../firebase-app'; +import { FirebaseError } from '../utils/error'; +import { FirebaseServiceInterface, FirebaseServiceInternalsInterface } from '../firebase-service'; +import { ServiceAccountCredential, isApplicationDefault } from '../auth/credential'; +import { Bucket, Storage as StorageClient } from '@google-cloud/storage'; import * as utils from '../utils/index'; import * as validator from '../utils/validator'; diff --git a/src/utils/api-request.ts b/src/utils/api-request.ts index 0597d8d9f3..03f52d0240 100644 --- a/src/utils/api-request.ts +++ b/src/utils/api-request.ts @@ -14,15 +14,15 @@ * limitations under the License. */ -import {FirebaseApp} from '../firebase-app'; -import {AppErrorCodes, FirebaseAppError} from './error'; +import { FirebaseApp } from '../firebase-app'; +import { AppErrorCodes, FirebaseAppError } from './error'; import * as validator from './validator'; import http = require('http'); import https = require('https'); import url = require('url'); -import {EventEmitter} from 'events'; -import {Readable} from 'stream'; +import { EventEmitter } from 'events'; +import { Readable } from 'stream'; import * as zlibmod from 'zlib'; /** Http method type definition. */ @@ -588,7 +588,7 @@ class AsyncHttpCall { response: LowLevelResponse, respStream: Readable, boundary: string): void { const dicer = require('dicer'); // eslint-disable-line @typescript-eslint/no-var-requires - const multipartParser = new dicer({boundary}); + const multipartParser = new dicer({ boundary }); const responseBuffer: Buffer[] = []; multipartParser.on('part', (part: any) => { const tempBuffers: Buffer[] = []; diff --git a/src/utils/error.ts b/src/utils/error.ts index 746cc3ca5d..8644511463 100755 --- a/src/utils/error.ts +++ b/src/utils/error.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import {deepCopy} from '../utils/deep-copy'; +import { deepCopy } from '../utils/deep-copy'; /** * Defines error info type. This includes a code and message string. @@ -196,7 +196,7 @@ export class FirebaseAuthError extends PrefixedFirebaseError { export class FirebaseDatabaseError extends FirebaseError { constructor(info: ErrorInfo, message?: string) { // Override default message if custom message provided. - super({code: 'database/' + info.code, message: message || info.message}); + super({ code: 'database/' + info.code, message: message || info.message }); } } @@ -211,7 +211,7 @@ export class FirebaseDatabaseError extends FirebaseError { export class FirebaseFirestoreError extends FirebaseError { constructor(info: ErrorInfo, message?: string) { // Override default message if custom message provided. - super({code: 'firestore/' + info.code, message: message || info.message}); + super({ code: 'firestore/' + info.code, message: message || info.message }); } } @@ -226,7 +226,7 @@ export class FirebaseFirestoreError extends FirebaseError { export class FirebaseInstanceIdError extends FirebaseError { constructor(info: ErrorInfo, message?: string) { // Override default message if custom message provided. - super({code: 'instance-id/' + info.code, message: message || info.message}); + super({ code: 'instance-id/' + info.code, message: message || info.message }); } } diff --git a/src/utils/index.ts b/src/utils/index.ts index f6e2f41232..f3f75d6d80 100755 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -14,8 +14,8 @@ * limitations under the License. */ -import {FirebaseApp, FirebaseAppOptions} from '../firebase-app'; -import {ServiceAccountCredential, ComputeEngineCredential} from '../auth/credential'; +import { FirebaseApp, FirebaseAppOptions } from '../firebase-app'; +import { ServiceAccountCredential, ComputeEngineCredential } from '../auth/credential'; import * as validator from './validator'; diff --git a/test/integration/app.spec.ts b/test/integration/app.spec.ts index 532adb5798..3cdf356245 100644 --- a/test/integration/app.spec.ts +++ b/test/integration/app.spec.ts @@ -15,7 +15,7 @@ */ import * as admin from '../../lib/index'; -import {expect} from 'chai'; +import { expect } from 'chai'; import { defaultApp, nullApp, nonNullApp, databaseUrl, projectId, storageBucket, } from './setup'; diff --git a/test/integration/auth.spec.ts b/test/integration/auth.spec.ts index ac7d8bde08..e4617357fb 100755 --- a/test/integration/auth.spec.ts +++ b/test/integration/auth.spec.ts @@ -21,7 +21,7 @@ import * as crypto from 'crypto'; import * as bcrypt from 'bcrypt'; import firebase from '@firebase/app'; import '@firebase/auth'; -import {clone} from 'lodash'; +import { clone } from 'lodash'; import { generateRandomString, projectId, apiKey, noServiceAccountApp, cmdArgs, } from './setup'; @@ -288,14 +288,14 @@ describe('admin.auth', () => { { uid: 'uid_that_doesnt_exist' }, { uid: 'uid3' }, ]); - expect(users.notFound).to.have.deep.members([{uid: 'uid_that_doesnt_exist'}]); + expect(users.notFound).to.have.deep.members([{ uid: 'uid_that_doesnt_exist' }]); const foundUsers = mapUserRecordsToUidEmailPhones(users.users); expect(foundUsers).to.have.deep.members([testUser1, testUser3]); }); it('returns nothing when queried for only non-existing users', async () => { - const notFoundIds = [{uid: 'non-existing user'}]; + const notFoundIds = [{ uid: 'non-existing user' }]; const users = await admin.auth().getUsers(notFoundIds); expect(users.users).to.be.empty; @@ -412,7 +412,7 @@ describe('admin.auth', () => { let currentUser: User; // Sign in with an email and password account. return clientAuth().signInWithEmailAndPassword(mockUserData.email, mockUserData.password) - .then(({user}) => { + .then(({ user }) => { expect(user).to.exist; currentUser = user!; // Get user's ID token. @@ -449,7 +449,7 @@ describe('admin.auth', () => { return clientAuth().signInWithEmailAndPassword( mockUserData.email, mockUserData.password); }) - .then(({user}) => { + .then(({ user }) => { // Get new session's ID token. expect(user).to.exist; return user!.getIdToken(); @@ -474,7 +474,7 @@ describe('admin.auth', () => { return clientAuth().signInWithEmailAndPassword( userRecord.email!, mockUserData.password); }) - .then(({user}) => { + .then(({ user }) => { // Get the user's ID token. expect(user).to.exist; return user!.getIdToken(); @@ -614,7 +614,7 @@ describe('admin.auth', () => { .then((customToken) => { return clientAuth().signInWithCustomToken(customToken); }) - .then(({user}) => { + .then(({ user }) => { expect(user).to.exist; return user!.getIdToken(); }) @@ -634,7 +634,7 @@ describe('admin.auth', () => { .then((customToken) => { return clientAuth().signInWithCustomToken(customToken); }) - .then(({user}) => { + .then(({ user }) => { expect(user).to.exist; return user!.getIdToken(); }) @@ -680,7 +680,7 @@ describe('admin.auth', () => { it('generatePasswordResetLink() should return a password reset link', () => { // Ensure old password set on created user. - return admin.auth().updateUser(uid, {password: 'password'}) + return admin.auth().updateUser(uid, { password: 'password' }) .then(() => { return admin.auth().generatePasswordResetLink(email, actionCodeSettings); }) @@ -702,7 +702,7 @@ describe('admin.auth', () => { it('generateEmailVerificationLink() should return a verification link', () => { // Ensure the user's email is unverified. - return admin.auth().updateUser(uid, {password: 'password', emailVerified: false}) + return admin.auth().updateUser(uid, { password: 'password', emailVerified: false }) .then((userRecord) => { expect(userRecord.emailVerified).to.be.false; return admin.auth().generateEmailVerificationLink(email, actionCodeSettings); @@ -972,7 +972,7 @@ describe('admin.auth', () => { clientAuth().tenantId = createdTenantId; const customToken = await tenantAwareAuth.createCustomToken('uid1'); - const {user} = await clientAuth().signInWithCustomToken(customToken); + const { user } = await clientAuth().signInWithCustomToken(customToken); expect(user).to.not.be.null; const idToken = await user!.getIdToken(); const token = await tenantAwareAuth.verifyIdToken(idToken); @@ -1041,7 +1041,7 @@ describe('admin.auth', () => { }) .then((config) => { const modifiedConfig = deepExtend( - {providerId: authProviderConfig.providerId}, modifiedConfigOptions); + { providerId: authProviderConfig.providerId }, modifiedConfigOptions); assertDeepEqualUnordered(modifiedConfig, config); return tenantAwareAuth.deleteProviderConfig(authProviderConfig.providerId); }) @@ -1099,7 +1099,7 @@ describe('admin.auth', () => { }) .then((config) => { const modifiedConfig = deepExtend( - {providerId: authProviderConfig.providerId}, modifiedConfigOptions); + { providerId: authProviderConfig.providerId }, modifiedConfigOptions); assertDeepEqualUnordered(modifiedConfig, config); return tenantAwareAuth.deleteProviderConfig(authProviderConfig.providerId); }) @@ -1242,7 +1242,7 @@ describe('admin.auth', () => { it('listProviderConfig() successfully returns the list of SAML providers', () => { const configs: AuthProviderConfig[] = []; const listProviders: any = (type: 'saml' | 'oidc', maxResults?: number, pageToken?: string) => { - return admin.auth().listProviderConfigs({type, maxResults, pageToken}) + return admin.auth().listProviderConfigs({ type, maxResults, pageToken }) .then((result) => { result.providerConfigs.forEach((config: AuthProviderConfig) => { configs.push(config); @@ -1284,7 +1284,7 @@ describe('admin.auth', () => { return admin.auth().updateProviderConfig(authProviderConfig1.providerId, modifiedConfigOptions) .then((config) => { const modifiedConfig = deepExtend( - {providerId: authProviderConfig1.providerId}, modifiedConfigOptions); + { providerId: authProviderConfig1.providerId }, modifiedConfigOptions); assertDeepEqualUnordered(modifiedConfig, config); }); }); @@ -1312,7 +1312,7 @@ describe('admin.auth', () => { return admin.auth().updateProviderConfig(authProviderConfig1.providerId, deltaChanges) .then((config) => { const modifiedConfig = deepExtend( - {providerId: authProviderConfig1.providerId}, modifiedConfigOptions); + { providerId: authProviderConfig1.providerId }, modifiedConfigOptions); assertDeepEqualUnordered(modifiedConfig, config); }); }); @@ -1374,7 +1374,7 @@ describe('admin.auth', () => { it('listProviderConfig() successfully returns the list of OIDC providers', () => { const configs: AuthProviderConfig[] = []; const listProviders: any = (type: 'saml' | 'oidc', maxResults?: number, pageToken?: string) => { - return admin.auth().listProviderConfigs({type, maxResults, pageToken}) + return admin.auth().listProviderConfigs({ type, maxResults, pageToken }) .then((result) => { result.providerConfigs.forEach((config: AuthProviderConfig) => { configs.push(config); @@ -1412,7 +1412,7 @@ describe('admin.auth', () => { return admin.auth().updateProviderConfig(authProviderConfig1.providerId, modifiedConfigOptions) .then((config) => { const modifiedConfig = deepExtend( - {providerId: authProviderConfig1.providerId}, modifiedConfigOptions); + { providerId: authProviderConfig1.providerId }, modifiedConfigOptions); assertDeepEqualUnordered(modifiedConfig, config); }); }); @@ -1432,7 +1432,7 @@ describe('admin.auth', () => { return admin.auth().updateProviderConfig(authProviderConfig1.providerId, deltaChanges) .then((config) => { const modifiedConfig = deepExtend( - {providerId: authProviderConfig1.providerId}, modifiedConfigOptions); + { providerId: authProviderConfig1.providerId }, modifiedConfigOptions); assertDeepEqualUnordered(modifiedConfig, config); }); }); @@ -1458,7 +1458,7 @@ describe('admin.auth', () => { const uid1 = await admin.auth().createUser({}).then((ur) => ur.uid); const uid2 = await admin.auth().createUser({}).then((ur) => ur.uid); const uid3 = await admin.auth().createUser({}).then((ur) => ur.uid); - const ids = [{uid: uid1}, {uid: uid2}, {uid: uid3}]; + const ids = [{ uid: uid1 }, { uid: uid2 }, { uid: uid3 }]; return deleteUsersWithDelay([uid1, uid2, uid3]) .then((deleteUsersResult) => { @@ -1477,7 +1477,7 @@ describe('admin.auth', () => { it('deletes users that exist even when non-existing users also specified', async () => { const uid1 = await admin.auth().createUser({}).then((ur) => ur.uid); const uid2 = 'uid-that-doesnt-exist'; - const ids = [{uid: uid1}, {uid: uid2}]; + const ids = [{ uid: uid1 }, { uid: uid2 }]; return deleteUsersWithDelay([uid1, uid2]) .then((deleteUsersResult) => { @@ -1521,9 +1521,9 @@ describe('admin.auth', () => { const uid3 = sessionCookieUids[2]; it('creates a valid Firebase session cookie', () => { - return admin.auth().createCustomToken(uid, {admin: true, groupId: '1234'}) + return admin.auth().createCustomToken(uid, { admin: true, groupId: '1234' }) .then((customToken) => clientAuth().signInWithCustomToken(customToken)) - .then(({user}) => { + .then(({ user }) => { expect(user).to.exist; return user!.getIdToken(); }) @@ -1539,7 +1539,7 @@ describe('admin.auth', () => { delete payloadClaims.iat; expectedIat = Math.floor(new Date().getTime() / 1000); // One day long session cookie. - return admin.auth().createSessionCookie(currentIdToken, {expiresIn}); + return admin.auth().createSessionCookie(currentIdToken, { expiresIn }); }) .then((sessionCookie) => admin.auth().verifySessionCookie(sessionCookie)) .then((decodedIdToken) => { @@ -1559,13 +1559,13 @@ describe('admin.auth', () => { let currentSessionCookie: string; return admin.auth().createCustomToken(uid2) .then((customToken) => clientAuth().signInWithCustomToken(customToken)) - .then(({user}) => { + .then(({ user }) => { expect(user).to.exist; return user!.getIdToken(); }) .then((idToken) => { // One day long session cookie. - return admin.auth().createSessionCookie(idToken, {expiresIn}); + return admin.auth().createSessionCookie(idToken, { expiresIn }); }) .then((sessionCookie) => { currentSessionCookie = sessionCookie; @@ -1584,9 +1584,9 @@ describe('admin.auth', () => { }); it('fails when called with a revoked ID token', () => { - return admin.auth().createCustomToken(uid3, {admin: true, groupId: '1234'}) + return admin.auth().createCustomToken(uid3, { admin: true, groupId: '1234' }) .then((customToken) => clientAuth().signInWithCustomToken(customToken)) - .then(({user}) => { + .then(({ user }) => { expect(user).to.exist; return user!.getIdToken(); }) @@ -1597,7 +1597,7 @@ describe('admin.auth', () => { ), 1000)); }) .then(() => { - return admin.auth().createSessionCookie(currentIdToken, {expiresIn}) + return admin.auth().createSessionCookie(currentIdToken, { expiresIn }) .should.eventually.be.rejected.and.have.property('code', 'auth/id-token-expired'); }); }); @@ -1614,7 +1614,7 @@ describe('admin.auth', () => { it('fails when called with a Firebase ID token', () => { return admin.auth().createCustomToken(uid) .then((customToken) => clientAuth().signInWithCustomToken(customToken)) - .then(({user}) => { + .then(({ user }) => { expect(user).to.exist; return user!.getIdToken(); }) @@ -1817,7 +1817,7 @@ describe('admin.auth', () => { photoURL, phoneNumber: '+15554446666', disabled: false, - customClaims: {admin: true}, + customClaims: { admin: true }, metadata: { lastSignInTime: now, creationTime: now, @@ -1922,10 +1922,10 @@ describe('admin.auth', () => { it('fails when invalid users are provided', () => { const users = [ - {uid: generateRandomString(20).toLowerCase(), phoneNumber: '+1error'}, - {uid: generateRandomString(20).toLowerCase(), email: 'invalid'}, - {uid: generateRandomString(20).toLowerCase(), phoneNumber: '+1invalid'}, - {uid: generateRandomString(20).toLowerCase(), emailVerified: 'invalid'} as any, + { uid: generateRandomString(20).toLowerCase(), phoneNumber: '+1error' }, + { uid: generateRandomString(20).toLowerCase(), email: 'invalid' }, + { uid: generateRandomString(20).toLowerCase(), phoneNumber: '+1invalid' }, + { uid: generateRandomString(20).toLowerCase(), emailVerified: 'invalid' } as any, ]; return admin.auth().importUsers(users) .then((result) => { @@ -1969,7 +1969,7 @@ function testImportAndSignInUser( // Sign in with an email and password to the imported account. return clientAuth().signInWithEmailAndPassword(users[0].email!, rawPassword); }) - .then(({user}) => { + .then(({ user }) => { // Confirm successful sign-in. expect(user).to.exist; expect(user!.email).to.equal(users[0].email); diff --git a/test/integration/database.spec.ts b/test/integration/database.spec.ts index b64e099813..e8d0a746a4 100644 --- a/test/integration/database.spec.ts +++ b/test/integration/database.spec.ts @@ -17,7 +17,7 @@ import * as admin from '../../lib/index'; import * as chai from 'chai'; import * as chaiAsPromised from 'chai-as-promised'; -import {defaultApp, nullApp, nonNullApp, cmdArgs, databaseUrl} from './setup'; +import { defaultApp, nullApp, nonNullApp, cmdArgs, databaseUrl } from './setup'; // eslint-disable-next-line @typescript-eslint/no-var-requires const chalk = require('chalk'); diff --git a/test/integration/firestore.spec.ts b/test/integration/firestore.spec.ts index d3bbf51493..3a6dc89fff 100644 --- a/test/integration/firestore.spec.ts +++ b/test/integration/firestore.spec.ts @@ -17,7 +17,7 @@ import * as admin from '../../lib/index'; import * as chai from 'chai'; import * as chaiAsPromised from 'chai-as-promised'; -import {clone} from 'lodash'; +import { clone } from 'lodash'; chai.should(); chai.use(chaiAsPromised); @@ -118,7 +118,7 @@ describe('admin.firestore', () => { const target = admin.firestore().collection('cities').doc(); return source.set(mountainView) .then(() => { - return target.set({name: 'Palo Alto', sisterCity: source}); + return target.set({ name: 'Palo Alto', sisterCity: source }); }) .then(() => { return target.get(); @@ -141,7 +141,7 @@ describe('admin.firestore', () => { admin.firestore.setLogFunction((log) => { logs.push(log); }); - return source.set({name: 'San Francisco'}) + return source.set({ name: 'San Francisco' }) .then(() => { return source.delete(); }) diff --git a/test/integration/machine-learning.spec.ts b/test/integration/machine-learning.spec.ts index 9cef0d31db..da2c0a60fd 100644 --- a/test/integration/machine-learning.spec.ts +++ b/test/integration/machine-learning.spec.ts @@ -18,7 +18,7 @@ import path = require('path'); import * as chai from 'chai'; import * as admin from '../../lib/index'; -import {Bucket} from '@google-cloud/storage'; +import { Bucket } from '@google-cloud/storage'; const expect = chai.expect; @@ -61,7 +61,7 @@ describe('admin.machineLearning', () => { function uploadModelToGcs(localFileName: string, gcsFileName: string): Promise { const bucket: Bucket = admin.storage().bucket(); const tfliteFileName = path.join(__dirname, `../resources/${localFileName}`); - return bucket.upload(tfliteFileName, {destination: gcsFileName}) + return bucket.upload(tfliteFileName, { destination: gcsFileName }) .then(() => { return `gs://${bucket.name}/${gcsFileName}`; }); @@ -75,7 +75,7 @@ describe('admin.machineLearning', () => { it('creates a new Model without ModelFormat', () => { const modelOptions: admin.machineLearning.ModelOptions = { displayName: 'node-integration-test-create-1', - tags: ['tag123', 'tag345']}; + tags: ['tag123', 'tag345'] }; return admin.machineLearning().createModel(modelOptions) .then((model) => { scheduleForDelete(model); @@ -87,7 +87,7 @@ describe('admin.machineLearning', () => { const modelOptions: admin.machineLearning.ModelOptions = { displayName: 'node-integration-test-create-2', tags: ['tag234', 'tag456'], - tfliteModel: {gcsTfliteUri: 'this will be replaced below'}, + tfliteModel: { gcsTfliteUri: 'this will be replaced below' }, }; return uploadModelToGcs('model1.tflite', 'valid_model.tflite') .then((fileName: string) => { @@ -105,7 +105,7 @@ describe('admin.machineLearning', () => { const modelOptions: admin.machineLearning.ModelOptions = { displayName: 'node-integration-test-create-3', tags: ['tag234', 'tag456'], - tfliteModel: {gcsTfliteUri: 'this will be replaced below'}, + tfliteModel: { gcsTfliteUri: 'this will be replaced below' }, }; return uploadModelToGcs('invalid_model.tflite', 'invalid_model.tflite') .then((fileName: string) => { @@ -150,7 +150,7 @@ describe('admin.machineLearning', () => { const modelOptions: admin.machineLearning.ModelOptions = { displayName: 'Invalid Name#*^!', }; - return createTemporaryModel({displayName: 'node-integration-invalid-arg'}) + return createTemporaryModel({ displayName: 'node-integration-invalid-arg' }) .then((model) => admin.machineLearning().updateModel(model.modelId, modelOptions) .should.eventually.be.rejected.and.have.property( 'code', 'machine-learning/invalid-argument')); @@ -158,7 +158,7 @@ describe('admin.machineLearning', () => { it('updates the displayName', () => { const DISPLAY_NAME = 'node-integration-test-update-1b'; - return createTemporaryModel({displayName: 'node-integration-test-update-1a'}) + return createTemporaryModel({ displayName: 'node-integration-test-update-1a' }) .then((model) => { const modelOptions: admin.machineLearning.ModelOptions = { displayName: DISPLAY_NAME, @@ -195,7 +195,7 @@ describe('admin.machineLearning', () => { uploadModelToGcs('model1.tflite', 'valid_model.tflite')]) .then(([model, fileName]) => { const modelOptions: admin.machineLearning.ModelOptions = { - tfliteModel: {gcsTfliteUri: fileName}, + tfliteModel: { gcsTfliteUri: fileName }, }; return admin.machineLearning().updateModel(model.modelId, modelOptions) .then((updatedModel) => { @@ -207,7 +207,7 @@ describe('admin.machineLearning', () => { it('can update more than 1 field', () => { const DISPLAY_NAME = 'node-integration-test-update-3b'; const TAGS = ['node-integration-tag-1', 'node-integration-tag-2']; - return createTemporaryModel({displayName: 'node-integration-test-update-3a'}) + return createTemporaryModel({ displayName: 'node-integration-test-update-3a' }) .then((model) => { const modelOptions: admin.machineLearning.ModelOptions = { displayName: DISPLAY_NAME, @@ -239,7 +239,7 @@ describe('admin.machineLearning', () => { it('publishes the model successfully', () => { const modelOptions: admin.machineLearning.ModelOptions = { displayName: 'node-integration-test-publish-1', - tfliteModel: {gcsTfliteUri: 'this will be replaced below'}, + tfliteModel: { gcsTfliteUri: 'this will be replaced below' }, }; return uploadModelToGcs('model1.tflite', 'valid_model.tflite') .then((fileName: string) => { @@ -274,7 +274,7 @@ describe('admin.machineLearning', () => { it('unpublishes the model successfully', () => { const modelOptions: admin.machineLearning.ModelOptions = { displayName: 'node-integration-test-unpublish1', - tfliteModel: {gcsTfliteUri: 'this will be replaced below'}, + tfliteModel: { gcsTfliteUri: 'this will be replaced below' }, }; return uploadModelToGcs('model1.tflite', 'valid_model.tflite') .then((fileName: string) => { @@ -357,7 +357,7 @@ describe('admin.machineLearning', () => { }); it('resolves with a list of models', () => { - return admin.machineLearning().listModels({pageSize: 100}) + return admin.machineLearning().listModels({ pageSize: 100 }) .then((modelList) => { expect(modelList.models.length).to.be.at.least(2); expect(modelList.models).to.deep.include(model1); @@ -367,7 +367,7 @@ describe('admin.machineLearning', () => { }); it('respects page size', () => { - return admin.machineLearning().listModels({pageSize: 2}) + return admin.machineLearning().listModels({ pageSize: 2 }) .then((modelList) => { expect(modelList.models.length).to.equal(2); expect(modelList.pageToken).not.to.be.empty; @@ -375,7 +375,7 @@ describe('admin.machineLearning', () => { }); it('filters by exact displayName', () => { - return admin.machineLearning().listModels({filter: 'displayName=node-integration-list1'}) + return admin.machineLearning().listModels({ filter: 'displayName=node-integration-list1' }) .then((modelList) => { expect(modelList.models.length).to.equal(1); expect(modelList.models[0]).to.deep.equal(model1); @@ -384,7 +384,7 @@ describe('admin.machineLearning', () => { }); it('filters by displayName prefix', () => { - return admin.machineLearning().listModels({filter: 'displayName:node-integration-list*', pageSize: 100}) + return admin.machineLearning().listModels({ filter: 'displayName:node-integration-list*', pageSize: 100 }) .then((modelList) => { expect(modelList.models.length).to.be.at.least(3); expect(modelList.models).to.deep.include(model1); @@ -395,7 +395,7 @@ describe('admin.machineLearning', () => { }); it('filters by tag', () => { - return admin.machineLearning().listModels({filter: 'tags:node-integration-tag-1', pageSize: 100}) + return admin.machineLearning().listModels({ filter: 'tags:node-integration-tag-1', pageSize: 100 }) .then((modelList) => { expect(modelList.models.length).to.be.at.least(3); expect(modelList.models).to.deep.include(model1); @@ -406,14 +406,14 @@ describe('admin.machineLearning', () => { }); it('handles pageTokens properly', () => { - return admin.machineLearning().listModels({filter: 'displayName:node-integration-list*', pageSize: 2}) + return admin.machineLearning().listModels({ filter: 'displayName:node-integration-list*', pageSize: 2 }) .then((modelList) => { expect(modelList.models.length).to.equal(2); expect(modelList.pageToken).not.to.be.empty; return admin.machineLearning().listModels({ filter: 'displayName:node-integration-list*', pageSize: 2, - pageToken: modelList.pageToken}) + pageToken: modelList.pageToken }) .then((modelList2) => { expect(modelList2.models.length).to.be.at.least(1); expect(modelList2.pageToken).to.be.empty; @@ -422,7 +422,7 @@ describe('admin.machineLearning', () => { }); it('successfully returns an empty list of models', () => { - return admin.machineLearning().listModels({filter: 'displayName=non-existing-model'}) + return admin.machineLearning().listModels({ filter: 'displayName=non-existing-model' }) .then((modelList) => { expect(modelList.models.length).to.equal(0); expect(modelList.pageToken).to.be.empty; @@ -430,7 +430,7 @@ describe('admin.machineLearning', () => { }); it('rejects with invalid argument if the filter is invalid', () => { - return admin.machineLearning().listModels({filter: 'invalidFilterItem=foo'}) + return admin.machineLearning().listModels({ filter: 'invalidFilterItem=foo' }) .should.eventually.be.rejected.and.have.property( 'code', 'machine-learning/invalid-argument'); }); diff --git a/test/integration/messaging.spec.ts b/test/integration/messaging.spec.ts index 7f0d7e24f9..e67a81602b 100644 --- a/test/integration/messaging.spec.ts +++ b/test/integration/messaging.spec.ts @@ -125,7 +125,7 @@ describe('admin.messaging', () => { it('sendAll(500)', () => { const messages: admin.messaging.Message[] = []; for (let i = 0; i < 500; i++) { - messages.push({topic: `foo-bar-${i % 10}`}); + messages.push({ topic: `foo-bar-${i % 10}` }); } return admin.messaging().sendAll(messages, true) .then((response) => { diff --git a/test/integration/setup.ts b/test/integration/setup.ts index a3558ae6b2..4d58cede9c 100644 --- a/test/integration/setup.ts +++ b/test/integration/setup.ts @@ -18,7 +18,7 @@ import * as admin from '../../lib/index'; import fs = require('fs'); import minimist = require('minimist'); import path = require('path'); -import {random} from 'lodash'; +import { random } from 'lodash'; import { Credential, GoogleOAuthAccessToken } from '../../src/auth/credential'; // eslint-disable-next-line @typescript-eslint/no-var-requires diff --git a/test/integration/storage.spec.ts b/test/integration/storage.spec.ts index 55e2414580..25b7a39e43 100644 --- a/test/integration/storage.spec.ts +++ b/test/integration/storage.spec.ts @@ -17,9 +17,9 @@ import * as admin from '../../lib/index'; import * as chai from 'chai'; import * as chaiAsPromised from 'chai-as-promised'; -import {Bucket, File} from '@google-cloud/storage'; +import { Bucket, File } from '@google-cloud/storage'; -import {projectId} from './setup'; +import { projectId } from './setup'; chai.should(); chai.use(chaiAsPromised); diff --git a/test/integration/typescript/src/example.test.ts b/test/integration/typescript/src/example.test.ts index 2b1159f696..8b730ea3f6 100644 --- a/test/integration/typescript/src/example.test.ts +++ b/test/integration/typescript/src/example.test.ts @@ -15,9 +15,9 @@ */ import initApp from './example'; -import {expect} from 'chai'; -import {Bucket} from '@google-cloud/storage'; -import {Firestore} from '@google-cloud/firestore'; +import { expect } from 'chai'; +import { Bucket } from '@google-cloud/storage'; +import { Firestore } from '@google-cloud/firestore'; import * as admin from 'firebase-admin'; diff --git a/test/resources/mocks.ts b/test/resources/mocks.ts index 7c73e8fe54..cb2be41a8f 100644 --- a/test/resources/mocks.ts +++ b/test/resources/mocks.ts @@ -24,10 +24,10 @@ import stream = require('stream'); import * as _ from 'lodash'; import * as jwt from 'jsonwebtoken'; -import {FirebaseNamespace} from '../../src/firebase-namespace'; -import {FirebaseServiceInterface} from '../../src/firebase-service'; -import {FirebaseApp, FirebaseAppOptions} from '../../src/firebase-app'; -import {Credential, GoogleOAuthAccessToken, ServiceAccountCredential} from '../../src/auth/credential'; +import { FirebaseNamespace } from '../../src/firebase-namespace'; +import { FirebaseServiceInterface } from '../../src/firebase-service'; +import { FirebaseApp, FirebaseAppOptions } from '../../src/firebase-app'; +import { Credential, GoogleOAuthAccessToken, ServiceAccountCredential } from '../../src/auth/credential'; const ALGORITHM = 'RS256'; const ONE_HOUR_IN_SECONDS = 60 * 60; diff --git a/test/unit/auth/action-code-settings-builder.spec.ts b/test/unit/auth/action-code-settings-builder.spec.ts index 78eace7a04..ceadde3e9b 100644 --- a/test/unit/auth/action-code-settings-builder.spec.ts +++ b/test/unit/auth/action-code-settings-builder.spec.ts @@ -19,8 +19,8 @@ import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; import * as chaiAsPromised from 'chai-as-promised'; -import {ActionCodeSettingsBuilder} from '../../../src/auth/action-code-settings-builder'; -import {AuthClientErrorCode} from '../../../src/utils/error'; +import { ActionCodeSettingsBuilder } from '../../../src/auth/action-code-settings-builder'; +import { AuthClientErrorCode } from '../../../src/utils/error'; chai.should(); @@ -139,7 +139,7 @@ describe('ActionCodeSettingsBuilder', () => { return new ActionCodeSettingsBuilder({ url: 'https://www.example.com/path/file?a=1&b=2', handleCodeInApp: true, - iOS: {bundleId}, + iOS: { bundleId }, } as any); }).to.throw('"ActionCodeSettings.iOS.bundleId" must be a valid non-empty string.'); }); @@ -175,7 +175,7 @@ describe('ActionCodeSettingsBuilder', () => { return new ActionCodeSettingsBuilder({ url: 'https://www.example.com/path/file?a=1&b=2', handleCodeInApp: true, - android: {packageName}, + android: { packageName }, } as any); }).to.throw('"ActionCodeSettings.android.packageName" must be a valid non-empty string.'); }); diff --git a/test/unit/auth/auth-api-request.spec.ts b/test/unit/auth/auth-api-request.spec.ts index 15f90407d7..f1173b5d0b 100755 --- a/test/unit/auth/auth-api-request.spec.ts +++ b/test/unit/auth/auth-api-request.spec.ts @@ -25,9 +25,9 @@ import * as chaiAsPromised from 'chai-as-promised'; import * as utils from '../utils'; import * as mocks from '../../resources/mocks'; -import {deepCopy, deepExtend} from '../../../src/utils/deep-copy'; -import {FirebaseApp} from '../../../src/firebase-app'; -import {HttpClient, HttpRequestConfig} from '../../../src/utils/api-request'; +import { deepCopy, deepExtend } from '../../../src/utils/deep-copy'; +import { FirebaseApp } from '../../../src/firebase-app'; +import { HttpClient, HttpRequestConfig } from '../../../src/utils/api-request'; import * as validator from '../../../src/utils/validator'; import { AuthRequestHandler, FIREBASE_AUTH_GET_ACCOUNT_INFO, FIREBASE_AUTH_GET_ACCOUNTS_INFO, @@ -36,15 +36,15 @@ import { RESERVED_CLAIMS, FIREBASE_AUTH_UPLOAD_ACCOUNT, FIREBASE_AUTH_CREATE_SESSION_COOKIE, EMAIL_ACTION_REQUEST_TYPES, TenantAwareAuthRequestHandler, AbstractAuthRequestHandler, } from '../../../src/auth/auth-api-request'; -import {UserImportBuilder, UserImportRecord} from '../../../src/auth/user-import-builder'; -import {AuthClientErrorCode, FirebaseAuthError} from '../../../src/utils/error'; -import {ActionCodeSettingsBuilder} from '../../../src/auth/action-code-settings-builder'; +import { UserImportBuilder, UserImportRecord } from '../../../src/auth/user-import-builder'; +import { AuthClientErrorCode, FirebaseAuthError } from '../../../src/utils/error'; +import { ActionCodeSettingsBuilder } from '../../../src/auth/action-code-settings-builder'; import { OIDCAuthProviderConfig, SAMLAuthProviderConfig, OIDCUpdateAuthProviderRequest, SAMLUpdateAuthProviderRequest, SAMLConfigServerResponse, } from '../../../src/auth/auth-config'; -import {UserIdentifier} from '../../../src/auth/identifier'; -import {TenantOptions} from '../../../src/auth/tenant'; +import { UserIdentifier } from '../../../src/auth/identifier'; +import { TenantOptions } from '../../../src/auth/tenant'; import { UpdateRequest, UpdateMultiFactorInfoRequest } from '../../../src/auth/user-record'; chai.should(); @@ -109,7 +109,7 @@ describe('FIREBASE_AUTH_CREATE_SESSION_COOKIE', () => { describe('requestValidator', () => { const requestValidator = FIREBASE_AUTH_CREATE_SESSION_COOKIE.getRequestValidator(); it('should succeed with valid parameters passed', () => { - const validRequest = {idToken: 'ID_TOKEN', validDuration: 60 * 60}; + const validRequest = { idToken: 'ID_TOKEN', validDuration: 60 * 60 }; expect(() => { return requestValidator(validRequest); }).not.to.throw(); @@ -118,7 +118,7 @@ describe('FIREBASE_AUTH_CREATE_SESSION_COOKIE', () => { }); it('should succeed with duration set at minimum allowed', () => { const validDuration = 60 * 5; - const validRequest = {idToken: 'ID_TOKEN', validDuration}; + const validRequest = { idToken: 'ID_TOKEN', validDuration }; expect(() => { return requestValidator(validRequest); }).not.to.throw(); @@ -127,7 +127,7 @@ describe('FIREBASE_AUTH_CREATE_SESSION_COOKIE', () => { }); it('should succeed with duration set at maximum allowed', () => { const validDuration = 60 * 60 * 24 * 14; - const validRequest = {idToken: 'ID_TOKEN', validDuration}; + const validRequest = { idToken: 'ID_TOKEN', validDuration }; expect(() => { return requestValidator(validRequest); }).not.to.throw(); @@ -135,14 +135,14 @@ describe('FIREBASE_AUTH_CREATE_SESSION_COOKIE', () => { expect(isNumber).to.have.been.calledOnce.and.calledWith(validDuration); }); it('should fail when idToken not passed', () => { - const invalidRequest = {validDuration: 60 * 60}; + const invalidRequest = { validDuration: 60 * 60 }; expect(() => { return requestValidator(invalidRequest); }).to.throw(); expect(isNonEmptyString).to.have.been.calledOnce.and.calledWith(undefined); }); it('should fail when validDuration not passed', () => { - const invalidRequest = {idToken: 'ID_TOKEN'}; + const invalidRequest = { idToken: 'ID_TOKEN' }; expect(() => { return requestValidator(invalidRequest); }).to.throw(); @@ -151,13 +151,13 @@ describe('FIREBASE_AUTH_CREATE_SESSION_COOKIE', () => { describe('called with invalid parameters', () => { it('should fail with invalid idToken', () => { expect(() => { - return requestValidator({idToken: '', validDuration: 60 * 60}); + return requestValidator({ idToken: '', validDuration: 60 * 60 }); }).to.throw(); expect(isNonEmptyString).to.have.been.calledOnce.and.calledWith(''); }); it('should fail with invalid validDuration', () => { expect(() => { - return requestValidator({idToken: 'ID_TOKEN', validDuration: 'invalid'}); + return requestValidator({ idToken: 'ID_TOKEN', validDuration: 'invalid' }); }).to.throw(); expect(isNonEmptyString).to.have.been.calledOnce.and.calledWith('ID_TOKEN'); expect(isNumber).to.have.been.calledOnce.and.calledWith('invalid'); @@ -166,7 +166,7 @@ describe('FIREBASE_AUTH_CREATE_SESSION_COOKIE', () => { // Duration less 5 minutes. const outOfBoundDuration = 60 * 5 - 1; expect(() => { - return requestValidator({idToken: 'ID_TOKEN', validDuration: outOfBoundDuration}); + return requestValidator({ idToken: 'ID_TOKEN', validDuration: outOfBoundDuration }); }).to.throw(); expect(isNonEmptyString).to.have.been.calledOnce.and.calledWith('ID_TOKEN'); expect(isNumber).to.have.been.calledOnce.and.calledWith(outOfBoundDuration); @@ -175,7 +175,7 @@ describe('FIREBASE_AUTH_CREATE_SESSION_COOKIE', () => { // Duration greater than 14 days. const outOfBoundDuration = 60 * 60 * 24 * 14 + 1; expect(() => { - return requestValidator({idToken: 'ID_TOKEN', validDuration: outOfBoundDuration}); + return requestValidator({ idToken: 'ID_TOKEN', validDuration: outOfBoundDuration }); }).to.throw(); expect(isNonEmptyString).to.have.been.calledOnce.and.calledWith('ID_TOKEN'); expect(isNumber).to.have.been.calledOnce.and.calledWith(outOfBoundDuration); @@ -185,7 +185,7 @@ describe('FIREBASE_AUTH_CREATE_SESSION_COOKIE', () => { describe('responseValidator', () => { const responseValidator = FIREBASE_AUTH_CREATE_SESSION_COOKIE.getResponseValidator(); it('should succeed with sessionCookie returned', () => { - const validResponse = {sessionCookie: 'SESSION_COOKIE'}; + const validResponse = { sessionCookie: 'SESSION_COOKIE' }; expect(() => { return responseValidator(validResponse); }).not.to.throw(); @@ -257,7 +257,7 @@ describe('FIREBASE_AUTH_DOWNLOAD_ACCOUNT', () => { describe('requestValidator', () => { const requestValidator = FIREBASE_AUTH_DOWNLOAD_ACCOUNT.getRequestValidator(); it('should succeed with valid maxResults passed', () => { - const validRequest = {maxResults: 500}; + const validRequest = { maxResults: 500 }; expect(() => { return requestValidator(validRequest); }).not.to.throw(); @@ -286,31 +286,31 @@ describe('FIREBASE_AUTH_DOWNLOAD_ACCOUNT', () => { describe('called with invalid parameters', () => { it('should fail with invalid maxResults', () => { expect(() => { - return requestValidator({maxResults: ''}); + return requestValidator({ maxResults: '' }); }).to.throw(); expect(isNumber).to.have.been.calledOnce.and.calledWith(''); }); it('should fail with zero maxResults', () => { expect(() => { - return requestValidator({maxResults: 0}); + return requestValidator({ maxResults: 0 }); }).to.throw(); expect(isNumber).to.have.been.calledOnce.and.calledWith(0); }); it('should fail with negative maxResults', () => { expect(() => { - return requestValidator({maxResults: -500}); + return requestValidator({ maxResults: -500 }); }).to.throw(); expect(isNumber).to.have.been.calledOnce.and.calledWith(-500); }); it('should fail with maxResults exceeding allowed limit', () => { expect(() => { - return requestValidator({maxResults: 1001}); + return requestValidator({ maxResults: 1001 }); }).to.throw(); expect(isNumber).to.have.been.calledOnce.and.calledWith(1001); }); it('should fail with invalid nextPageToken', () => { expect(() => { - return requestValidator({maxResults: 1000, nextPageToken: ['PAGE_TOKEN']}); + return requestValidator({ maxResults: 1000, nextPageToken: ['PAGE_TOKEN'] }); }).to.throw(); expect(isNonEmptyString).to.have.been.calledOnce.and.calledWith(['PAGE_TOKEN']); }); @@ -328,31 +328,31 @@ describe('FIREBASE_AUTH_GET_ACCOUNT_INFO', () => { describe('requestValidator', () => { const requestValidator = FIREBASE_AUTH_GET_ACCOUNT_INFO.getRequestValidator(); it('should succeed with localId passed', () => { - const validRequest = {localId: ['1234']}; + const validRequest = { localId: ['1234'] }; expect(() => { return requestValidator(validRequest); }).not.to.throw(); }); it('should succeed with email passed', () => { - const validRequest = {email: ['user@example.com']}; + const validRequest = { email: ['user@example.com'] }; expect(() => { return requestValidator(validRequest); }).not.to.throw(); }); it('should succeed with phoneNumber passed', () => { - const validRequest = {phoneNumber: ['+11234567890']}; + const validRequest = { phoneNumber: ['+11234567890'] }; expect(() => { return requestValidator(validRequest); }).not.to.throw(); }); it('should succeed with federatedUserId passed', () => { - const validRequest = {federatedUserId: [{providerId: 'google.com', rawId: 'google_uid'}]}; + const validRequest = { federatedUserId: [{ providerId: 'google.com', rawId: 'google_uid' }] }; expect(() => { return requestValidator(validRequest); }).not.to.throw(); }); it('should fail when neither localId, email or phoneNumber are passed', () => { - const invalidRequest = {bla: ['1234']}; + const invalidRequest = { bla: ['1234'] }; expect(() => { return requestValidator(invalidRequest); }).to.throw(); @@ -361,7 +361,7 @@ describe('FIREBASE_AUTH_GET_ACCOUNT_INFO', () => { describe('responseValidator', () => { const responseValidator = FIREBASE_AUTH_GET_ACCOUNT_INFO.getResponseValidator(); it('should succeed with users returned', () => { - const validResponse: object = {users: []}; + const validResponse: object = { users: [] }; expect(() => { return responseValidator(validResponse); }).not.to.throw(); @@ -385,31 +385,31 @@ describe('FIREBASE_AUTH_GET_ACCOUNTS_INFO', () => { describe('requestValidator', () => { const requestValidator = FIREBASE_AUTH_GET_ACCOUNTS_INFO.getRequestValidator(); it('should succeed with localId passed', () => { - const validRequest = {localId: ['1234']}; + const validRequest = { localId: ['1234'] }; expect(() => { return requestValidator(validRequest); }).not.to.throw(); }); it('should succeed with email passed', () => { - const validRequest = {email: ['user@example.com']}; + const validRequest = { email: ['user@example.com'] }; expect(() => { return requestValidator(validRequest); }).not.to.throw(); }); it('should succeed with phoneNumber passed', () => { - const validRequest = {phoneNumber: ['+11234567890']}; + const validRequest = { phoneNumber: ['+11234567890'] }; expect(() => { return requestValidator(validRequest); }).not.to.throw(); }); it('should succeed with federatedUserId passed', () => { - const validRequest = {federatedUserId: [{providerId: 'google.com', rawId: 'google_uid'}]}; + const validRequest = { federatedUserId: [{ providerId: 'google.com', rawId: 'google_uid' }] }; expect(() => { return requestValidator(validRequest); }).not.to.throw(); }); it('should fail when neither localId, email or phoneNumber are passed', () => { - const invalidRequest = {bla: ['1234']}; + const invalidRequest = { bla: ['1234'] }; expect(() => { return requestValidator(invalidRequest); }).to.throw(); @@ -420,9 +420,9 @@ describe('FIREBASE_AUTH_GET_ACCOUNTS_INFO', () => { email: ['user1@example.com', 'user2@example.com'], phoneNumber: ['+15555550001', '+15555550002'], federatedUserId: [ - {providerId: 'google.com', rawId: 'google_uid1'}, - {providerId: 'google.com', rawId: 'google_uid2'} - ]}; + { providerId: 'google.com', rawId: 'google_uid1' }, + { providerId: 'google.com', rawId: 'google_uid2' } + ] }; expect(() => { return requestValidator(validRequest); }).not.to.throw(); @@ -431,7 +431,7 @@ describe('FIREBASE_AUTH_GET_ACCOUNTS_INFO', () => { describe('responseValidator', () => { const responseValidator = FIREBASE_AUTH_GET_ACCOUNTS_INFO.getResponseValidator(); it('should succeed with users returned', () => { - const validResponse: object = {users: []}; + const validResponse: object = { users: [] }; expect(() => { return responseValidator(validResponse); }).not.to.throw(); @@ -463,13 +463,13 @@ describe('FIREBASE_AUTH_DELETE_ACCOUNT', () => { describe('requestValidator', () => { const requestValidator = FIREBASE_AUTH_DELETE_ACCOUNT.getRequestValidator(); it('should succeed with localId passed', () => { - const validRequest = {localId: '1234'}; + const validRequest = { localId: '1234' }; expect(() => { return requestValidator(validRequest); }).not.to.throw(); }); it('should fail when localId not passed', () => { - const invalidRequest = {bla: '1234'}; + const invalidRequest = { bla: '1234' }; expect(() => { return requestValidator(invalidRequest); }).to.throw(); @@ -512,7 +512,7 @@ describe('FIREBASE_AUTH_SET_ACCOUNT_INFO', () => { describe('requestValidator', () => { const requestValidator = FIREBASE_AUTH_SET_ACCOUNT_INFO.getRequestValidator(); it('should succeed with valid localId passed', () => { - const validRequest = {localId: '1234'}; + const validRequest = { localId: '1234' }; expect(() => { return requestValidator(validRequest); }).not.to.throw(); @@ -528,7 +528,7 @@ describe('FIREBASE_AUTH_SET_ACCOUNT_INFO', () => { photoUrl: 'http://www.example.com/1234/photo.png', disableUser: false, phoneNumber: '+11234567890', - customAttributes: JSON.stringify({admin: true, groupId: '123'}), + customAttributes: JSON.stringify({ admin: true, groupId: '123' }), validSince: 1476136676, // Pass an unsupported parameter which should be ignored. ignoreMe: 'bla', @@ -546,9 +546,9 @@ describe('FIREBASE_AUTH_SET_ACCOUNT_INFO', () => { }); it('should succeed with valid localId and customAttributes with 1000 char payload', () => { // Test with 1000 characters. - const atLimitClaims = JSON.stringify({key: createRandomString(990)}); + const atLimitClaims = JSON.stringify({ key: createRandomString(990) }); expect(() => { - return requestValidator({localId: '1234', customAttributes: atLimitClaims}); + return requestValidator({ localId: '1234', customAttributes: atLimitClaims }); }).not.to.throw(); }); it('should fail when localId not passed', () => { @@ -561,59 +561,59 @@ describe('FIREBASE_AUTH_SET_ACCOUNT_INFO', () => { describe('called with invalid parameters', () => { it('should fail with invalid localId', () => { expect(() => { - return requestValidator({localId: ''}); + return requestValidator({ localId: '' }); }).to.throw(); expect(isUidSpy).to.have.been.calledOnce.and.calledWith(''); }); it('should fail with invalid displayName', () => { expect(() => { - return requestValidator({localId: '1234', displayName: ['John Doe']}); + return requestValidator({ localId: '1234', displayName: ['John Doe'] }); }).to.throw(); }); it('should fail with invalid email', () => { expect(() => { - return requestValidator({localId: '1234', email: 'invalid'}); + return requestValidator({ localId: '1234', email: 'invalid' }); }).to.throw(); expect(isEmailSpy).to.have.been.calledOnce.and.calledWith('invalid'); }); it('should fail with invalid password', () => { expect(() => { - return requestValidator({localId: '1234', password: 'short'}); + return requestValidator({ localId: '1234', password: 'short' }); }).to.throw(); expect(isPasswordSpy).to.have.been.calledOnce.and.calledWith('short'); }); it('should fail with invalid emailVerified flag', () => { expect(() => { - return requestValidator({localId: '1234', emailVerified: 'yes'}); + return requestValidator({ localId: '1234', emailVerified: 'yes' }); }).to.throw(); }); it('should fail with invalid photoUrl', () => { expect(() => { - return requestValidator({localId: '1234', photoUrl: 'invalid url'}); + return requestValidator({ localId: '1234', photoUrl: 'invalid url' }); }).to.throw(); expect(isUrlSpy).to.have.been.calledOnce.and.calledWith('invalid url'); }); it('should fail with invalid disableUser flag', () => { expect(() => { - return requestValidator({localId: '1234', disableUser: 'no'}); + return requestValidator({ localId: '1234', disableUser: 'no' }); }).to.throw(); }); it('should fail with invalid phoneNumber', () => { expect(() => { - return requestValidator({localId: '1234', phoneNumber: 'invalid'}); + return requestValidator({ localId: '1234', phoneNumber: 'invalid' }); }).to.throw(); expect(isPhoneNumberSpy).to.have.been.calledOnce.and.calledWith('invalid'); }); it('should fail with invalid JSON customAttributes', () => { expect(() => { - return requestValidator({localId: '1234', customAttributes: 'invalid'}); + return requestValidator({ localId: '1234', customAttributes: 'invalid' }); }).to.throw(); }); it('should fail with customAttributes exceeding maximum allowed payload', () => { // Test with 1001 characters. - const largeClaims = JSON.stringify({key: createRandomString(991)}); + const largeClaims = JSON.stringify({ key: createRandomString(991) }); expect(() => { - return requestValidator({localId: '1234', customAttributes: largeClaims}); + return requestValidator({ localId: '1234', customAttributes: largeClaims }); }).to.throw(`Developer claims payload should not exceed 1000 characters.`); }); RESERVED_CLAIMS.forEach((invalidClaim) => { @@ -622,7 +622,7 @@ describe('FIREBASE_AUTH_SET_ACCOUNT_INFO', () => { // Instantiate custom attributes with invalid claims. const claims: {[key: string]: any} = {}; claims[invalidClaim] = 'bla'; - return requestValidator({localId: '1234', customAttributes: JSON.stringify(claims)}); + return requestValidator({ localId: '1234', customAttributes: JSON.stringify(claims) }); }).to.throw(`Developer claim "${invalidClaim}" is reserved and cannot be specified.`); }); }); @@ -632,12 +632,12 @@ describe('FIREBASE_AUTH_SET_ACCOUNT_INFO', () => { sub: 'sub', auth_time: 'time', // eslint-disable-line @typescript-eslint/camelcase }; - return requestValidator({localId: '1234', customAttributes: JSON.stringify(claims)}); + return requestValidator({ localId: '1234', customAttributes: JSON.stringify(claims) }); }).to.throw(`Developer claims "auth_time", "sub" are reserved and cannot be specified.`); }); it('should fail with invalid validSince', () => { expect(() => { - return requestValidator({localId: '1234', validSince: 'invalid'}); + return requestValidator({ localId: '1234', validSince: 'invalid' }); }).to.throw('The tokensValidAfterTime must be a valid UTC number in seconds.'); expect(isNumberSpy).to.have.been.calledOnce.and.calledWith('invalid'); }); @@ -646,7 +646,7 @@ describe('FIREBASE_AUTH_SET_ACCOUNT_INFO', () => { describe('responseValidator', () => { const responseValidator = FIREBASE_AUTH_SET_ACCOUNT_INFO.getResponseValidator(); it('should succeed with localId returned', () => { - const validResponse = {localId: '1234'}; + const validResponse = { localId: '1234' }; expect(() => { return responseValidator(validResponse); }).not.to.throw(); @@ -744,57 +744,57 @@ describe('FIREBASE_AUTH_SIGN_UP_NEW_USER', () => { describe('called with invalid parameters', () => { it('should fail with invalid localId', () => { expect(() => { - return requestValidator({localId: ''}); + return requestValidator({ localId: '' }); }).to.throw(); expect(isUidSpy).to.have.been.calledOnce.and.calledWith(''); }); it('should fail with invalid displayName', () => { expect(() => { - return requestValidator({displayName: ['John Doe']}); + return requestValidator({ displayName: ['John Doe'] }); }).to.throw(); }); it('should fail with invalid email', () => { expect(() => { - return requestValidator({email: 'invalid'}); + return requestValidator({ email: 'invalid' }); }).to.throw(); expect(isEmailSpy).to.have.been.calledOnce.and.calledWith('invalid'); }); it('should fail with invalid password', () => { expect(() => { - return requestValidator({password: 'short'}); + return requestValidator({ password: 'short' }); }).to.throw(); expect(isPasswordSpy).to.have.been.calledOnce.and.calledWith('short'); }); it('should fail with invalid emailVerified flag', () => { expect(() => { - return requestValidator({emailVerified: 'yes'}); + return requestValidator({ emailVerified: 'yes' }); }).to.throw(); }); it('should fail with invalid photoUrl', () => { expect(() => { - return requestValidator({photoUrl: 'invalid url'}); + return requestValidator({ photoUrl: 'invalid url' }); }).to.throw(); expect(isUrlSpy).to.have.been.calledOnce.and.calledWith('invalid url'); }); it('should fail with invalid disabled flag', () => { expect(() => { - return requestValidator({disabled: 'no'}); + return requestValidator({ disabled: 'no' }); }).to.throw(); }); it('should fail with invalid phoneNumber', () => { expect(() => { - return requestValidator({phoneNumber: 'invalid'}); + return requestValidator({ phoneNumber: 'invalid' }); }).to.throw(); expect(isPhoneNumberSpy).to.have.been.calledOnce.and.calledWith('invalid'); }); it('should fail with customAttributes', () => { expect(() => { - return requestValidator({customAttributes: JSON.stringify({admin: true})}); + return requestValidator({ customAttributes: JSON.stringify({ admin: true }) }); }).to.throw(); }); it('should fail with validSince', () => { expect(() => { - return requestValidator({validSince: 1476136676}); + return requestValidator({ validSince: 1476136676 }); }).to.throw(); }); }); @@ -802,7 +802,7 @@ describe('FIREBASE_AUTH_SIGN_UP_NEW_USER', () => { describe('responseValidator', () => { const responseValidator = FIREBASE_AUTH_SIGN_UP_NEW_USER.getResponseValidator(); it('should succeed with localId returned', () => { - const validResponse = {localId: '1234'}; + const validResponse = { localId: '1234' }; expect(() => { return responseValidator(validResponse); }).not.to.throw(); @@ -897,7 +897,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const expectedResult = utils.responseFrom({ sessionCookie: 'SESSION_COOKIE', }); - const data = {idToken: 'ID_TOKEN', validDuration: durationInMs / 1000}; + const data = { idToken: 'ID_TOKEN', validDuration: durationInMs / 1000 }; const stub = sinon.stub(HttpClient.prototype, 'send').resolves(expectedResult); stubs.push(stub); @@ -913,7 +913,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { sessionCookie: 'SESSION_COOKIE', }); const durationAtLimitInMs = 14 * 24 * 60 * 60 * 1000; - const data = {idToken: 'ID_TOKEN', validDuration: durationAtLimitInMs / 1000}; + const data = { idToken: 'ID_TOKEN', validDuration: durationAtLimitInMs / 1000 }; const stub = sinon.stub(HttpClient.prototype, 'send').resolves(expectedResult); stubs.push(stub); @@ -929,7 +929,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { sessionCookie: 'SESSION_COOKIE', }); const durationAtLimitInMs = 5 * 60 * 1000; - const data = {idToken: 'ID_TOKEN', validDuration: durationAtLimitInMs / 1000}; + const data = { idToken: 'ID_TOKEN', validDuration: durationAtLimitInMs / 1000 }; const stub = sinon.stub(HttpClient.prototype, 'send').resolves(expectedResult); stubs.push(stub); @@ -1001,7 +1001,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { }, }); const expectedError = new FirebaseAuthError(AuthClientErrorCode.INVALID_ID_TOKEN); - const data = {idToken: 'invalid-token', validDuration: durationInMs / 1000}; + const data = { idToken: 'invalid-token', validDuration: durationInMs / 1000 }; const stub = sinon.stub(HttpClient.prototype, 'send').rejects(expectedResult); stubs.push(stub); @@ -1022,10 +1022,10 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { it('should be fulfilled given a valid email', () => { const expectedResult = utils.responseFrom({ users : [ - {email: 'user@example.com'}, + { email: 'user@example.com' }, ], }); - const data = {email: ['user@example.com']}; + const data = { email: ['user@example.com'] }; const stub = sinon.stub(HttpClient.prototype, 'send').resolves(expectedResult); stubs.push(stub); @@ -1047,7 +1047,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { kind: 'identitytoolkit#GetAccountInfoResponse', }); const expectedError = new FirebaseAuthError(AuthClientErrorCode.USER_NOT_FOUND); - const data = {email: ['user@example.com']}; + const data = { email: ['user@example.com'] }; const stub = sinon.stub(HttpClient.prototype, 'send').resolves(expectedResult); stubs.push(stub); @@ -1068,10 +1068,10 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { it('should be fulfilled given a valid localId', () => { const expectedResult = utils.responseFrom({ users : [ - {localId: 'uid'}, + { localId: 'uid' }, ], }); - const data = {localId: ['uid']}; + const data = { localId: ['uid'] }; const stub = sinon.stub(HttpClient.prototype, 'send').resolves(expectedResult); stubs.push(stub); @@ -1087,7 +1087,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { kind: 'identitytoolkit#GetAccountInfoResponse', }); const expectedError = new FirebaseAuthError(AuthClientErrorCode.USER_NOT_FOUND); - const data = {localId: ['uid']}; + const data = { localId: ['uid'] }; const stub = sinon.stub(HttpClient.prototype, 'send').resolves(expectedResult); stubs.push(stub); @@ -1107,7 +1107,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { }, }); const expectedError = FirebaseAuthError.fromServerError('OPERATION_NOT_ALLOWED'); - const data = {localId: ['uid']}; + const data = { localId: ['uid'] }; const stub = sinon.stub(HttpClient.prototype, 'send').rejects(expectedResult); stubs.push(stub); @@ -1199,7 +1199,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { it('should throw when given more than 100 identifiers', () => { const identifiers: UserIdentifier[] = []; for (let i = 0; i < 101; i++) { - identifiers.push({uid: 'id' + i}); + identifiers.push({ uid: 'id' + i }); } const requestHandler = handler.init(mockApp); @@ -1212,7 +1212,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.getAccountInfoByIdentifiers([]) .then((getUsersResult) => { - expect(getUsersResult).to.deep.equal({users: []}); + expect(getUsersResult).to.deep.equal({ users: [] }); }); }); @@ -1222,7 +1222,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { stubs.push(stub); const requestHandler = handler.init(mockApp); - const notFoundIds = [{uid: 'id that doesnt exist'}]; + const notFoundIds = [{ uid: 'id that doesnt exist' }]; return requestHandler.getAccountInfoByIdentifiers(notFoundIds) .then((getUsersResult) => { expect(getUsersResult).to.deep.equal({ users: [] }); @@ -1231,39 +1231,39 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { it('should throw when given an invalid uid', () => { const requestHandler = handler.init(mockApp); - expect(() => requestHandler.getAccountInfoByIdentifiers([{uid: 'too long ' + ('.' as any).repeat(128)}])) + expect(() => requestHandler.getAccountInfoByIdentifiers([{ uid: 'too long ' + ('.' as any).repeat(128) }])) .to.throw(FirebaseAuthError) .with.property('code', 'auth/invalid-uid'); }); it('should throw when given an invalid email', () => { const requestHandler = handler.init(mockApp); - expect(() => requestHandler.getAccountInfoByIdentifiers([{email: 'invalid email addr'}])) + expect(() => requestHandler.getAccountInfoByIdentifiers([{ email: 'invalid email addr' }])) .to.throw(FirebaseAuthError) .with.property('code', 'auth/invalid-email'); }); it('should throw when given an invalid phone number', () => { const requestHandler = handler.init(mockApp); - expect(() => requestHandler.getAccountInfoByIdentifiers([{phoneNumber: 'invalid phone number'}])) + expect(() => requestHandler.getAccountInfoByIdentifiers([{ phoneNumber: 'invalid phone number' }])) .to.throw(FirebaseAuthError) .with.property('code', 'auth/invalid-phone-number'); }); it('should throw when given an invalid provider', () => { const requestHandler = handler.init(mockApp); - expect(() => requestHandler.getAccountInfoByIdentifiers([{providerUid: '', providerId: ''}])) + expect(() => requestHandler.getAccountInfoByIdentifiers([{ providerUid: '', providerId: '' }])) .to.throw(FirebaseAuthError) .with.property('code', 'auth/invalid-provider-id'); }); it('should throw when given a single bad identifier', () => { const identifiers: UserIdentifier[] = [ - {uid: 'valid_id1'}, - {uid: 'valid_id2'}, - {uid: 'invalid id; too long. ' + ('.' as any).repeat(128)}, - {uid: 'valid_id4'}, - {uid: 'valid_id5'}, + { uid: 'valid_id1' }, + { uid: 'valid_id2' }, + { uid: 'invalid id; too long. ' + ('.' as any).repeat(128) }, + { uid: 'valid_id4' }, + { uid: 'valid_id5' }, ]; const requestHandler = handler.init(mockApp); @@ -1355,7 +1355,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { }, ], }, - customClaims: {admin: true}, + customClaims: { admin: true }, // Tenant ID accepted on user batch upload. tenantId, }, @@ -1365,7 +1365,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { passwordHash: Buffer.from('userpass'), passwordSalt: Buffer.from('NaCl'), }, - {uid: '5678', phoneNumber: '+16505550101'}, + { uid: '5678', phoneNumber: '+16505550101' }, ]; const options = { hash: { @@ -1489,8 +1489,8 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { it('should resolve with expected result on underlying API partial succcess', () => { const expectedResult = utils.responseFrom({ error: [ - {index: 0, message: 'Some error occurred'}, - {index: 1, message: 'Another error occurred'}, + { index: 0, message: 'Some error occurred' }, + { index: 1, message: 'Another error occurred' }, ], }); const stub = sinon.stub(HttpClient.prototype, 'send').resolves(expectedResult); @@ -1509,15 +1509,15 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { it('should resolve without underlying API call when users are processed client side', () => { // These users should fail to upload due to invalid phone number and email fields. const testUsers = [ - {uid: '1234', phoneNumber: 'invalid'}, - {uid: '5678', email: 'invalid'}, + { uid: '1234', phoneNumber: 'invalid' }, + { uid: '5678', email: 'invalid' }, ] as any; const expectedResult = { successCount: 0, failureCount: 2, errors: [ - {index: 0, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_PHONE_NUMBER)}, - {index: 1, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_EMAIL)}, + { index: 0, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_PHONE_NUMBER) }, + { index: 1, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_EMAIL) }, ], }; const stub = sinon.stub(HttpClient.prototype, 'send'); @@ -1533,33 +1533,33 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { it('should validate underlying users and resolve with expected errors', () => { const testUsers = [ - {uid: 'user1', displayName: false}, - {uid: 123}, - {uid: 'user2', email: 'invalid'}, - {uid: 'user3', phoneNumber: 'invalid'}, - {uid: 'user4', emailVerified: 'invalid'}, - {uid: 'user5', photoURL: 'invalid'}, - {uid: 'user6', disabled: 'invalid'}, - {uid: 'user7', metadata: {creationTime: 'invalid'}}, - {uid: 'user8', metadata: {lastSignInTime: 'invalid'}}, - {uid: 'user9', customClaims: {admin: true, aud: 'bla'}}, - {uid: 'user10', email: 'user10@example.com', passwordHash: 'invalid'}, - {uid: 'user11', email: 'user11@example.com', passwordSalt: 'invalid'}, - {uid: 'user12', providerData: [{providerId: 'google.com'}]}, + { uid: 'user1', displayName: false }, + { uid: 123 }, + { uid: 'user2', email: 'invalid' }, + { uid: 'user3', phoneNumber: 'invalid' }, + { uid: 'user4', emailVerified: 'invalid' }, + { uid: 'user5', photoURL: 'invalid' }, + { uid: 'user6', disabled: 'invalid' }, + { uid: 'user7', metadata: { creationTime: 'invalid' } }, + { uid: 'user8', metadata: { lastSignInTime: 'invalid' } }, + { uid: 'user9', customClaims: { admin: true, aud: 'bla' } }, + { uid: 'user10', email: 'user10@example.com', passwordHash: 'invalid' }, + { uid: 'user11', email: 'user11@example.com', passwordSalt: 'invalid' }, + { uid: 'user12', providerData: [{ providerId: 'google.com' }] }, { uid: 'user13', - providerData: [{providerId: 'google.com', uid: 'RAW_ID', displayName: false}], + providerData: [{ providerId: 'google.com', uid: 'RAW_ID', displayName: false }], }, { uid: 'user14', - providerData: [{providerId: 'google.com', uid: 'RAW_ID', email: 'invalid'}], + providerData: [{ providerId: 'google.com', uid: 'RAW_ID', email: 'invalid' }], }, { uid: 'user15', - providerData: [{providerId: 'google.com', uid: 'RAW_ID', photoURL: 'invalid'}], + providerData: [{ providerId: 'google.com', uid: 'RAW_ID', photoURL: 'invalid' }], }, - {uid: 'user16', providerData: [{}]}, - {email: 'user17@example.com'}, + { uid: 'user16', providerData: [{}] }, + { email: 'user17@example.com' }, { uid: 'user18', email: 'user18@example.com', @@ -1644,15 +1644,15 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { successCount: 0, failureCount: testUsers.length, errors: [ - {index: 0, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_DISPLAY_NAME)}, - {index: 1, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_UID)}, - {index: 2, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_EMAIL)}, - {index: 3, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_PHONE_NUMBER)}, - {index: 4, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_EMAIL_VERIFIED)}, - {index: 5, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_PHOTO_URL)}, - {index: 6, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_DISABLED_FIELD)}, - {index: 7, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_CREATION_TIME)}, - {index: 8, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_LAST_SIGN_IN_TIME)}, + { index: 0, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_DISPLAY_NAME) }, + { index: 1, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_UID) }, + { index: 2, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_EMAIL) }, + { index: 3, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_PHONE_NUMBER) }, + { index: 4, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_EMAIL_VERIFIED) }, + { index: 5, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_PHOTO_URL) }, + { index: 6, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_DISABLED_FIELD) }, + { index: 7, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_CREATION_TIME) }, + { index: 8, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_LAST_SIGN_IN_TIME) }, { index: 9, error: new FirebaseAuthError( @@ -1660,8 +1660,8 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { `Developer claim "aud" is reserved and cannot be specified.`, ), }, - {index: 10, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_PASSWORD_HASH)}, - {index: 11, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_PASSWORD_SALT)}, + { index: 10, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_PASSWORD_HASH) }, + { index: 11, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_PASSWORD_SALT) }, { index: 12, error: new FirebaseAuthError( @@ -1690,8 +1690,8 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { `The provider "photoURL" for "google.com" must be a valid URL string.`, ), }, - {index: 16, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_PROVIDER_ID)}, - {index: 17, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_UID)}, + { index: 16, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_PROVIDER_ID) }, + { index: 17, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_UID) }, { index: 18, error: new FirebaseAuthError( @@ -1776,8 +1776,8 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const maxResults = 500; const expectedResult = utils.responseFrom({ users : [ - {localId: 'uid1'}, - {localId: 'uid2'}, + { localId: 'uid1' }, + { localId: 'uid2' }, ], nextPageToken: 'NEXT_PAGE_TOKEN', }); @@ -1808,7 +1808,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.downloadAccount(maxResults, nextPageToken) .then((result) => { - expect(result).to.deep.equal({users: []}); + expect(result).to.deep.equal({ users: [] }); expect(stub).to.have.been.calledOnce.and.calledWith(callParams(path, method, data)); }); }); @@ -1887,7 +1887,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const expectedResult = utils.responseFrom({ kind: 'identitytoolkit#DeleteAccountResponse', }); - const data = {localId: 'uid'}; + const data = { localId: 'uid' }; const stub = sinon.stub(HttpClient.prototype, 'send').resolves(expectedResult); stubs.push(stub); @@ -1905,7 +1905,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { }, }); const expectedError = FirebaseAuthError.fromServerError('OPERATION_NOT_ALLOWED'); - const data = {localId: 'uid'}; + const data = { localId: 'uid' }; const stub = sinon.stub(HttpClient.prototype, 'send').rejects(expectedResult); stubs.push(stub); @@ -1953,7 +1953,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { it('should be fulfilled given valid uids', async () => { const expectedResult = utils.responseFrom({}); - const data = {localIds: ['uid1', 'uid2', 'uid3'], force: true}; + const data = { localIds: ['uid1', 'uid2', 'uid3'], force: true }; const stub = sinon.stub(HttpClient.prototype, 'send').resolves(expectedResult); stubs.push(stub); @@ -2080,7 +2080,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { expect(returnedUid).to.be.equal(uid); // Confirm expected rpc request parameters sent. expect(stub).to.have.been.calledOnce.and.calledWith( - callParams(path, method, {localId: uid})); + callParams(path, method, { localId: uid })); }); }); @@ -2161,7 +2161,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); // Send update request to delete enrolled factors. - return requestHandler.updateExistingAccount(uid, {multiFactor: {enrolledFactors: null}}) + return requestHandler.updateExistingAccount(uid, { multiFactor: { enrolledFactors: null } }) .then((returnedUid: string) => { // uid should be returned. expect(returnedUid).to.be.equal(uid); @@ -2183,7 +2183,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); // Send update request to delete enrolled factors. - return requestHandler.updateExistingAccount(uid, {multiFactor: {enrolledFactors: []}}) + return requestHandler.updateExistingAccount(uid, { multiFactor: { enrolledFactors: [] } }) .then((returnedUid: string) => { // uid should be returned. expect(returnedUid).to.be.equal(uid); @@ -2355,7 +2355,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const path = handler.path('v1', '/accounts:update', 'project_id'); const method = 'POST'; const uid = '12345678'; - const claims = {admin: true, groupId: '1234'}; + const claims = { admin: true, groupId: '1234' }; const expectedValidData = { localId: uid, customAttributes: JSON.stringify(claims), @@ -2440,7 +2440,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { `Developer claim "aud" is reserved and cannot be specified.`, ); const requestHandler = handler.init(mockApp); - const blacklistedClaims = {admin: true, aud: 'bla'}; + const blacklistedClaims = { admin: true, aud: 'bla' }; // Send request with blacklisted claims. return requestHandler.setCustomUserClaims(uid, blacklistedClaims) .then(() => { @@ -2513,7 +2513,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { it('should be rejected given an invalid uid', () => { const expectedError = new FirebaseAuthError(AuthClientErrorCode.INVALID_UID); - const invalidUid: any = {localId: uid}; + const invalidUid: any = { localId: uid }; const requestHandler = handler.init(mockApp); return requestHandler.revokeRefreshTokens(invalidUid as any) @@ -2623,7 +2623,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); // Send empty create new account request with only a uid provided. - return requestHandler.createNewAccount({uid}) + return requestHandler.createNewAccount({ uid }) .then((returnedUid: string) => { // uid should be returned. expect(returnedUid).to.be.equal(uid); @@ -2679,7 +2679,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); // Send create new account request with no enrolled factors. - const request: any = {uid, multiFactor: {enrolledFactors: null}}; + const request: any = { uid, multiFactor: { enrolledFactors: null } }; return requestHandler.createNewAccount(request) .then((returnedUid: string) => { // uid should be returned. @@ -3139,7 +3139,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { }, expectedActionCodeSettingsRequest); // Simulate response missing link. const stub = sinon.stub(HttpClient.prototype, 'send') - .resolves(utils.responseFrom({email})); + .resolves(utils.responseFrom({ email })); stubs.push(stub); const requestHandler = handler.init(mockApp); @@ -3245,8 +3245,8 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const maxResults = 50; const expectedResult = utils.responseFrom({ oauthIdpConfigs : [ - {name: 'projects/project1/oauthIdpConfigs/oidc.provider1'}, - {name: 'projects/project1/oauthIdpConfigs/oidc.provider2'}, + { name: 'projects/project1/oauthIdpConfigs/oidc.provider1' }, + { name: 'projects/project1/oauthIdpConfigs/oidc.provider2' }, ], nextPageToken: 'NEXT_PAGE_TOKEN', }); @@ -3279,7 +3279,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.listOAuthIdpConfigs(maxResults, nextPageToken) .then((result) => { - expect(result).to.deep.equal({oauthIdpConfigs: []}); + expect(result).to.deep.equal({ oauthIdpConfigs: [] }); expect(stub).to.have.been.calledOnce.and.calledWith( callParams(path, expectedHttpMethod, data)); }); @@ -3737,8 +3737,8 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const maxResults = 50; const expectedResult = utils.responseFrom({ inboundSamlConfigs : [ - {name: 'projects/project1/inboundSamlConfigs/saml.provider1'}, - {name: 'projects/project1/inboundSamlConfigs/saml.provider2'}, + { name: 'projects/project1/inboundSamlConfigs/saml.provider1' }, + { name: 'projects/project1/inboundSamlConfigs/saml.provider2' }, ], nextPageToken: 'NEXT_PAGE_TOKEN', }); @@ -3770,7 +3770,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp); return requestHandler.listInboundSamlConfigs(maxResults, nextPageToken) .then((result) => { - expect(result).to.deep.equal({inboundSamlConfigs: []}); + expect(result).to.deep.equal({ inboundSamlConfigs: [] }); expect(stub).to.have.been.calledOnce.and.calledWith(callParams(path, expectedHttpMethod, data)); }); }); @@ -3922,8 +3922,8 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { ssoUrl: 'https://example.com/login', signRequest: true, idpCertificates: [ - {x509Certificate: 'CERT1'}, - {x509Certificate: 'CERT2'}, + { x509Certificate: 'CERT1' }, + { x509Certificate: 'CERT2' }, ], }, spConfig: { @@ -4029,8 +4029,8 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { ssoUrl: 'https://example.com/login', signRequest: true, idpCertificates: [ - {x509Certificate: 'CERT1'}, - {x509Certificate: 'CERT2'}, + { x509Certificate: 'CERT1' }, + { x509Certificate: 'CERT2' }, ], }, spConfig: { @@ -4051,8 +4051,8 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { ssoUrl: 'https://example.com/login2', signRequest: true, idpCertificates: [ - {x509Certificate: 'CERT1'}, - {x509Certificate: 'CERT2'}, + { x509Certificate: 'CERT1' }, + { x509Certificate: 'CERT2' }, ], }, spConfig: { @@ -4280,8 +4280,8 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const maxResults = 500; const expectedResult = utils.responseFrom({ tenants : [ - {name: 'projects/project_id/tenants/tenant-id1'}, - {name: 'projects/project_id/tenants/tenant-id2'}, + { name: 'projects/project_id/tenants/tenant-id1' }, + { name: 'projects/project_id/tenants/tenant-id2' }, ], nextPageToken: 'NEXT_PAGE_TOKEN', }); @@ -4313,7 +4313,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { const requestHandler = handler.init(mockApp) as AuthRequestHandler; return requestHandler.listTenants(maxResults, nextPageToken) .then((result) => { - expect(result).to.deep.equal({tenants: []}); + expect(result).to.deep.equal({ tenants: [] }); expect(stub).to.have.been.calledOnce.and.calledWith(callParams(path, method, data)); }); }); @@ -4516,7 +4516,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { ); // Resource name should have /tenants/tenant-id in path. This should throw an error. const stub = sinon.stub(HttpClient.prototype, 'send') - .resolves(utils.responseFrom({name: 'projects/project_id'})); + .resolves(utils.responseFrom({ name: 'projects/project_id' })); stubs.push(stub); const requestHandler = handler.init(mockApp) as AuthRequestHandler; @@ -4595,7 +4595,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { allowPasswordSignup: true, }; const partialTenantOptions = { - emailSignInConfig: {enabled: true}, + emailSignInConfig: { enabled: true }, }; stubs.push(stub); @@ -4688,7 +4688,7 @@ AUTH_REQUEST_HANDLER_TESTS.forEach((handler) => { ); // Resource name should have /tenants/tenant-id in path. This should throw an error. const stub = sinon.stub(HttpClient.prototype, 'send') - .resolves(utils.responseFrom({name: 'projects/project_id'})); + .resolves(utils.responseFrom({ name: 'projects/project_id' })); stubs.push(stub); const requestHandler = handler.init(mockApp) as AuthRequestHandler; diff --git a/test/unit/auth/auth-config.spec.ts b/test/unit/auth/auth-config.spec.ts index d5777d787d..d74a6c9666 100755 --- a/test/unit/auth/auth-config.spec.ts +++ b/test/unit/auth/auth-config.spec.ts @@ -19,7 +19,7 @@ import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; import * as chaiAsPromised from 'chai-as-promised'; -import {deepCopy} from '../../../src/utils/deep-copy'; +import { deepCopy } from '../../../src/utils/deep-copy'; import { OIDCConfig, SAMLConfig, SAMLConfigServerRequest, SAMLConfigServerResponse, OIDCConfigServerRequest, @@ -159,8 +159,8 @@ describe('SAMLConfig', () => { ssoUrl: 'https://example.com/login', signRequest: true, idpCertificates: [ - {x509Certificate: 'CERT1'}, - {x509Certificate: 'CERT2'}, + { x509Certificate: 'CERT1' }, + { x509Certificate: 'CERT2' }, ], }, spConfig: { @@ -177,8 +177,8 @@ describe('SAMLConfig', () => { ssoUrl: 'https://example.com/login', signRequest: true, idpCertificates: [ - {x509Certificate: 'CERT1'}, - {x509Certificate: 'CERT2'}, + { x509Certificate: 'CERT1' }, + { x509Certificate: 'CERT2' }, ], }, spConfig: { @@ -347,7 +347,7 @@ describe('SAMLConfig', () => { .to.throw('"SAMLAuthProviderConfig.providerId" must be a valid non-empty string prefixed with "saml.".'); }); - const nonAuthConfigOptions = [null, undefined, {}, {other: 'value'}]; + const nonAuthConfigOptions = [null, undefined, {}, { other: 'value' }]; nonAuthConfigOptions.forEach((nonAuthConfig) => { it('should return null when no AuthConfig is provided: ' + JSON.stringify(nonAuthConfig), () => { expect(SAMLConfig.buildServerRequest(nonAuthConfig as any)) @@ -645,7 +645,7 @@ describe('OIDCConfig', () => { .to.throw('"OIDCAuthProviderConfig.providerId" must be a valid non-empty string prefixed with "oidc.".'); }); - const nonAuthConfigOptions = [null, undefined, {}, {other: 'value'}]; + const nonAuthConfigOptions = [null, undefined, {}, { other: 'value' }]; nonAuthConfigOptions.forEach((nonAuthConfig) => { it('should return null when no AuthConfig is provided: ' + JSON.stringify(nonAuthConfig), () => { expect(OIDCConfig.buildServerRequest(nonAuthConfig as any)).to.be.null; diff --git a/test/unit/auth/auth.spec.ts b/test/unit/auth/auth.spec.ts index b869580c1f..0d211a718d 100755 --- a/test/unit/auth/auth.spec.ts +++ b/test/unit/auth/auth.spec.ts @@ -26,13 +26,13 @@ import * as chaiAsPromised from 'chai-as-promised'; import * as utils from '../utils'; import * as mocks from '../../resources/mocks'; -import {Auth, TenantAwareAuth, BaseAuth, DecodedIdToken} from '../../../src/auth/auth'; -import {UserRecord, UpdateRequest} from '../../../src/auth/user-record'; -import {FirebaseApp} from '../../../src/firebase-app'; +import { Auth, TenantAwareAuth, BaseAuth, DecodedIdToken } from '../../../src/auth/auth'; +import { UserRecord, UpdateRequest } from '../../../src/auth/user-record'; +import { FirebaseApp } from '../../../src/firebase-app'; import { AuthRequestHandler, TenantAwareAuthRequestHandler, AbstractAuthRequestHandler, } from '../../../src/auth/auth-api-request'; -import {AuthClientErrorCode, FirebaseAuthError} from '../../../src/utils/error'; +import { AuthClientErrorCode, FirebaseAuthError } from '../../../src/utils/error'; import * as validator from '../../../src/utils/validator'; import { FirebaseTokenVerifier } from '../../../src/auth/token-verifier'; @@ -40,7 +40,7 @@ import { AuthProviderConfigFilter, OIDCConfig, SAMLConfig, OIDCConfigServerResponse, SAMLConfigServerResponse, } from '../../../src/auth/auth-config'; -import {deepCopy} from '../../../src/utils/deep-copy'; +import { deepCopy } from '../../../src/utils/deep-copy'; import { TenantManager } from '../../../src/auth/tenant-manager'; import { ServiceAccountCredential } from '../../../src/auth/credential'; import { HttpClient } from '../../../src/utils/api-request'; @@ -220,8 +220,8 @@ function getSAMLConfigServerResponse(providerId: string): SAMLConfigServerRespon ssoUrl: 'https://example.com/login', signRequest: true, idpCertificates: [ - {x509Certificate: 'CERT1'}, - {x509Certificate: 'CERT2'}, + { x509Certificate: 'CERT1' }, + { x509Certificate: 'CERT2' }, ], }, spConfig: { @@ -353,7 +353,7 @@ AUTH_CONFIGS.forEach((testConfig) => { describe('createCustomToken()', () => { it('should return a jwt', async () => { const token = await auth.createCustomToken('uid1'); - const decodedToken = jwt.decode(token, {complete: true}); + const decodedToken = jwt.decode(token, { complete: true }); expect(decodedToken).to.have.property('header').that.has.property('typ', 'JWT'); }); @@ -1171,7 +1171,7 @@ AUTH_CONFIGS.forEach((testConfig) => { const stub = sinon.stub(testConfig.RequestHandler.prototype, 'getAccountInfoByIdentifiers') .resolves({}); stubs.push(stub); - const notFoundIds = [{uid: 'id that doesnt exist'}]; + const notFoundIds = [{ uid: 'id that doesnt exist' }]; return auth.getUsers(notFoundIds) .then((getUsersResult) => { expect(getUsersResult.users).to.deep.equal([]); @@ -1203,7 +1203,7 @@ AUTH_CONFIGS.forEach((testConfig) => { }]; const stub = sinon.stub(testConfig.RequestHandler.prototype, 'getAccountInfoByIdentifiers') - .resolves({users: mockUsers}); + .resolves({ users: mockUsers }); stubs.push(stub); const users = await auth.getUsers([ @@ -1215,13 +1215,13 @@ AUTH_CONFIGS.forEach((testConfig) => { ]); expect(users.users).to.have.deep.members(mockUsers.map((u) => new UserRecord(u))); - expect(users.notFound).to.have.deep.members([{uid: 'this-user-doesnt-exist'}]); + expect(users.notFound).to.have.deep.members([{ uid: 'this-user-doesnt-exist' }]); }); }); describe('deleteUser()', () => { const uid = 'abcdefghijklmnopqrstuvwxyz'; - const expectedDeleteAccountResult = {kind: 'identitytoolkit#DeleteAccountResponse'}; + const expectedDeleteAccountResult = { kind: 'identitytoolkit#DeleteAccountResponse' }; const expectedError = new FirebaseAuthError(AuthClientErrorCode.USER_NOT_FOUND); // Stubs used to simulate underlying api calls. @@ -1732,17 +1732,17 @@ AUTH_CONFIGS.forEach((testConfig) => { const maxResult = 500; const downloadAccountResponse: any = { users: [ - {localId: 'UID1'}, - {localId: 'UID2'}, - {localId: 'UID3'}, + { localId: 'UID1' }, + { localId: 'UID2' }, + { localId: 'UID3' }, ], nextPageToken: 'NEXT_PAGE_TOKEN', }; const expectedResult: any = { users: [ - new UserRecord({localId: 'UID1'}), - new UserRecord({localId: 'UID2'}), - new UserRecord({localId: 'UID3'}), + new UserRecord({ localId: 'UID1' }), + new UserRecord({ localId: 'UID2' }), + new UserRecord({ localId: 'UID3' }), ], pageToken: 'NEXT_PAGE_TOKEN', }; @@ -1949,8 +1949,8 @@ AUTH_CONFIGS.forEach((testConfig) => { describe('importUsers()', () => { const users = [ - {uid: '1234', email: 'user@example.com', passwordHash: Buffer.from('password')}, - {uid: '5678', phoneNumber: 'invalid'}, + { uid: '1234', email: 'user@example.com', passwordHash: Buffer.from('password') }, + { uid: '5678', phoneNumber: 'invalid' }, ]; const options = { hash: { @@ -2034,7 +2034,7 @@ AUTH_CONFIGS.forEach((testConfig) => { .throws(expectedOptionsError); stubs.push(uploadAccountStub); expect(() => { - return auth.importUsers(users, {hash: {algorithm: 'invalid' as any}}); + return auth.importUsers(users, { hash: { algorithm: 'invalid' as any } }); }).to.throw(expectedOptionsError); }); @@ -2072,7 +2072,7 @@ AUTH_CONFIGS.forEach((testConfig) => { describe('createSessionCookie()', () => { const tenantId = testConfig.supportsTenantManagement ? undefined : TENANT_ID; const idToken = 'ID_TOKEN'; - const options = {expiresIn: 60 * 60 * 24 * 1000}; + const options = { expiresIn: 60 * 60 * 24 * 1000 }; const sessionCookie = 'SESSION_COOKIE'; const expectedError = new FirebaseAuthError(AuthClientErrorCode.INVALID_ID_TOKEN); const expectedUserRecord = getValidUserRecord(getValidGetAccountInfoResponse(tenantId)); @@ -2138,7 +2138,7 @@ AUTH_CONFIGS.forEach((testConfig) => { stubs.push(sinon.stub(testConfig.Auth.prototype, 'verifyIdToken') .returns(Promise.resolve(decodedIdToken))); // 1 minute duration. - const invalidOptions = {expiresIn: 60 * 1000}; + const invalidOptions = { expiresIn: 60 * 1000 }; return auth.createSessionCookie(idToken, invalidOptions) .should.eventually.be.rejected.and.have.property( 'code', 'auth/invalid-session-cookie-duration'); @@ -2234,9 +2234,9 @@ AUTH_CONFIGS.forEach((testConfig) => { }); const emailActionFlows: EmailActionTest[] = [ - {api: 'generatePasswordResetLink', requestType: 'PASSWORD_RESET', requiresSettings: false}, - {api: 'generateEmailVerificationLink', requestType: 'VERIFY_EMAIL', requiresSettings: false}, - {api: 'generateSignInWithEmailLink', requestType: 'EMAIL_SIGNIN', requiresSettings: true}, + { api: 'generatePasswordResetLink', requestType: 'PASSWORD_RESET', requiresSettings: false }, + { api: 'generateEmailVerificationLink', requestType: 'VERIFY_EMAIL', requiresSettings: false }, + { api: 'generateSignInWithEmailLink', requestType: 'EMAIL_SIGNIN', requiresSettings: true }, ]; emailActionFlows.forEach((emailActionFlow) => { describe(`${emailActionFlow.api}()`, () => { @@ -2448,8 +2448,8 @@ AUTH_CONFIGS.forEach((testConfig) => { ssoUrl: 'https://example.com/login', signRequest: true, idpCertificates: [ - {x509Certificate: 'CERT1'}, - {x509Certificate: 'CERT2'}, + { x509Certificate: 'CERT1' }, + { x509Certificate: 'CERT2' }, ], }, spConfig: { @@ -2584,7 +2584,7 @@ AUTH_CONFIGS.forEach((testConfig) => { .stub(testConfig.RequestHandler.prototype, 'listOAuthIdpConfigs') .resolves(listConfigsResponse); stubs.push(listConfigsStub); - return (auth as Auth).listProviderConfigs({type: 'oidc'}) + return (auth as Auth).listProviderConfigs({ type: 'oidc' }) .then((response) => { expect(response).to.deep.equal(expectedResult); // Confirm underlying API called with expected parameters. @@ -2679,7 +2679,7 @@ AUTH_CONFIGS.forEach((testConfig) => { .stub(testConfig.RequestHandler.prototype, 'listInboundSamlConfigs') .resolves(listConfigsResponse); stubs.push(listConfigsStub); - return (auth as Auth).listProviderConfigs({type: 'saml'}) + return (auth as Auth).listProviderConfigs({ type: 'saml' }) .then((response) => { expect(response).to.deep.equal(expectedResult); // Confirm underlying API called with expected parameters. @@ -2966,8 +2966,8 @@ AUTH_CONFIGS.forEach((testConfig) => { ssoUrl: 'https://example.com/login', signRequest: true, idpCertificates: [ - {x509Certificate: 'CERT1'}, - {x509Certificate: 'CERT2'}, + { x509Certificate: 'CERT1' }, + { x509Certificate: 'CERT2' }, ], }, spConfig: { @@ -3133,8 +3133,8 @@ AUTH_CONFIGS.forEach((testConfig) => { ssoUrl: 'https://example.com/login', signRequest: true, idpCertificates: [ - {x509Certificate: 'CERT1'}, - {x509Certificate: 'CERT2'}, + { x509Certificate: 'CERT1' }, + { x509Certificate: 'CERT2' }, ], }, spConfig: { diff --git a/test/unit/auth/credential.spec.ts b/test/unit/auth/credential.spec.ts index 881dcb7525..dc66ae317b 100644 --- a/test/unit/auth/credential.spec.ts +++ b/test/unit/auth/credential.spec.ts @@ -35,7 +35,7 @@ import { ComputeEngineCredential, getApplicationDefault, isApplicationDefault, Credential, } from '../../../src/auth/credential'; import { HttpClient } from '../../../src/utils/api-request'; -import {Agent} from 'https'; +import { Agent } from 'https'; import { FirebaseAppError } from '../../../src/utils/error'; chai.should(); @@ -325,7 +325,7 @@ describe('Credential', () => { expect(httpStub).to.have.been.calledOnce.and.calledWith({ method: 'GET', url: 'http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token', - headers: {'Metadata-Flavor': 'Google'}, + headers: { 'Metadata-Flavor': 'Google' }, httpAgent: undefined, }); }); @@ -342,7 +342,7 @@ describe('Credential', () => { expect(httpStub).to.have.been.calledOnce.and.calledWith({ method: 'GET', url: 'http://metadata.google.internal/computeMetadata/v1/project/project-id', - headers: {'Metadata-Flavor': 'Google'}, + headers: { 'Metadata-Flavor': 'Google' }, httpAgent: undefined, }); }); @@ -364,7 +364,7 @@ describe('Credential', () => { expect(httpStub).to.have.been.calledOnce.and.calledWith({ method: 'GET', url: 'http://metadata.google.internal/computeMetadata/v1/project/project-id', - headers: {'Metadata-Flavor': 'Google'}, + headers: { 'Metadata-Flavor': 'Google' }, httpAgent: undefined, }); }); diff --git a/test/unit/auth/tenant-manager.spec.ts b/test/unit/auth/tenant-manager.spec.ts index 82f89599d9..6a578323d9 100644 --- a/test/unit/auth/tenant-manager.spec.ts +++ b/test/unit/auth/tenant-manager.spec.ts @@ -23,11 +23,11 @@ import * as sinonChai from 'sinon-chai'; import * as chaiAsPromised from 'chai-as-promised'; import * as mocks from '../../resources/mocks'; -import {FirebaseApp} from '../../../src/firebase-app'; -import {AuthRequestHandler} from '../../../src/auth/auth-api-request'; -import {Tenant, TenantOptions, TenantServerResponse, ListTenantsResult} from '../../../src/auth/tenant'; -import {TenantManager} from '../../../src/auth/tenant-manager'; -import {AuthClientErrorCode, FirebaseAuthError} from '../../../src/utils/error'; +import { FirebaseApp } from '../../../src/firebase-app'; +import { AuthRequestHandler } from '../../../src/auth/auth-api-request'; +import { Tenant, TenantOptions, TenantServerResponse, ListTenantsResult } from '../../../src/auth/tenant'; +import { TenantManager } from '../../../src/auth/tenant-manager'; +import { AuthClientErrorCode, FirebaseAuthError } from '../../../src/utils/error'; chai.should(); chai.use(sinonChai); @@ -175,15 +175,15 @@ describe('TenantManager', () => { const maxResult = 500; const listTenantsResponse: any = { tenants : [ - {name: 'projects/project-id/tenants/tenant-id1'}, - {name: 'projects/project-id/tenants/tenant-id2'}, + { name: 'projects/project-id/tenants/tenant-id1' }, + { name: 'projects/project-id/tenants/tenant-id2' }, ], nextPageToken: 'NEXT_PAGE_TOKEN', }; const expectedResult: ListTenantsResult = { tenants: [ - new Tenant({name: 'projects/project-id/tenants/tenant-id1'}), - new Tenant({name: 'projects/project-id/tenants/tenant-id2'}), + new Tenant({ name: 'projects/project-id/tenants/tenant-id1' }), + new Tenant({ name: 'projects/project-id/tenants/tenant-id2' }), ], pageToken: 'NEXT_PAGE_TOKEN', }; @@ -412,7 +412,7 @@ describe('TenantManager', () => { it('should be rejected given TenantOptions with invalid type property', () => { // Create tenant using invalid type. This should throw an argument error. - return tenantManager.createTenant({type: 'invalid'} as any) + return tenantManager.createTenant({ type: 'invalid' } as any) .then(() => { throw new Error('Unexpected success'); }) @@ -521,7 +521,7 @@ describe('TenantManager', () => { it('should be rejected given TenantOptions with invalid update property', () => { // Updating the tenantId of an existing tenant will throw an error as tenantId is // an immutable property. - return tenantManager.updateTenant(tenantId, {tenantId: 'unmodifiable'} as any) + return tenantManager.updateTenant(tenantId, { tenantId: 'unmodifiable' } as any) .then(() => { throw new Error('Unexpected success'); }) diff --git a/test/unit/auth/tenant.spec.ts b/test/unit/auth/tenant.spec.ts index 1fb1e24dfa..21440a1a8f 100755 --- a/test/unit/auth/tenant.spec.ts +++ b/test/unit/auth/tenant.spec.ts @@ -19,8 +19,8 @@ import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; import * as chaiAsPromised from 'chai-as-promised'; -import {deepCopy} from '../../../src/utils/deep-copy'; -import {EmailSignInConfig, EmailSignInProviderConfig} from '../../../src/auth/auth-config'; +import { deepCopy } from '../../../src/utils/deep-copy'; +import { EmailSignInConfig, EmailSignInProviderConfig } from '../../../src/auth/auth-config'; import { Tenant, TenantOptions, TenantServerResponse, } from '../../../src/auth/tenant'; diff --git a/test/unit/auth/token-generator.spec.ts b/test/unit/auth/token-generator.spec.ts index a257026193..cc733270b2 100644 --- a/test/unit/auth/token-generator.spec.ts +++ b/test/unit/auth/token-generator.spec.ts @@ -127,13 +127,13 @@ describe('CryptoSigner', () => { }); describe('explicit service account ID', () => { - const response = {signedBlob: Buffer.from('testsignature').toString('base64')}; + const response = { signedBlob: Buffer.from('testsignature').toString('base64') }; const input = Buffer.from('input'); const signRequest = { method: 'POST', url: `https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/test-service-account:signBlob`, - headers: {Authorization: `Bearer ${mockAccessToken}`}, - data: {payload: input.toString('base64')}, + headers: { Authorization: `Bearer ${mockAccessToken}` }, + data: { payload: input.toString('base64') }, }; let stub: sinon.SinonStub; @@ -179,17 +179,17 @@ describe('CryptoSigner', () => { describe('auto discovered service account', () => { const input = Buffer.from('input'); - const response = {signedBlob: Buffer.from('testsignature').toString('base64')}; + const response = { signedBlob: Buffer.from('testsignature').toString('base64') }; const metadataRequest = { method: 'GET', url: `http://metadata/computeMetadata/v1/instance/service-accounts/default/email`, - headers: {'Metadata-Flavor': 'Google'}, + headers: { 'Metadata-Flavor': 'Google' }, }; const signRequest = { method: 'POST', url: `https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/discovered-service-account:signBlob`, - headers: {Authorization: `Bearer ${mockAccessToken}`}, - data: {payload: input.toString('base64')}, + headers: { Authorization: `Bearer ${mockAccessToken}` }, + data: { payload: input.toString('base64') }, }; let stub: sinon.SinonStub; diff --git a/test/unit/auth/token-verifier.spec.ts b/test/unit/auth/token-verifier.spec.ts index bf95f96380..d4f4722af9 100644 --- a/test/unit/auth/token-verifier.spec.ts +++ b/test/unit/auth/token-verifier.spec.ts @@ -28,10 +28,10 @@ import * as chaiAsPromised from 'chai-as-promised'; import LegacyFirebaseTokenGenerator = require('firebase-token-generator'); import * as mocks from '../../resources/mocks'; -import {FirebaseTokenGenerator, ServiceAccountSigner} from '../../../src/auth/token-generator'; +import { FirebaseTokenGenerator, ServiceAccountSigner } from '../../../src/auth/token-generator'; import * as verifier from '../../../src/auth/token-verifier'; -import {ServiceAccountCredential} from '../../../src/auth/credential'; +import { ServiceAccountCredential } from '../../../src/auth/credential'; import { AuthClientErrorCode } from '../../../src/utils/error'; import { FirebaseApp } from '../../../src/firebase-app'; @@ -336,7 +336,7 @@ describe('FirebaseTokenVerifier', () => { it('should be rejected given a Firebase JWT token with no kid', () => { const mockIdToken = mocks.generateIdToken({ - header: {foo: 'bar'}, + header: { foo: 'bar' }, }); return tokenVerifier.verifyJWT(mockIdToken) .should.eventually.be.rejectedWith('Firebase ID token has no "kid" claim'); diff --git a/test/unit/auth/user-import-builder.spec.ts b/test/unit/auth/user-import-builder.spec.ts index b94e22f1f4..8923d42b8c 100755 --- a/test/unit/auth/user-import-builder.spec.ts +++ b/test/unit/auth/user-import-builder.spec.ts @@ -18,13 +18,13 @@ import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; import * as chaiAsPromised from 'chai-as-promised'; -import {deepCopy} from '../../../src/utils/deep-copy'; +import { deepCopy } from '../../../src/utils/deep-copy'; import { UserImportBuilder, ValidatorFunction, UserImportResult, UserImportRecord, UploadAccountRequest, } from '../../../src/auth/user-import-builder'; -import {AuthClientErrorCode, FirebaseAuthError} from '../../../src/utils/error'; -import {toWebSafeBase64} from '../../../src/utils'; +import { AuthClientErrorCode, FirebaseAuthError } from '../../../src/utils/error'; +import { toWebSafeBase64 } from '../../../src/utils'; chai.should(); @@ -69,7 +69,7 @@ describe('UserImportBuilder', () => { providerId: 'google.com', }, ], - customClaims: {admin: true}, + customClaims: { admin: true }, tenantId: 'TENANT-ID', }, { @@ -78,7 +78,7 @@ describe('UserImportBuilder', () => { passwordHash: Buffer.from('userpass'), passwordSalt: Buffer.from('NaCl'), }, - {uid: '5678', phoneNumber: '+16505550101'}, + { uid: '5678', phoneNumber: '+16505550101' }, { uid: '3456', email: 'janedoe@example.com', @@ -122,7 +122,7 @@ describe('UserImportBuilder', () => { providerId: 'google.com', }, ], - customAttributes: JSON.stringify({admin: true}), + customAttributes: JSON.stringify({ admin: true }), tenantId: 'TENANT-ID', }, { @@ -200,8 +200,8 @@ describe('UserImportBuilder', () => { it('should not throw when no hash options are provided and no hashing is needed', () => { const noHashUsers = [ - {uid: '1234', email: 'user@example.com'}, - {uid: '5678', phoneNumber: '+16505550101'}, + { uid: '1234', email: 'user@example.com' }, + { uid: '5678', phoneNumber: '+16505550101' }, ]; expect(() => { return new UserImportBuilder(noHashUsers, undefined, userRequestValidator); @@ -594,7 +594,7 @@ describe('UserImportBuilder', () => { } as any, ); testUsers.push( - {uid: 'INVALID2', email: 'other@domain.com', passwordHash: 'not a buffer'} as any, + { uid: 'INVALID2', email: 'other@domain.com', passwordHash: 'not a buffer' } as any, ); const expectedRequest = { hashAlgorithm: algorithm, @@ -610,13 +610,13 @@ describe('UserImportBuilder', () => { it('should return expected request with no hash options when not required', () => { const noHashUsers = [ - {uid: '1234', email: 'user@example.com'}, - {uid: '5678', phoneNumber: '+16505550101'}, + { uid: '1234', email: 'user@example.com' }, + { uid: '5678', phoneNumber: '+16505550101' }, ]; const expectedRequest = { users: [ - {localId: '1234', email: 'user@example.com'}, - {localId: '5678', phoneNumber: '+16505550101'}, + { localId: '1234', email: 'user@example.com' }, + { localId: '5678', phoneNumber: '+16505550101' }, ], }; const userImportBuilder = @@ -626,13 +626,13 @@ describe('UserImportBuilder', () => { it('should return expected request with no multi-factor fields when not available', () => { const noMultiFactorUsers: any[] = [ - {uid: '1234', email: 'user@example.com', multiFactor: null}, - {uid: '5678', phoneNumber: '+16505550101', multiFactor: {enrolledFactors: []}}, + { uid: '1234', email: 'user@example.com', multiFactor: null }, + { uid: '5678', phoneNumber: '+16505550101', multiFactor: { enrolledFactors: [] } }, ]; const expectedRequest = { users: [ - {localId: '1234', email: 'user@example.com'}, - {localId: '5678', phoneNumber: '+16505550101'}, + { localId: '1234', email: 'user@example.com' }, + { localId: '5678', phoneNumber: '+16505550101' }, ], }; const userImportBuilder = @@ -656,11 +656,11 @@ describe('UserImportBuilder', () => { ], }, }, - {uid: '5678', phoneNumber: '+16505550102'}, + { uid: '5678', phoneNumber: '+16505550102' }, ]; const expectedRequest: UploadAccountRequest = { users: [ - {localId: '5678', phoneNumber: '+16505550102'}, + { localId: '5678', phoneNumber: '+16505550102' }, ], }; const userImportBuilder = @@ -683,11 +683,11 @@ describe('UserImportBuilder', () => { ], }, }, - {uid: '5678', phoneNumber: '+16505550102'}, + { uid: '5678', phoneNumber: '+16505550102' }, ]; const expectedRequest: UploadAccountRequest = { users: [ - {localId: '5678', phoneNumber: '+16505550102'}, + { localId: '5678', phoneNumber: '+16505550102' }, ], }; const userImportBuilder = @@ -719,7 +719,7 @@ describe('UserImportBuilder', () => { it('should return the expected response for import with server side errors', () => { const failingServerResponse = [ - {index: 1, message: 'Some error occurred!'}, + { index: 1, message: 'Some error occurred!' }, ]; const serverErrorUserImportResponse = { successCount: 3, @@ -747,7 +747,7 @@ describe('UserImportBuilder', () => { successCount: 3, failureCount: 1, errors: [ - {index: 2, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_PHONE_NUMBER)}, + { index: 2, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_PHONE_NUMBER) }, ], }; // userRequestValidatorWithError will throw on the 3rd user (index = 2). @@ -760,8 +760,8 @@ describe('UserImportBuilder', () => { it('should return the expected response for import with mixed client/server errors', () => { // Server errors will occur on USER3 and USER6 passed to backend. const failingServerResponse = [ - {index: 1, message: 'Some error occurred in USER3!'}, - {index: 3, message: 'Another error occurred in USER6!'}, + { index: 1, message: 'Some error occurred in USER3!' }, + { index: 3, message: 'Another error occurred in USER6!' }, ]; const userRequestValidatorWithMultipleErrors: ValidatorFunction = (request) => { // Simulate a validation error is thrown for specific users. @@ -777,13 +777,13 @@ describe('UserImportBuilder', () => { // Seventh, eighth and nineth user will throw a client side error due to invalid type provided. // Tenth user will throw a client side error due to an unsupported second factor. const testUsers = [ - {uid: 'USER1'}, - {uid: 'USER2', email: 'invalid', passwordHash: Buffer.from('userpass')}, - {uid: 'USER3'}, - {uid: 'USER4', email: 'user@example.com', phoneNumber: 'invalid'}, - {uid: 'USER5', email: 'johndoe@example.com', passwordHash: Buffer.from('password')}, - {uid: 'USER6', phoneNumber: '+16505550101'}, - {uid: 'USER7', email: 'other@domain.com', passwordHash: 'not a buffer' as any}, + { uid: 'USER1' }, + { uid: 'USER2', email: 'invalid', passwordHash: Buffer.from('userpass') }, + { uid: 'USER3' }, + { uid: 'USER4', email: 'user@example.com', phoneNumber: 'invalid' }, + { uid: 'USER5', email: 'johndoe@example.com', passwordHash: Buffer.from('password') }, + { uid: 'USER6', phoneNumber: '+16505550101' }, + { uid: 'USER7', email: 'other@domain.com', passwordHash: 'not a buffer' as any }, { uid: 'USER8', email: 'other@domain.com', @@ -822,7 +822,7 @@ describe('UserImportBuilder', () => { failureCount: 8, errors: [ // Client side detected error. - {index: 1, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_EMAIL)}, + { index: 1, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_EMAIL) }, // Server side detected error. { index: 2, @@ -832,7 +832,7 @@ describe('UserImportBuilder', () => { ), }, // Client side detected error. - {index: 3, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_PHONE_NUMBER)}, + { index: 3, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_PHONE_NUMBER) }, // Server side detected error. { index: 5, @@ -842,8 +842,8 @@ describe('UserImportBuilder', () => { ), }, // Client side errors. - {index: 6, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_PASSWORD_HASH)}, - {index: 7, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_PASSWORD_SALT)}, + { index: 6, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_PASSWORD_HASH) }, + { index: 7, error: new FirebaseAuthError(AuthClientErrorCode.INVALID_PASSWORD_SALT) }, { index: 8, error: new FirebaseAuthError( diff --git a/test/unit/auth/user-record.spec.ts b/test/unit/auth/user-record.spec.ts index af1ae9773b..33a641bc4a 100644 --- a/test/unit/auth/user-record.spec.ts +++ b/test/unit/auth/user-record.spec.ts @@ -18,7 +18,7 @@ import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; import * as chaiAsPromised from 'chai-as-promised'; -import {deepCopy} from '../../../src/utils/deep-copy'; +import { deepCopy } from '../../../src/utils/deep-copy'; import { UserInfo, UserMetadata, UserRecord, GetAccountInfoUserResponse, ProviderUserInfoResponse, MultiFactor, PhoneMultiFactorInfo, MultiFactorInfo, MultiFactorInfoResponse, @@ -515,19 +515,19 @@ describe('UserInfo', () => { it('should succeed when rawId and providerId are both provided', () => { expect(() => { - return new UserInfo({providerId: 'google.com', rawId: '1234567890'}); + return new UserInfo({ providerId: 'google.com', rawId: '1234567890' }); }).not.to.throw(Error); }); it('should throw when only rawId is provided', () => { expect(() => { - return new UserInfo({rawId: '1234567890'} as any); + return new UserInfo({ rawId: '1234567890' } as any); }).to.throw(Error); }); it('should throw when only providerId is provided', () => { expect(() => { - return new UserInfo({providerId: 'google.com'} as any); + return new UserInfo({ providerId: 'google.com' } as any); }).to.throw(Error); }); }); @@ -631,7 +631,7 @@ describe('UserMetadata', () => { describe('constructor', () => { it('should initialize as expected when a valid creationTime is provided', () => { expect(() => { - return new UserMetadata({createdAt: '1476136676000'} as any); + return new UserMetadata({ createdAt: '1476136676000' } as any); }).not.to.throw(Error); }); @@ -701,7 +701,7 @@ describe('UserRecord', () => { it('should succeed when only localId is provided', () => { expect(() => { - return new UserRecord({localId: '123456789'}); + return new UserRecord({ localId: '123456789' }); }).not.to.throw(Error); }); }); @@ -849,7 +849,7 @@ describe('UserRecord', () => { it('should throw when modifying readonly customClaims property', () => { expect(() => { - (userRecord as any).customClaims = {admin: false}; + (userRecord as any).customClaims = { admin: false }; }).to.throw(Error); }); diff --git a/test/unit/database/database.spec.ts b/test/unit/database/database.spec.ts index 54d59432a3..78d73f21d6 100644 --- a/test/unit/database/database.spec.ts +++ b/test/unit/database/database.spec.ts @@ -17,13 +17,13 @@ 'use strict'; import * as _ from 'lodash'; -import {expect} from 'chai'; +import { expect } from 'chai'; import * as sinon from 'sinon'; import * as mocks from '../../resources/mocks'; -import {FirebaseApp} from '../../../src/firebase-app'; -import {DatabaseService} from '../../../src/database/database'; -import {Database} from '@firebase/database'; +import { FirebaseApp } from '../../../src/firebase-app'; +import { DatabaseService } from '../../../src/database/database'; +import { Database } from '@firebase/database'; import * as utils from '../utils'; import { HttpClient, HttpRequestConfig } from '../../../src/utils/api-request'; @@ -165,7 +165,7 @@ describe('Database', () => { }; if (strict) { - params.data = {format: 'strict'}; + params.data = { format: 'strict' }; } return params; @@ -228,7 +228,7 @@ describe('Database', () => { it('should throw if the server responds with a well-formed error', () => { const db: Database = database.getDatabase(); - stubErrorResponse({error: 'test error'}); + stubErrorResponse({ error: 'test error' }); return db.getRules().should.eventually.be.rejectedWith( 'Error while accessing security rules: test error'); }); @@ -282,7 +282,7 @@ describe('Database', () => { it('should throw if the server responds with a well-formed error', () => { const db: Database = database.getDatabase(); - stubErrorResponse({error: 'test error'}); + stubErrorResponse({ error: 'test error' }); return db.getRulesJSON().should.eventually.be.rejectedWith( 'Error while accessing security rules: test error'); }); @@ -386,7 +386,7 @@ describe('Database', () => { it('should throw if the server responds with a well-formed error', () => { const db: Database = database.getDatabase(); - stubErrorResponse({error: 'test error'}); + stubErrorResponse({ error: 'test error' }); return db.setRules(rules).should.eventually.be.rejectedWith( 'Error while accessing security rules: test error'); }); diff --git a/test/unit/firebase-app.spec.ts b/test/unit/firebase-app.spec.ts index ef63754993..dc89b6383c 100644 --- a/test/unit/firebase-app.spec.ts +++ b/test/unit/firebase-app.spec.ts @@ -25,19 +25,19 @@ import * as chaiAsPromised from 'chai-as-promised'; import * as utils from './utils'; import * as mocks from '../resources/mocks'; -import {GoogleOAuthAccessToken, ServiceAccountCredential} from '../../src/auth/credential'; -import {FirebaseServiceInterface} from '../../src/firebase-service'; -import {FirebaseApp, FirebaseAccessToken} from '../../src/firebase-app'; -import {FirebaseNamespace, FirebaseNamespaceInternals, FIREBASE_CONFIG_VAR} from '../../src/firebase-namespace'; - -import {Auth} from '../../src/auth/auth'; -import {Messaging} from '../../src/messaging/messaging'; -import {MachineLearning} from '../../src/machine-learning/machine-learning'; -import {Storage} from '../../src/storage/storage'; -import {Firestore} from '@google-cloud/firestore'; -import {Database} from '@firebase/database'; -import {InstanceId} from '../../src/instance-id/instance-id'; -import {ProjectManagement} from '../../src/project-management/project-management'; +import { GoogleOAuthAccessToken, ServiceAccountCredential } from '../../src/auth/credential'; +import { FirebaseServiceInterface } from '../../src/firebase-service'; +import { FirebaseApp, FirebaseAccessToken } from '../../src/firebase-app'; +import { FirebaseNamespace, FirebaseNamespaceInternals, FIREBASE_CONFIG_VAR } from '../../src/firebase-namespace'; + +import { Auth } from '../../src/auth/auth'; +import { Messaging } from '../../src/messaging/messaging'; +import { MachineLearning } from '../../src/machine-learning/machine-learning'; +import { Storage } from '../../src/storage/storage'; +import { Firestore } from '@google-cloud/firestore'; +import { Database } from '@firebase/database'; +import { InstanceId } from '../../src/instance-id/instance-id'; +import { ProjectManagement } from '../../src/project-management/project-management'; import { SecurityRules } from '../../src/security-rules/security-rules'; import { FirebaseAppError, AppErrorCodes } from '../../src/utils/error'; import { RemoteConfig } from '../../src/remote-config/remote-config'; @@ -728,7 +728,7 @@ describe('FirebaseApp', () => { getAccessToken: () => Promise.resolve(oracle), }; - const app = utils.createAppWithOptions({credential}); + const app = utils.createAppWithOptions({ credential }); return app.INTERNAL.getToken().then((token) => { expect(token.accessToken).to.equal(oracle.access_token); diff --git a/test/unit/firebase-namespace.spec.ts b/test/unit/firebase-namespace.spec.ts index 97478a330c..2c3a7b2dc1 100644 --- a/test/unit/firebase-namespace.spec.ts +++ b/test/unit/firebase-namespace.spec.ts @@ -24,9 +24,9 @@ import * as chaiAsPromised from 'chai-as-promised'; import * as mocks from '../resources/mocks'; -import {FirebaseNamespace} from '../../src/firebase-namespace'; -import {FirebaseApp} from '../../src/firebase-app'; -import {Auth} from '../../src/auth/auth'; +import { FirebaseNamespace } from '../../src/firebase-namespace'; +import { FirebaseApp } from '../../src/firebase-app'; +import { Auth } from '../../src/auth/auth'; import { enableLogging, Database, @@ -36,9 +36,9 @@ import { Reference, ServerValue, } from '@firebase/database'; -import {Messaging} from '../../src/messaging/messaging'; -import {MachineLearning} from '../../src/machine-learning/machine-learning'; -import {Storage} from '../../src/storage/storage'; +import { Messaging } from '../../src/messaging/messaging'; +import { MachineLearning } from '../../src/machine-learning/machine-learning'; +import { Storage } from '../../src/storage/storage'; import { Firestore, FieldPath, @@ -48,8 +48,8 @@ import { v1beta1, setLogFunction, } from '@google-cloud/firestore'; -import {InstanceId} from '../../src/instance-id/instance-id'; -import {ProjectManagement} from '../../src/project-management/project-management'; +import { InstanceId } from '../../src/instance-id/instance-id'; +import { ProjectManagement } from '../../src/project-management/project-management'; import { SecurityRules } from '../../src/security-rules/security-rules'; import { RemoteConfig } from '../../src/remote-config/remote-config'; diff --git a/test/unit/firebase.spec.ts b/test/unit/firebase.spec.ts index eca361b7e4..b697afa541 100644 --- a/test/unit/firebase.spec.ts +++ b/test/unit/firebase.spec.ts @@ -27,7 +27,7 @@ import * as chaiAsPromised from 'chai-as-promised'; import * as mocks from '../resources/mocks'; import * as firebaseAdmin from '../../src/index'; -import {RefreshTokenCredential, ServiceAccountCredential, isApplicationDefault} from '../../src/auth/credential'; +import { RefreshTokenCredential, ServiceAccountCredential, isApplicationDefault } from '../../src/auth/credential'; chai.should(); chai.use(chaiAsPromised); diff --git a/test/unit/firestore/firestore.spec.ts b/test/unit/firestore/firestore.spec.ts index 482211ffa0..236050dfbe 100644 --- a/test/unit/firestore/firestore.spec.ts +++ b/test/unit/firestore/firestore.spec.ts @@ -17,12 +17,12 @@ 'use strict'; import * as _ from 'lodash'; -import {expect} from 'chai'; +import { expect } from 'chai'; import * as mocks from '../../resources/mocks'; -import {FirebaseApp} from '../../../src/firebase-app'; +import { FirebaseApp } from '../../../src/firebase-app'; import { ComputeEngineCredential, RefreshTokenCredential } from '../../../src/auth/credential'; -import {FirestoreService, getFirestoreOptions} from '../../../src/firestore/firestore'; +import { FirestoreService, getFirestoreOptions } from '../../../src/firestore/firestore'; describe('Firestore', () => { let mockApp: FirebaseApp; diff --git a/test/unit/instance-id/instance-id-request.spec.ts b/test/unit/instance-id/instance-id-request.spec.ts index 7515f9cd7e..ae8580d3c2 100644 --- a/test/unit/instance-id/instance-id-request.spec.ts +++ b/test/unit/instance-id/instance-id-request.spec.ts @@ -25,9 +25,9 @@ import * as chaiAsPromised from 'chai-as-promised'; import * as utils from '../utils'; import * as mocks from '../../resources/mocks'; -import {FirebaseApp} from '../../../src/firebase-app'; -import {HttpClient} from '../../../src/utils/api-request'; -import {FirebaseInstanceIdRequestHandler} from '../../../src/instance-id/instance-id-request'; +import { FirebaseApp } from '../../../src/firebase-app'; +import { HttpClient } from '../../../src/utils/api-request'; +import { FirebaseInstanceIdRequestHandler } from '../../../src/instance-id/instance-id-request'; chai.should(); chai.use(sinonChai); @@ -129,7 +129,7 @@ describe('FirebaseInstanceIdRequestHandler', () => { }); it('should throw for unexpected HTTP errors', () => { - const expectedResult = {error: 'test error'}; + const expectedResult = { error: 'test error' }; const stub = sinon.stub(HttpClient.prototype, 'send') .rejects(utils.errorFrom(expectedResult, 511)); stubs.push(stub); diff --git a/test/unit/instance-id/instance-id.spec.ts b/test/unit/instance-id/instance-id.spec.ts index db4a9dcb10..9de49086b4 100644 --- a/test/unit/instance-id/instance-id.spec.ts +++ b/test/unit/instance-id/instance-id.spec.ts @@ -25,10 +25,10 @@ import * as chaiAsPromised from 'chai-as-promised'; import * as utils from '../utils'; import * as mocks from '../../resources/mocks'; -import {InstanceId} from '../../../src/instance-id/instance-id'; -import {FirebaseInstanceIdRequestHandler} from '../../../src/instance-id/instance-id-request'; -import {FirebaseApp} from '../../../src/firebase-app'; -import {FirebaseInstanceIdError, InstanceIdClientErrorCode} from '../../../src/utils/error'; +import { InstanceId } from '../../../src/instance-id/instance-id'; +import { FirebaseInstanceIdRequestHandler } from '../../../src/instance-id/instance-id-request'; +import { FirebaseApp } from '../../../src/firebase-app'; +import { FirebaseInstanceIdError, InstanceIdClientErrorCode } from '../../../src/utils/error'; chai.should(); chai.use(sinonChai); diff --git a/test/unit/machine-learning/machine-learning-api-client.spec.ts b/test/unit/machine-learning/machine-learning-api-client.spec.ts index b308164a8b..3b98c2b21d 100644 --- a/test/unit/machine-learning/machine-learning-api-client.spec.ts +++ b/test/unit/machine-learning/machine-learning-api-client.spec.ts @@ -43,7 +43,7 @@ describe('MachineLearningApiClient', () => { modelHash: 'modelHash123', displayName: 'model_1', tags: ['tag_1', 'tag_2'], - state: {published: true}, + state: { published: true }, tfliteModel: { gcsTfliteUri: 'gs://test-project-bucket/Firebase/ML/Models/model1.tflite', sizeBytes: 16900988, @@ -57,7 +57,7 @@ describe('MachineLearningApiClient', () => { modelHash: 'modelHash234', displayName: 'model_2', tags: ['tag_2', 'tag_3'], - state: {published: true}, + state: { published: true }, tfliteModel: { gcsTfliteUri: 'gs://test-project-bucket/Firebase/ML/Models/model2.tflite', sizeBytes: 2220022, @@ -124,10 +124,10 @@ describe('MachineLearningApiClient', () => { }); describe('createModel', () => { - const NAME_ONLY_CONTENT: ModelContent = {displayName: 'name1'}; + const NAME_ONLY_CONTENT: ModelContent = { displayName: 'name1' }; - const invalidContent: any[] = [null, undefined, {}, { tags: []}]; + const invalidContent: any[] = [null, undefined, {}, { tags: [] }]; invalidContent.forEach((content) => { it(`should reject when called with: ${JSON.stringify(content)}`, () => { return apiClient.createModel(content) @@ -210,7 +210,7 @@ describe('MachineLearningApiClient', () => { }); describe('updateModel', () => { - const NAME_ONLY_CONTENT: ModelContent = {displayName: 'name1'}; + const NAME_ONLY_CONTENT: ModelContent = { displayName: 'name1' }; const NAME_ONLY_MASK = ['displayName']; const invalidContent: any[] = [null, undefined]; @@ -395,7 +395,7 @@ describe('MachineLearningApiClient', () => { const invalidListFilters: any[] = [null, 0, '', true, {}, []]; invalidListFilters.forEach((invalidFilter) => { it(`should reject when called with invalid pageToken: ${JSON.stringify(invalidFilter)}`, () => { - return apiClient.listModels({filter: invalidFilter}) + return apiClient.listModels({ filter: invalidFilter }) .should.eventually.be.rejected.and.have.property( 'message', 'Invalid list filter.'); }); @@ -404,7 +404,7 @@ describe('MachineLearningApiClient', () => { const invalidPageSizes: any[] = [null, '', '10', true, {}, []]; invalidPageSizes.forEach((invalidPageSize) => { it(`should reject when called with invalid page size: ${JSON.stringify(invalidPageSize)}`, () => { - return apiClient.listModels({pageSize: invalidPageSize}) + return apiClient.listModels({ pageSize: invalidPageSize }) .should.eventually.be.rejected.and.have.property( 'message', 'Invalid page size.'); }); @@ -413,7 +413,7 @@ describe('MachineLearningApiClient', () => { const outOfRangePageSizes: number[] = [-1, 0, 101]; outOfRangePageSizes.forEach((invalidPageSize) => { it(`should reject when called with invalid page size: ${invalidPageSize}`, () => { - return apiClient.listModels({pageSize: invalidPageSize}) + return apiClient.listModels({ pageSize: invalidPageSize }) .should.eventually.be.rejected.and.have.property( 'message', 'Page size must be between 1 and 100.'); }); @@ -422,7 +422,7 @@ describe('MachineLearningApiClient', () => { const invalidPageTokens: any[] = [null, 0, '', true, {}, []]; invalidPageTokens.forEach((invalidToken) => { it(`should reject when called with invalid pageToken: ${JSON.stringify(invalidToken)}`, () => { - return apiClient.listModels({pageToken: invalidToken}) + return apiClient.listModels({ pageToken: invalidToken }) .should.eventually.be.rejected.and.have.property( 'message', 'Next page token must be a non-empty string.'); }); @@ -446,9 +446,9 @@ describe('MachineLearningApiClient', () => { }); const validOptions: ListModelsOptions[] = [ - {pageSize: 5}, - {pageToken: 'next'}, - {filter: 'displayName=name1'}, + { pageSize: 5 }, + { pageToken: 'next' }, + { filter: 'displayName=name1' }, { filter: 'displayName=name1', pageSize: 5, diff --git a/test/unit/machine-learning/machine-learning.spec.ts b/test/unit/machine-learning/machine-learning.spec.ts index 1a49b2cab1..b5c824955d 100644 --- a/test/unit/machine-learning/machine-learning.spec.ts +++ b/test/unit/machine-learning/machine-learning.spec.ts @@ -62,7 +62,7 @@ describe('MachineLearning', () => { modelHash: 'modelHash123', displayName: 'model_1', tags: ['tag_1', 'tag_2'], - state: {published: true}, + state: { published: true }, tfliteModel: { gcsTfliteUri: 'gs://test-project-bucket/Firebase/ML/Models/model1.tflite', sizeBytes: 16900988, @@ -97,7 +97,7 @@ describe('MachineLearning', () => { modelHash: 'modelHash234', displayName: 'model_2', tags: ['tag_2', 'tag_3'], - state: {published: false}, + state: { published: false }, tfliteModel: { gcsTfliteUri: 'gs://test-project-bucket/Firebase/ML/Models/model2.tflite', sizeBytes: 22200222, @@ -209,7 +209,7 @@ describe('MachineLearning', () => { displayName: 'foo', tfliteModel: { gcsTfliteUri: 'gs://some-bucket/model.tflite', - }}); + } }); }).to.throw(expectedError); }); diff --git a/test/unit/messaging/batch-requests.spec.ts b/test/unit/messaging/batch-requests.spec.ts index bcfee5ef74..c7c96a75f1 100644 --- a/test/unit/messaging/batch-requests.spec.ts +++ b/test/unit/messaging/batch-requests.spec.ts @@ -65,7 +65,7 @@ function createMultipartResponse(success: object[], failures: object[] = []): Ht }); return { status: 200, - headers: {'Content-Type': 'multipart/mixed; boundary=boundary'}, + headers: { 'Content-Type': 'multipart/mixed; boundary=boundary' }, multipart, text: '', data: null, @@ -93,7 +93,7 @@ describe('BatchRequestClient', () => { createMultipartResponse([responseObject])); stubs.push(stub); const requests: SubRequest[] = [ - {url: 'https://example.com', body: {foo: 1}}, + { url: 'https://example.com', body: { foo: 1 } }, ]; const batch = new BatchRequestClient(httpClient, batchUrl); @@ -110,9 +110,9 @@ describe('BatchRequestClient', () => { createMultipartResponse([responseObject, responseObject, responseObject])); stubs.push(stub); const requests: SubRequest[] = [ - {url: 'https://example.com', body: {foo: 1}}, - {url: 'https://example.com', body: {foo: 2}}, - {url: 'https://example.com', body: {foo: 3}}, + { url: 'https://example.com', body: { foo: 1 } }, + { url: 'https://example.com', body: { foo: 2 } }, + { url: 'https://example.com', body: { foo: 3 } }, ]; const batch = new BatchRequestClient(httpClient, batchUrl); @@ -131,9 +131,9 @@ describe('BatchRequestClient', () => { createMultipartResponse([responseObject, responseObject], [responseObject])); stubs.push(stub); const requests: SubRequest[] = [ - {url: 'https://example.com', body: {foo: 1}}, - {url: 'https://example.com', body: {foo: 2}}, - {url: 'https://example.com', body: {foo: 3}}, + { url: 'https://example.com', body: { foo: 1 } }, + { url: 'https://example.com', body: { foo: 2 } }, + { url: 'https://example.com', body: { foo: 3 } }, ]; const batch = new BatchRequestClient(httpClient, batchUrl); @@ -150,12 +150,12 @@ describe('BatchRequestClient', () => { it('should reject on top-level HTTP error responses', async () => { const stub = sinon.stub(httpClient, 'send').rejects( - utils.errorFrom({error: 'test'})); + utils.errorFrom({ error: 'test' })); stubs.push(stub); const requests: SubRequest[] = [ - {url: 'https://example.com', body: {foo: 1}}, - {url: 'https://example.com', body: {foo: 2}}, - {url: 'https://example.com', body: {foo: 3}}, + { url: 'https://example.com', body: { foo: 1 } }, + { url: 'https://example.com', body: { foo: 2 } }, + { url: 'https://example.com', body: { foo: 3 } }, ]; const batch = new BatchRequestClient(httpClient, batchUrl); @@ -174,10 +174,10 @@ describe('BatchRequestClient', () => { createMultipartResponse([responseObject])); stubs.push(stub); const requests: SubRequest[] = [ - {url: 'https://example.com', body: {foo: 1}}, - {url: 'https://example.com', body: {foo: 2}}, + { url: 'https://example.com', body: { foo: 1 } }, + { url: 'https://example.com', body: { foo: 2 } }, ]; - const commonHeaders = {'X-Custom-Header': 'value'}; + const commonHeaders = { 'X-Custom-Header': 'value' }; const batch = new BatchRequestClient(httpClient, batchUrl, commonHeaders); const responses: HttpResponse[] = await batch.send(requests); @@ -200,8 +200,8 @@ describe('BatchRequestClient', () => { createMultipartResponse([responseObject])); stubs.push(stub); const requests: SubRequest[] = [ - {url: 'https://example.com', body: {foo: 1}, headers: {'X-Custom-Header': 'value'}}, - {url: 'https://example.com', body: {foo: 1}, headers: {'X-Custom-Header': 'value'}}, + { url: 'https://example.com', body: { foo: 1 }, headers: { 'X-Custom-Header': 'value' } }, + { url: 'https://example.com', body: { foo: 1 }, headers: { 'X-Custom-Header': 'value' } }, ]; const batch = new BatchRequestClient(httpClient, batchUrl); @@ -223,10 +223,10 @@ describe('BatchRequestClient', () => { createMultipartResponse([responseObject])); stubs.push(stub); const requests: SubRequest[] = [ - {url: 'https://example.com', body: {foo: 1}, headers: {'X-Custom-Header': 'overwrite'}}, - {url: 'https://example.com', body: {foo: 1}, headers: {'X-Custom-Header': 'overwrite'}}, + { url: 'https://example.com', body: { foo: 1 }, headers: { 'X-Custom-Header': 'overwrite' } }, + { url: 'https://example.com', body: { foo: 1 }, headers: { 'X-Custom-Header': 'overwrite' } }, ]; - const commonHeaders = {'X-Custom-Header': 'value'}; + const commonHeaders = { 'X-Custom-Header': 'value' }; const batch = new BatchRequestClient(httpClient, batchUrl, commonHeaders); const responses: HttpResponse[] = await batch.send(requests); diff --git a/test/unit/messaging/messaging.spec.ts b/test/unit/messaging/messaging.spec.ts index 9bd41b374e..69453a216e 100644 --- a/test/unit/messaging/messaging.spec.ts +++ b/test/unit/messaging/messaging.spec.ts @@ -26,7 +26,7 @@ import * as chaiAsPromised from 'chai-as-promised'; import * as utils from '../utils'; import * as mocks from '../../resources/mocks'; -import {FirebaseApp} from '../../../src/firebase-app'; +import { FirebaseApp } from '../../../src/firebase-app'; import { Message, MessagingOptions, MessagingPayload, MessagingDevicesResponse, MessagingDeviceGroupResponse, MessagingTopicManagementResponse, BatchResponse, SendResponse, MulticastMessage, @@ -86,7 +86,7 @@ function mockBatchRequest(ids: string[]): nock.Scope { function mockBatchRequestWithErrors(ids: string[], errors: object[] = []): nock.Scope { const mockPayload = createMultipartPayloadWithErrors(ids.map((id) => { - return {name: id}; + return { name: id }; }), errors); return nock(`https://${FCM_SEND_HOST}:443`) .post('/batch') @@ -371,7 +371,7 @@ describe('Messaging', () => { it('should reject given app without project ID', () => { const appWithoutProjectId = mocks.mockCredentialApp(); const messagingWithoutProjectId = new Messaging(appWithoutProjectId); - messagingWithoutProjectId.send({topic: 'test'}) + messagingWithoutProjectId.send({ topic: 'test' }) .should.eventually.be.rejectedWith( 'Failed to determine project ID for Messaging. Initialize the SDK with service ' + 'account credentials or set project ID as an app option. Alternatively set the ' @@ -409,7 +409,7 @@ describe('Messaging', () => { }); const noTarget = [ - {}, {token: null}, {token: ''}, {topic: null}, {topic: ''}, {condition: null}, {condition: ''}, + {}, { token: null }, { token: '' }, { topic: null }, { topic: '' }, { condition: null }, { condition: '' }, ]; noTarget.forEach((message) => { it(`should throw given message without target: ${ JSON.stringify(message) }`, () => { @@ -420,10 +420,10 @@ describe('Messaging', () => { }); const multipleTargets = [ - {token: 'a', topic: 'b'}, - {token: 'a', condition: 'b'}, - {condition: 'a', topic: 'b'}, - {token: 'a', topic: 'b', condition: 'c'}, + { token: 'a', topic: 'b' }, + { token: 'a', condition: 'b' }, + { condition: 'a', topic: 'b' }, + { token: 'a', topic: 'b', condition: 'c' }, ]; multipleTargets.forEach((message) => { it(`should throw given message without target: ${ JSON.stringify(message)}`, () => { @@ -437,7 +437,7 @@ describe('Messaging', () => { invalidDryRun.forEach((dryRun) => { it(`should throw given invalid dryRun parameter: ${JSON.stringify(dryRun)}`, () => { expect(() => { - messaging.send({token: 'a'}, dryRun as any); + messaging.send({ token: 'a' }, dryRun as any); }).to.throw('dryRun must be a boolean'); }); }); @@ -446,14 +446,14 @@ describe('Messaging', () => { invalidTopics.forEach((topic) => { it(`should throw given invalid topic name: ${JSON.stringify(topic)}`, () => { expect(() => { - messaging.send({topic}); + messaging.send({ topic }); }).to.throw('Malformed topic name'); }); }); const targetMessages = [ - {token: 'mock-token'}, {topic: 'mock-topic'}, - {topic: '/topics/mock-topic'}, {condition: '"foo" in topics'}, + { token: 'mock-token' }, { topic: 'mock-topic' }, + { topic: '/topics/mock-topic' }, { condition: '"foo" in topics' }, ]; targetMessages.forEach((message) => { it(`should be fulfilled with a message ID given a valid message: ${JSON.stringify(message)}`, () => { @@ -482,7 +482,7 @@ describe('Messaging', () => { }; mockedRequests.push(mockSendError(400, 'json', resp)); return messaging.send( - {token: 'mock-token'}, + { token: 'mock-token' }, ).should.eventually.be.rejectedWith('test error message') .and.have.property('code', 'messaging/invalid-argument'); }); @@ -502,7 +502,7 @@ describe('Messaging', () => { }; mockedRequests.push(mockSendError(404, 'json', resp)); return messaging.send( - {token: 'mock-token'}, + { token: 'mock-token' }, ).should.eventually.be.rejectedWith('test error message') .and.have.property('code', 'messaging/registration-token-not-registered'); }); @@ -523,7 +523,7 @@ describe('Messaging', () => { }; mockedRequests.push(mockSendError(404, 'json', resp)); return messaging.send( - {token: 'mock-token'}, + { token: 'mock-token' }, ).should.eventually.be.rejectedWith('test error message') .and.have.property('code', 'messaging/third-party-auth-error'); }); @@ -538,16 +538,16 @@ describe('Messaging', () => { }; mockedRequests.push(mockSendError(404, 'json', resp)); return messaging.send( - {token: 'mock-token'}, + { token: 'mock-token' }, ).should.eventually.be.rejectedWith('test error message') .and.have.property('code', 'messaging/registration-token-not-registered'); }); it('should fail when the backend server returns an unknown error', () => { - const resp = {error: 'test error message'}; + const resp = { error: 'test error message' }; mockedRequests.push(mockSendError(400, 'json', resp)); return messaging.send( - {token: 'mock-token'}, + { token: 'mock-token' }, ).should.eventually.be.rejected.and.have.property('code', 'messaging/unknown-error'); }); @@ -555,13 +555,13 @@ describe('Messaging', () => { // Error code will be determined based on the status code. mockedRequests.push(mockSendError(400, 'text', 'foo bar')); return messaging.send( - {token: 'mock-token'}, + { token: 'mock-token' }, ).should.eventually.be.rejected.and.have.property('code', 'messaging/invalid-argument'); }); }); describe('sendAll()', () => { - const validMessage: Message = {token: 'a'}; + const validMessage: Message = { token: 'a' }; function checkSendResponseSuccess(response: SendResponse, messageId: string): void { expect(response.success).to.be.true; @@ -610,7 +610,7 @@ describe('Messaging', () => { invalidDryRun.forEach((dryRun) => { it(`should throw given invalid dryRun parameter: ${JSON.stringify(dryRun)}`, () => { expect(() => { - messaging.sendAll([{token: 'a'}], dryRun as any); + messaging.sendAll([{ token: 'a' }], dryRun as any); }).to.throw('dryRun must be a boolean'); }); }); @@ -795,7 +795,7 @@ describe('Messaging', () => { }); it('should fail when the backend server returns an unknown error', () => { - const resp = {error: 'test error message'}; + const resp = { error: 'test error message' }; mockedRequests.push(mockBatchError(400, 'json', resp)); return messaging.sendAll( [validMessage], @@ -822,9 +822,9 @@ describe('Messaging', () => { successCount: 3, failureCount: 0, responses: [ - {success: true, messageId: 'projects/projec_id/messages/1'}, - {success: true, messageId: 'projects/projec_id/messages/2'}, - {success: true, messageId: 'projects/projec_id/messages/3'}, + { success: true, messageId: 'projects/projec_id/messages/1' }, + { success: true, messageId: 'projects/projec_id/messages/2' }, + { success: true, messageId: 'projects/projec_id/messages/3' }, ], }; @@ -845,7 +845,7 @@ describe('Messaging', () => { messaging.sendMulticast({} as any); }).to.throw('tokens must be a non-empty array'); expect(() => { - messaging.sendMulticast({tokens: []}); + messaging.sendMulticast({ tokens: [] }); }).to.throw('tokens must be a non-empty array'); }); @@ -855,7 +855,7 @@ describe('Messaging', () => { tokens.push(`token${i}`); } expect(() => { - messaging.sendMulticast({tokens}); + messaging.sendMulticast({ tokens }); }).to.throw('tokens list must not contain more than 500 items'); }); @@ -863,7 +863,7 @@ describe('Messaging', () => { invalidDryRun.forEach((dryRun) => { it(`should throw given invalid dryRun parameter: ${JSON.stringify(dryRun)}`, () => { expect(() => { - messaging.sendMulticast({tokens: ['a']}, dryRun as any); + messaging.sendMulticast({ tokens: ['a'] }, dryRun as any); }).to.throw('dryRun must be a boolean'); }); }); @@ -871,7 +871,7 @@ describe('Messaging', () => { it('should create multiple messages using the empty multicast payload', () => { stub = sinon.stub(messaging, 'sendAll').resolves(mockResponse); const tokens = ['a', 'b', 'c']; - return messaging.sendMulticast({tokens}) + return messaging.sendMulticast({ tokens }) .then((response: BatchResponse) => { expect(response).to.deep.equal(mockResponse); expect(stub).to.have.been.calledOnce; @@ -894,12 +894,12 @@ describe('Messaging', () => { const tokens = ['a', 'b', 'c']; const multicast: MulticastMessage = { tokens, - android: {ttl: 100}, - apns: {payload: {aps: {badge: 42}}}, - data: {key: 'value'}, - notification: {title: 'test title'}, - webpush: {data: {webKey: 'webValue'}}, - fcmOptions: {analyticsLabel: 'label'}, + android: { ttl: 100 }, + apns: { payload: { aps: { badge: 42 } } }, + data: { key: 'value' }, + notification: { title: 'test title' }, + webpush: { data: { webKey: 'webValue' } }, + fcmOptions: { analyticsLabel: 'label' }, }; return messaging.sendMulticast(multicast) .then((response: BatchResponse) => { @@ -923,7 +923,7 @@ describe('Messaging', () => { it('should pass dryRun argument through', () => { stub = sinon.stub(messaging, 'sendAll').resolves(mockResponse); const tokens = ['a', 'b', 'c']; - return messaging.sendMulticast({tokens}, true) + return messaging.sendMulticast({ tokens }, true) .then((response: BatchResponse) => { expect(response).to.deep.equal(mockResponse); expect(stub).to.have.been.calledOnce; @@ -940,11 +940,11 @@ describe('Messaging', () => { mockedRequests.push(mockBatchRequest(messageIds)); return messaging.sendMulticast({ tokens: ['a', 'b', 'c'], - android: {ttl: 100}, - apns: {payload: {aps: {badge: 42}}}, - data: {key: 'value'}, - notification: {title: 'test title'}, - webpush: {data: {webKey: 'webValue'}}, + android: { ttl: 100 }, + apns: { payload: { aps: { badge: 42 } } }, + data: { key: 'value' }, + notification: { title: 'test title' }, + webpush: { data: { webKey: 'webValue' } }, }).then((response: BatchResponse) => { expect(response.successCount).to.equal(3); expect(response.failureCount).to.equal(0); @@ -965,11 +965,11 @@ describe('Messaging', () => { mockedRequests.push(mockBatchRequest(messageIds)); return messaging.sendMulticast({ tokens: ['a', 'b', 'c'], - android: {ttl: 100}, - apns: {payload: {aps: {badge: 42}}}, - data: {key: 'value'}, - notification: {title: 'test title'}, - webpush: {data: {webKey: 'webValue'}}, + android: { ttl: 100 }, + apns: { payload: { aps: { badge: 42 } } }, + data: { key: 'value' }, + notification: { title: 'test title' }, + webpush: { data: { webKey: 'webValue' } }, }, true).then((response: BatchResponse) => { expect(response.successCount).to.equal(3); expect(response.failureCount).to.equal(0); @@ -994,7 +994,7 @@ describe('Messaging', () => { }, ]; mockedRequests.push(mockBatchRequestWithErrors(messageIds, errors)); - return messaging.sendMulticast({tokens: ['a', 'b']}) + return messaging.sendMulticast({ tokens: ['a', 'b'] }) .then((response: BatchResponse) => { expect(response.successCount).to.equal(2); expect(response.failureCount).to.equal(1); @@ -1027,7 +1027,7 @@ describe('Messaging', () => { }, ]; mockedRequests.push(mockBatchRequestWithErrors(messageIds, errors)); - return messaging.sendMulticast({tokens: ['a', 'b']}) + return messaging.sendMulticast({ tokens: ['a', 'b'] }) .then((response: BatchResponse) => { expect(response.successCount).to.equal(1); expect(response.failureCount).to.equal(1); @@ -1049,7 +1049,7 @@ describe('Messaging', () => { }; mockedRequests.push(mockBatchError(400, 'json', resp)); return messaging.sendMulticast( - {tokens: ['a']}, + { tokens: ['a'] }, ).should.eventually.be.rejectedWith('test error message') .and.have.property('code', 'messaging/invalid-argument'); }); @@ -1069,7 +1069,7 @@ describe('Messaging', () => { }; mockedRequests.push(mockBatchError(404, 'json', resp)); return messaging.sendMulticast( - {tokens: ['a']}, + { tokens: ['a'] }, ).should.eventually.be.rejectedWith('test error message') .and.have.property('code', 'messaging/registration-token-not-registered'); }); @@ -1083,16 +1083,16 @@ describe('Messaging', () => { }; mockedRequests.push(mockBatchError(404, 'json', resp)); return messaging.sendMulticast( - {tokens: ['a']}, + { tokens: ['a'] }, ).should.eventually.be.rejectedWith('test error message') .and.have.property('code', 'messaging/registration-token-not-registered'); }); it('should fail when the backend server returns an unknown error', () => { - const resp = {error: 'test error message'}; + const resp = { error: 'test error message' }; mockedRequests.push(mockBatchError(400, 'json', resp)); return messaging.sendMulticast( - {tokens: ['a']}, + { tokens: ['a'] }, ).should.eventually.be.rejected.and.have.property('code', 'messaging/unknown-error'); }); @@ -1100,13 +1100,13 @@ describe('Messaging', () => { // Error code will be determined based on the status code. mockedRequests.push(mockBatchError(400, 'text', 'foo bar')); return messaging.sendMulticast( - {tokens: ['a']}, + { tokens: ['a'] }, ).should.eventually.be.rejected.and.have.property('code', 'messaging/invalid-argument'); }); it('should be rejected given an app which returns null access tokens', () => { return nullAccessTokenMessaging.sendMulticast( - {tokens: ['a']}, + { tokens: ['a'] }, ).should.eventually.be.rejected.and.have.property('code', 'app/invalid-credential'); }); @@ -2590,49 +2590,49 @@ describe('Messaging', () => { invalidObjects.forEach((arg) => { it(`should throw given invalid android config: ${JSON.stringify(arg)}`, () => { expect(() => { - messaging.send({android: arg, topic: 'test'}); + messaging.send({ android: arg, topic: 'test' }); }).to.throw('android must be a non-null object'); }); it(`should throw given invalid android notification: ${JSON.stringify(arg)}`, () => { expect(() => { - messaging.send({android: {notification: arg}, topic: 'test'}); + messaging.send({ android: { notification: arg }, topic: 'test' }); }).to.throw('android.notification must be a non-null object'); }); it(`should throw given invalid apns config: ${JSON.stringify(arg)}`, () => { expect(() => { - messaging.send({apns: arg, topic: 'test'}); + messaging.send({ apns: arg, topic: 'test' }); }).to.throw('apns must be a non-null object'); }); it(`should throw given invalid webpush config: ${JSON.stringify(arg)}`, () => { expect(() => { - messaging.send({webpush: arg, topic: 'test'}); + messaging.send({ webpush: arg, topic: 'test' }); }).to.throw('webpush must be a non-null object'); }); it(`should throw given invalid data: ${JSON.stringify(arg)}`, () => { expect(() => { - messaging.send({data: arg, topic: 'test'}); + messaging.send({ data: arg, topic: 'test' }); }).to.throw('data must be a non-null object'); }); it(`should throw given invalid fcmOptions: ${JSON.stringify(arg)}`, () => { expect(() => { - messaging.send({fcmOptions: arg, topic: 'test'}); + messaging.send({ fcmOptions: arg, topic: 'test' }); }).to.throw('fcmOptions must be a non-null object'); }); it(`should throw given invalid AndroidFcmOptions: ${JSON.stringify(arg)}`, () => { expect(() => { - messaging.send({android: {fcmOptions: arg}, topic: 'test'}); + messaging.send({ android: { fcmOptions: arg }, topic: 'test' }); }).to.throw('fcmOptions must be a non-null object'); }); it(`should throw given invalid ApnsFcmOptions: ${JSON.stringify(arg)}`, () => { expect(() => { - messaging.send({apns: {fcmOptions: arg}, topic: 'test'}); + messaging.send({ apns: { fcmOptions: arg }, topic: 'test' }); }).to.throw('fcmOptions must be a non-null object'); }); }); @@ -2640,17 +2640,17 @@ describe('Messaging', () => { invalidImages.forEach((imageUrl) => { it(`should throw given invalid URL string for imageUrl`, () => { expect(() => { - messaging.send({apns: {fcmOptions: {imageUrl}}, topic: 'test'}); + messaging.send({ apns: { fcmOptions: { imageUrl } }, topic: 'test' }); }).to.throw('imageUrl must be a valid URL string'); }); }); const invalidDataMessages: any[] = [ - {label: 'data', message: {data: {k1: true}}}, - {label: 'android.data', message: {android: {data: {k1: true}}}}, - {label: 'webpush.data', message: {webpush: {data: {k1: true}}}}, - {label: 'webpush.headers', message: {webpush: {headers: {k1: true}}}}, - {label: 'apns.headers', message: {apns: {headers: {k1: true}}}}, + { label: 'data', message: { data: { k1: true } } }, + { label: 'android.data', message: { android: { data: { k1: true } } } }, + { label: 'webpush.data', message: { webpush: { data: { k1: true } } } }, + { label: 'webpush.headers', message: { webpush: { headers: { k1: true } } } }, + { label: 'apns.headers', message: { apns: { headers: { k1: true } } } }, ]; invalidDataMessages.forEach((config) => { it(`should throw given data with non-string value: ${config.label}`, () => { @@ -2666,14 +2666,14 @@ describe('Messaging', () => { invalidApnsPayloads.forEach((payload) => { it(`should throw given APNS payload with invalid object: ${JSON.stringify(payload)}`, () => { expect(() => { - messaging.send({apns: {payload}, token: 'token'}); + messaging.send({ apns: { payload }, token: 'token' }); }).to.throw('apns.payload must be a non-null object'); }); }); invalidApnsPayloads.forEach((aps) => { it(`should throw given APNS payload with invalid aps object: ${JSON.stringify(aps)}`, () => { expect(() => { - messaging.send({apns: {payload: {aps}}, token: 'token'}); + messaging.send({ apns: { payload: { aps } }, token: 'token' }); }).to.throw('apns.payload.aps must be a non-null object'); }); }); @@ -2682,7 +2682,7 @@ describe('Messaging', () => { messaging.send({ apns: { payload: { - aps: {'mutableContent': true, 'mutable-content': 1}, + aps: { 'mutableContent': true, 'mutable-content': 1 }, }, }, token: 'token', @@ -2694,7 +2694,7 @@ describe('Messaging', () => { invalidApnsAlerts.forEach((alert) => { it(`should throw given APNS payload with invalid aps alert: ${JSON.stringify(alert)}`, () => { expect(() => { - messaging.send({apns: {payload: {aps: {alert}}}, token: 'token'}); + messaging.send({ apns: { payload: { aps: { alert } } }, token: 'token' }); }).to.throw('apns.payload.aps.alert must be a string or a non-null object'); }); }); @@ -2703,7 +2703,7 @@ describe('Messaging', () => { invalidApnsSounds.forEach((sound) => { it(`should throw given APNS payload with invalid aps sound: ${JSON.stringify(sound)}`, () => { expect(() => { - messaging.send({apns: {payload: {aps: {sound}}}, token: 'token'}); + messaging.send({ apns: { payload: { aps: { sound } } }, token: 'token' }); }).to.throw('apns.payload.aps.sound must be a non-empty string or a non-null object'); }); }); @@ -2714,7 +2714,7 @@ describe('Messaging', () => { apns: { payload: { aps: { - sound: {name}, + sound: { name }, }, }, }, @@ -3283,7 +3283,7 @@ describe('Messaging', () => { threadId: 'thread.id', }, customKey1: 'custom.value', - customKey2: {nested: 'value'}, + customKey2: { nested: 'value' }, }, fcmOptions: { analyticsLabel: 'test.analytics', @@ -3320,7 +3320,7 @@ describe('Messaging', () => { 'thread-id': 'thread.id', }, customKey1: 'custom.value', - customKey2: {nested: 'value'}, + customKey2: { nested: 'value' }, }, fcmOptions: { analyticsLabel: 'test.analytics', @@ -3444,7 +3444,7 @@ describe('Messaging', () => { expectedReq: { apns: { payload: { - aps: {'content-available': 1}, + aps: { 'content-available': 1 }, }, }, }, @@ -3498,7 +3498,7 @@ describe('Messaging', () => { // Wait for the initial getToken() call to complete before stubbing https.request. return mockApp.INTERNAL.getToken() .then(() => { - const resp = utils.responseFrom({message: 'test'}); + const resp = utils.responseFrom({ message: 'test' }); httpsRequestStub = sinon.stub(HttpClient.prototype, 'send').resolves(resp); const req = config.req; req.token = 'mock-token'; @@ -3509,7 +3509,7 @@ describe('Messaging', () => { expectedReq.token = 'mock-token'; expect(httpsRequestStub).to.have.been.calledOnce.and.calledWith({ method: 'POST', - data: {message: expectedReq}, + data: { message: expectedReq }, timeout: 10000, url: 'https://fcm.googleapis.com/v1/projects/project_id/messages:send', headers: expectedHeaders, @@ -3521,14 +3521,14 @@ describe('Messaging', () => { it('should not throw when the message is addressed to the prefixed topic name', () => { return mockApp.INTERNAL.getToken() .then(() => { - const resp = utils.responseFrom({message: 'test'}); + const resp = utils.responseFrom({ message: 'test' }); httpsRequestStub = sinon.stub(HttpClient.prototype, 'send').resolves(resp); - return messaging.send({topic: '/topics/mock-topic'}); + return messaging.send({ topic: '/topics/mock-topic' }); }) .then(() => { expect(httpsRequestStub).to.have.been.calledOnce; const requestData = httpsRequestStub.args[0][0].data; - const expectedReq = {topic: 'mock-topic'}; + const expectedReq = { topic: 'mock-topic' }; expect(requestData.message).to.deep.equal(expectedReq); }); }); diff --git a/test/unit/security-rules/security-rules.spec.ts b/test/unit/security-rules/security-rules.spec.ts index 45e1f98a87..bc9ba713fa 100644 --- a/test/unit/security-rules/security-rules.spec.ts +++ b/test/unit/security-rules/security-rules.spec.ts @@ -57,7 +57,7 @@ describe('SecurityRules', () => { 'invalid-argument', 'ruleset must be a non-empty name or a RulesetMetadata object.', ); - const INVALID_RULESETS: any[] = [null, undefined, '', 1, true, {}, [], {name: ''}]; + const INVALID_RULESETS: any[] = [null, undefined, '', 1, true, {}, [], { name: '' }]; const INVALID_BUCKET_ERROR = new FirebaseSecurityRulesError( 'invalid-argument', @@ -397,7 +397,7 @@ describe('SecurityRules', () => { }); stubs.push(stub); - return securityRules.releaseFirestoreRuleset({name: 'foo', createTime: 'time'}) + return securityRules.releaseFirestoreRuleset({ name: 'foo', createTime: 'time' }) .then(() => { expect(stub).to.have.been.calledOnce.and.calledWith('cloud.firestore', 'foo'); }); @@ -520,7 +520,7 @@ describe('SecurityRules', () => { }); stubs.push(stub); - return securityRules.releaseStorageRuleset({name: 'foo', createTime: 'time'}) + return securityRules.releaseStorageRuleset({ name: 'foo', createTime: 'time' }) .then(() => { expect(stub).to.have.been.calledOnce.and.calledWith( 'firebase.storage/bucketName.appspot.com', 'foo'); diff --git a/test/unit/storage/storage.spec.ts b/test/unit/storage/storage.spec.ts index 55fc8ff6df..0dba8db5a0 100644 --- a/test/unit/storage/storage.spec.ts +++ b/test/unit/storage/storage.spec.ts @@ -17,11 +17,11 @@ 'use strict'; import * as _ from 'lodash'; -import {expect} from 'chai'; +import { expect } from 'chai'; import * as mocks from '../../resources/mocks'; -import {FirebaseApp} from '../../../src/firebase-app'; -import {Storage} from '../../../src/storage/storage'; +import { FirebaseApp } from '../../../src/firebase-app'; +import { Storage } from '../../../src/storage/storage'; describe('Storage', () => { let mockApp: FirebaseApp; @@ -90,7 +90,7 @@ describe('Storage', () => { const expectedError = 'Bucket name not specified or invalid. Specify a valid bucket name via ' + 'the storageBucket option when initializing the app, or specify the bucket name ' + 'explicitly when calling the getBucket() method.'; - const invalidNames = [null, NaN, 0, 1, true, false, '', [], [1, 'a'], {}, { a: 1}, _.noop]; + const invalidNames = [null, NaN, 0, 1, true, false, '', [], [1, 'a'], {}, { a: 1 }, _.noop]; invalidNames.forEach((invalidName) => { it(`should throw given invalid bucket name: ${ JSON.stringify(invalidName) }`, () => { expect(() => { diff --git a/test/unit/utils.ts b/test/unit/utils.ts index 12bc260b65..fa655dd4e8 100644 --- a/test/unit/utils.ts +++ b/test/unit/utils.ts @@ -19,8 +19,8 @@ import * as sinon from 'sinon'; import * as mocks from '../resources/mocks'; -import {FirebaseNamespace} from '../../src/firebase-namespace'; -import {FirebaseApp, FirebaseAppOptions, FirebaseAppInternals, FirebaseAccessToken} from '../../src/firebase-app'; +import { FirebaseNamespace } from '../../src/firebase-namespace'; +import { FirebaseApp, FirebaseAppOptions, FirebaseAppInternals, FirebaseAccessToken } from '../../src/firebase-app'; import { HttpError, HttpResponse } from '../../src/utils/api-request'; /** diff --git a/test/unit/utils/api-request.spec.ts b/test/unit/utils/api-request.spec.ts index c2798de455..cab4c4f9ac 100644 --- a/test/unit/utils/api-request.spec.ts +++ b/test/unit/utils/api-request.spec.ts @@ -25,13 +25,13 @@ import * as chaiAsPromised from 'chai-as-promised'; import * as utils from '../utils'; import * as mocks from '../../resources/mocks'; -import {FirebaseApp} from '../../../src/firebase-app'; +import { FirebaseApp } from '../../../src/firebase-app'; import { ApiSettings, HttpClient, HttpError, AuthorizedHttpClient, ApiCallbackFunction, HttpRequestConfig, HttpResponse, parseHttpResponse, RetryConfig, defaultRetryConfig, } from '../../../src/utils/api-request'; import { deepCopy } from '../../../src/utils/deep-copy'; -import {Agent} from 'http'; +import { Agent } from 'http'; import * as zlib from 'zlib'; chai.should(); @@ -141,7 +141,7 @@ describe('HttpClient', () => { invalidNumbers.forEach((maxRetries: any) => { it(`should throw when maxRetries is: ${maxRetries}`, () => { expect(() => { - new HttpClient({maxRetries} as any); + new HttpClient({ maxRetries } as any); }).to.throw('maxRetries must be a non-negative integer'); }); }); @@ -150,7 +150,7 @@ describe('HttpClient', () => { if (typeof backOffFactor !== 'undefined') { it(`should throw when backOffFactor is: ${backOffFactor}`, () => { expect(() => { - new HttpClient({maxRetries: 1, backOffFactor} as any); + new HttpClient({ maxRetries: 1, backOffFactor } as any); }).to.throw('backOffFactor must be a non-negative number'); }); } @@ -159,7 +159,7 @@ describe('HttpClient', () => { invalidNumbers.forEach((maxDelayInMillis: any) => { it(`should throw when maxDelayInMillis is: ${maxDelayInMillis}`, () => { expect(() => { - new HttpClient({maxRetries: 1, maxDelayInMillis} as any); + new HttpClient({ maxRetries: 1, maxDelayInMillis } as any); }).to.throw('maxDelayInMillis must be a non-negative integer'); }); }); @@ -167,7 +167,7 @@ describe('HttpClient', () => { invalidArrays.forEach((ioErrorCodes: any) => { it(`should throw when ioErrorCodes is: ${ioErrorCodes}`, () => { expect(() => { - new HttpClient({maxRetries: 1, maxDelayInMillis: 10000, ioErrorCodes} as any); + new HttpClient({ maxRetries: 1, maxDelayInMillis: 10000, ioErrorCodes } as any); }).to.throw('ioErrorCodes must be an array'); }); }); @@ -175,13 +175,13 @@ describe('HttpClient', () => { invalidArrays.forEach((statusCodes: any) => { it(`should throw when statusCodes is: ${statusCodes}`, () => { expect(() => { - new HttpClient({maxRetries: 1, maxDelayInMillis: 10000, statusCodes} as any); + new HttpClient({ maxRetries: 1, maxDelayInMillis: 10000, statusCodes } as any); }).to.throw('statusCodes must be an array'); }); }); it('should be fulfilled for a 2xx response with a json payload', () => { - const respData = {foo: 'bar'}; + const respData = { foo: 'bar' }; const scope = nock('https://' + mockHost) .get(mockPath) .reply(200, respData, { @@ -337,7 +337,7 @@ describe('HttpClient', () => { }); it('should use the specified HTTP agent', () => { - const respData = {success: true}; + const respData = { success: true }; const scope = nock('https://' + mockHost) .get(mockPath) .reply(200, respData, { @@ -369,8 +369,8 @@ describe('HttpClient', () => { }); it('should make a POST request with the provided headers and data', () => { - const reqData = {request: 'data'}; - const respData = {success: true}; + const reqData = { request: 'data' }; + const respData = { success: true }; const scope = nock('https://' + mockHost, { reqheaders: { 'Authorization': 'Bearer token', @@ -402,8 +402,8 @@ describe('HttpClient', () => { }); it('should use the specified content-type header for the body', () => { - const reqData = {request: 'data'}; - const respData = {success: true}; + const reqData = { request: 'data' }; + const respData = { success: true }; const scope = nock('https://' + mockHost, { reqheaders: { 'Content-Type': (header) => { @@ -432,7 +432,7 @@ describe('HttpClient', () => { }); it('should not mutate the arguments', () => { - const reqData = {request: 'data'}; + const reqData = { request: 'data' }; const scope = nock('https://' + mockHost, { reqheaders: { 'Authorization': 'Bearer token', @@ -442,7 +442,7 @@ describe('HttpClient', () => { 'My-Custom-Header': 'CustomValue', }, }).post(mockPath, reqData) - .reply(200, {success: true}, { + .reply(200, { success: true }, { 'content-type': 'application/json', }); mockedRequests.push(scope); @@ -464,8 +464,8 @@ describe('HttpClient', () => { }); it('should make a GET request with the provided headers and data', () => { - const reqData = {key1: 'value1', key2: 'value2'}; - const respData = {success: true}; + const reqData = { key1: 'value1', key2: 'value2' }; + const respData = { success: true }; const scope = nock('https://' + mockHost, { reqheaders: { 'Authorization': 'Bearer token', @@ -495,9 +495,9 @@ describe('HttpClient', () => { }); it('should merge query parameters in URL with data', () => { - const reqData = {key1: 'value1', key2: 'value2'}; - const mergedData = {...reqData, key3: 'value3'}; - const respData = {success: true}; + const reqData = { key1: 'value1', key2: 'value2' }; + const mergedData = { ...reqData, key3: 'value3' }; + const respData = { success: true }; const scope = nock('https://' + mockHost) .get(mockPath) .query(mergedData) @@ -519,9 +519,9 @@ describe('HttpClient', () => { }); it('should urlEncode query parameters in URL', () => { - const reqData = {key1: 'value 1!', key2: 'value 2!'}; - const mergedData = {...reqData, key3: 'value 3!'}; - const respData = {success: true}; + const reqData = { key1: 'value 1!', key2: 'value 2!' }; + const mergedData = { ...reqData, key3: 'value 3!' }; + const respData = { success: true }; const scope = nock('https://' + mockHost) .get(mockPath) .query(mergedData) @@ -543,7 +543,7 @@ describe('HttpClient', () => { }); it('should default to https when protocol not specified', () => { - const respData = {foo: 'bar'}; + const respData = { foo: 'bar' }; const scope = nock('https://' + mockHost) .get(mockPath) .reply(200, respData, { @@ -576,8 +576,8 @@ describe('HttpClient', () => { }); it('should make a HEAD request with the provided headers and data', () => { - const reqData = {key1: 'value1', key2: 'value2'}; - const respData = {success: true}; + const reqData = { key1: 'value1', key2: 'value2' }; + const respData = { success: true }; const scope = nock('https://' + mockHost, { reqheaders: { 'Authorization': 'Bearer token', @@ -618,7 +618,7 @@ describe('HttpClient', () => { }); it('should fail with an HttpError for a 4xx response', () => { - const data = {error: 'data'}; + const data = { error: 'data' }; mockedRequests.push(mockRequestWithHttpError(400, 'application/json', data)); const client = new HttpClient(); return client.send({ @@ -635,7 +635,7 @@ describe('HttpClient', () => { }); it('should fail with an HttpError for a 5xx response', () => { - const data = {error: 'data'}; + const data = { error: 'data' }; mockedRequests.push(mockRequestWithHttpError(500, 'application/json', data)); const client = new HttpClient(); return client.send({ @@ -676,7 +676,7 @@ describe('HttpClient', () => { }); it('should fail with a FirebaseAppError for a network error', () => { - mockedRequests.push(mockRequestWithError({message: 'test error', code: 'AWFUL_ERROR'})); + mockedRequests.push(mockRequestWithError({ message: 'test error', code: 'AWFUL_ERROR' })); const client = new HttpClient(); const err = 'Error while making request: test error. Error code: AWFUL_ERROR'; return client.send({ @@ -686,7 +686,7 @@ describe('HttpClient', () => { }); it('should timeout when the response is repeatedly delayed', () => { - const respData = {foo: 'bar'}; + const respData = { foo: 'bar' }; const scope = nock('https://' + mockHost) .get(mockPath) .times(5) @@ -707,7 +707,7 @@ describe('HttpClient', () => { }); it('should timeout when multiple socket timeouts encountered', () => { - const respData = {foo: 'bar timeout'}; + const respData = { foo: 'bar timeout' }; const scope = nock('https://' + mockHost) .get(mockPath) .times(5) @@ -729,7 +729,7 @@ describe('HttpClient', () => { it('should be rejected, after 4 retries, on multiple network errors', () => { for (let i = 0; i < 5; i++) { - mockedRequests.push(mockRequestWithError({message: `connection reset ${i + 1}`, code: 'ECONNRESET'})); + mockedRequests.push(mockRequestWithError({ message: `connection reset ${i + 1}`, code: 'ECONNRESET' })); } const client = new HttpClient(testRetryConfig()); @@ -767,8 +767,8 @@ describe('HttpClient', () => { }); it('should succeed, after 1 retry, on a single network error', () => { - mockedRequests.push(mockRequestWithError({message: 'connection reset 1', code: 'ECONNRESET'})); - const respData = {foo: 'bar'}; + mockedRequests.push(mockRequestWithError({ message: 'connection reset 1', code: 'ECONNRESET' })); + const respData = { foo: 'bar' }; const scope = nock('https://' + mockHost) .get(mockPath) .reply(200, respData, { @@ -786,7 +786,7 @@ describe('HttpClient', () => { }); it('should not retry when RetryConfig is explicitly null', () => { - mockedRequests.push(mockRequestWithError({message: 'connection reset 1', code: 'ECONNRESET'})); + mockedRequests.push(mockRequestWithError({ message: 'connection reset 1', code: 'ECONNRESET' })); const client = new HttpClient(null); const err = 'Error while making request: connection reset 1'; return client.send({ @@ -796,7 +796,7 @@ describe('HttpClient', () => { }); it('should not retry when maxRetries is set to 0', () => { - mockedRequests.push(mockRequestWithError({message: 'connection reset 1', code: 'ECONNRESET'})); + mockedRequests.push(mockRequestWithError({ message: 'connection reset 1', code: 'ECONNRESET' })); const client = new HttpClient({ maxRetries: 0, ioErrorCodes: ['ECONNRESET'], @@ -810,7 +810,7 @@ describe('HttpClient', () => { }); it('should not retry when error codes are not configured', () => { - mockedRequests.push(mockRequestWithError({message: 'connection reset 1', code: 'ECONNRESET'})); + mockedRequests.push(mockRequestWithError({ message: 'connection reset 1', code: 'ECONNRESET' })); const client = new HttpClient({ maxRetries: 1, maxDelayInMillis: 10000, @@ -823,8 +823,8 @@ describe('HttpClient', () => { }); it('should succeed after a retry on a configured I/O error', () => { - mockedRequests.push(mockRequestWithError({message: 'connection reset 1', code: 'ETESTCODE'})); - const respData = {foo: 'bar'}; + mockedRequests.push(mockRequestWithError({ message: 'connection reset 1', code: 'ETESTCODE' })); + const respData = { foo: 'bar' }; const scope = nock('https://' + mockHost) .get(mockPath) .reply(200, respData, { @@ -852,7 +852,7 @@ describe('HttpClient', () => { 'content-type': 'application/json', }); mockedRequests.push(scope1); - const respData = {foo: 'bar'}; + const respData = { foo: 'bar' }; const scope2 = nock('https://' + mockHost) .get(mockPath) .reply(200, respData, { @@ -871,8 +871,8 @@ describe('HttpClient', () => { it('should not retry more than maxRetries', () => { // simulate 2 low-level errors - mockedRequests.push(mockRequestWithError({message: 'connection reset 1', code: 'ECONNRESET'})); - mockedRequests.push(mockRequestWithError({message: 'connection reset 2', code: 'ECONNRESET'})); + mockedRequests.push(mockRequestWithError({ message: 'connection reset 1', code: 'ECONNRESET' })); + mockedRequests.push(mockRequestWithError({ message: 'connection reset 2', code: 'ECONNRESET' })); // followed by 3 HTTP errors const scope = nock('https://' + mockHost) @@ -1020,7 +1020,7 @@ describe('HttpClient', () => { 'retry-after': '30', }); mockedRequests.push(scope1); - const respData = {foo: 'bar'}; + const respData = { foo: 'bar' }; const scope2 = nock('https://' + mockHost) .get(mockPath) .reply(200, respData, { @@ -1056,7 +1056,7 @@ describe('HttpClient', () => { 'retry-after': timestamp.toUTCString(), }); mockedRequests.push(scope1); - const respData = {foo: 'bar'}; + const respData = { foo: 'bar' }; const scope2 = nock('https://' + mockHost) .get(mockPath) .reply(200, respData, { @@ -1090,7 +1090,7 @@ describe('HttpClient', () => { 'retry-after': timestamp.toUTCString(), }); mockedRequests.push(scope1); - const respData = {foo: 'bar'}; + const respData = { foo: 'bar' }; const scope2 = nock('https://' + mockHost) .get(mockPath) .reply(200, respData, { @@ -1122,7 +1122,7 @@ describe('HttpClient', () => { 'retry-after': 'invalid', }); mockedRequests.push(scope1); - const respData = {foo: 'bar'}; + const respData = { foo: 'bar' }; const scope2 = nock('https://' + mockHost) .get(mockPath) .reply(200, respData, { @@ -1158,7 +1158,7 @@ describe('HttpClient', () => { }); it('should use the port 80 for http URLs', () => { - const respData = {foo: 'bar'}; + const respData = { foo: 'bar' }; const scope = nock('http://' + mockHost + ':80') .get('/') .reply(200, respData, { @@ -1175,7 +1175,7 @@ describe('HttpClient', () => { }); it('should use the port specified in the URL', () => { - const respData = {foo: 'bar'}; + const respData = { foo: 'bar' }; const scope = nock('https://' + mockHost + ':8080') .get('/') .reply(200, respData, { @@ -1223,7 +1223,7 @@ describe('AuthorizedHttpClient', () => { }); it('should be fulfilled for a 2xx response with a json payload', () => { - const respData = {foo: 'bar'}; + const respData = { foo: 'bar' }; const scope = nock('https://' + mockHost, requestHeaders) .get(mockPath) .reply(200, respData, { @@ -1265,7 +1265,7 @@ describe('AuthorizedHttpClient', () => { }); it('should use the HTTP agent set in request', () => { - const respData = {success: true}; + const respData = { success: true }; const scope = nock('https://' + mockHost, requestHeaders) .get(mockPath) .reply(200, respData, { @@ -1287,7 +1287,7 @@ describe('AuthorizedHttpClient', () => { }); it('should use the HTTP agent set in AppOptions', () => { - const respData = {success: true}; + const respData = { success: true }; const scope = nock('https://' + mockHost, requestHeaders) .get(mockPath) .reply(200, respData, { @@ -1308,8 +1308,8 @@ describe('AuthorizedHttpClient', () => { }); it('should make a POST request with the provided headers and data', () => { - const reqData = {request: 'data'}; - const respData = {success: true}; + const reqData = { request: 'data' }; + const respData = { success: true }; const options = { reqheaders: { 'Content-Type': (header: string) => { @@ -1341,7 +1341,7 @@ describe('AuthorizedHttpClient', () => { }); it('should not mutate the arguments', () => { - const reqData = {request: 'data'}; + const reqData = { request: 'data' }; const options = { reqheaders: { 'Content-Type': (header: string) => { @@ -1353,7 +1353,7 @@ describe('AuthorizedHttpClient', () => { Object.assign(options.reqheaders, requestHeaders.reqheaders); const scope = nock('https://' + mockHost, options) .post(mockPath, reqData) - .reply(200, {success: true}, { + .reply(200, { success: true }, { 'content-type': 'application/json', }); mockedRequests.push(scope); @@ -1464,7 +1464,7 @@ describe('parseHttpResponse()', () => { expect(response.headers).to.have.property('content-type', 'application/json'); expect(response.headers).to.have.property('date', 'Thu, 07 Feb 2019 19:20:34 GMT'); expect(response.isJson()).to.be.true; - expect(response.data).to.deep.equal({foo: 1}); + expect(response.data).to.deep.equal({ foo: 1 }); expect(response.text).to.equal('{"foo": 1}'); }); @@ -1482,7 +1482,7 @@ describe('parseHttpResponse()', () => { expect(response.headers).to.have.property('content-type', 'application/json'); expect(response.headers).to.have.property('date', 'Thu, 07 Feb 2019 19:20:34 GMT'); expect(response.isJson()).to.be.true; - expect(response.data).to.deep.equal({foo: 1}); + expect(response.data).to.deep.equal({ foo: 1 }); expect(response.text).to.equal('{"foo": 1}'); }); diff --git a/test/unit/utils/error.spec.ts b/test/unit/utils/error.spec.ts index 41e977f725..3b9e59269d 100755 --- a/test/unit/utils/error.spec.ts +++ b/test/unit/utils/error.spec.ts @@ -33,7 +33,7 @@ const expect = chai.expect; describe('FirebaseError', () => { const code = 'code'; const message = 'message'; - const errorInfo = {code, message}; + const errorInfo = { code, message }; it('should initialize successfully with error info specified', () => { const error = new FirebaseError(errorInfo); expect(error.code).to.be.equal(code); @@ -49,7 +49,7 @@ describe('FirebaseError', () => { it('toJSON() should resolve with the expected object', () => { const error = new FirebaseError(errorInfo); - expect(error.toJSON()).to.deep.equal({code, message}); + expect(error.toJSON()).to.deep.equal({ code, message }); }); }); diff --git a/test/unit/utils/index.spec.ts b/test/unit/utils/index.spec.ts index 2065e2fb49..1cd683de48 100755 --- a/test/unit/utils/index.spec.ts +++ b/test/unit/utils/index.spec.ts @@ -15,7 +15,7 @@ */ import * as _ from 'lodash'; -import {expect} from 'chai'; +import { expect } from 'chai'; import * as sinon from 'sinon'; import * as mocks from '../../resources/mocks'; @@ -23,8 +23,8 @@ import { addReadonlyGetter, getExplicitProjectId, findProjectId, toWebSafeBase64, formatString, generateUpdateMask, } from '../../../src/utils/index'; -import {isNonEmptyString} from '../../../src/utils/validator'; -import {FirebaseApp, FirebaseAppOptions} from '../../../src/firebase-app'; +import { isNonEmptyString } from '../../../src/utils/validator'; +import { FirebaseApp, FirebaseAppOptions } from '../../../src/firebase-app'; import { ComputeEngineCredential } from '../../../src/auth/credential'; import { HttpClient } from '../../../src/utils/api-request'; import * as utils from '../utils'; diff --git a/test/unit/utils/validator.spec.ts b/test/unit/utils/validator.spec.ts index c8ab764f93..bcf2a67d3a 100755 --- a/test/unit/utils/validator.spec.ts +++ b/test/unit/utils/validator.spec.ts @@ -307,7 +307,7 @@ describe('isUid()', () => { }); it('should return false with an invalid type', () => { - expect(isUid({uid: createRandomString(1)})).to.be.false; + expect(isUid({ uid: createRandomString(1) })).to.be.false; }); it('should return false with an empty string', () => { @@ -355,7 +355,7 @@ describe('isEmail()', () => { }); it('should return false with a non string', () => { - expect(isEmail({email: 'user@example.com'})).to.be.false; + expect(isEmail({ email: 'user@example.com' })).to.be.false; }); it('show return true with a valid email string', () => { From ac40e916300b360cbc33e0e1ba662250dd9f907e Mon Sep 17 00:00:00 2001 From: MathBunny Date: Thu, 9 Jul 2020 15:50:29 -0400 Subject: [PATCH 2/2] Remove fix tag from package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 453ae3933e..4d6791b7a1 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,8 @@ "test:unit": "mocha test/unit/*.spec.ts --require ts-node/register", "test:integration": "mocha test/integration/*.ts --slow 5000 --timeout 20000 --require ts-node/register", "test:coverage": "nyc npm run test:unit", - "lint:src": "eslint src/ --ext .ts --fix", - "lint:test": "eslint test/ --ext .ts --fix", + "lint:src": "eslint src/ --ext .ts", + "lint:test": "eslint test/ --ext .ts", "apidocs": "node docgen/generate-docs.js --api node" }, "nyc": {