From fd58aebaedd122bdbdd24dfea8c7240a85364bc6 Mon Sep 17 00:00:00 2001 From: Prof Darrel Francis <20881844+darrelfrancis@users.noreply.github.com> Date: Sat, 15 Apr 2023 12:40:09 +0100 Subject: [PATCH] Remove elvis operator `?.` Fixes https://github.com/prescottprue/cypress-firebase/issues/788 --- src/attachCustomCommands.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/attachCustomCommands.ts b/src/attachCustomCommands.ts index 8358ca09..93821645 100644 --- a/src/attachCustomCommands.ts +++ b/src/attachCustomCommands.ts @@ -338,7 +338,7 @@ export default function attachCustomCommands( * @name cy.login */ Cypress.Commands.add( - options?.commandNames?.login || 'login', + options && options.commandNames && options.commandNames.login || 'login', ( uid?: string, customClaims?: any, @@ -379,7 +379,7 @@ export default function attachCustomCommands( * cy.logout() */ Cypress.Commands.add( - options?.commandNames?.logout || 'logout', + options && options.commandNames && options.commandNames.logout || 'logout', ( tenantId: string | undefined = Cypress.env('TEST_TENANT_ID'), ): Promise => @@ -408,7 +408,7 @@ export default function attachCustomCommands( * @name cy.callRtdb */ Cypress.Commands.add( - options?.commandNames?.callRtdb || 'callRtdb', + options && options.commandNames && options.commandNames.callRtdb || 'callRtdb', ( action: RTDBAction, actionPath: string, @@ -426,7 +426,7 @@ export default function attachCustomCommands( const dataToWrite = dataIsObject ? { ...dataOrOptions } : dataOrOptions; // Add metadata to dataToWrite if specified by options - if (dataIsObject && options?.withMeta) { + if (dataIsObject && options && options.withMeta) { if (!dataToWrite.createdBy && Cypress.env('TEST_UID')) { dataToWrite.createdBy = Cypress.env('TEST_UID'); } @@ -456,7 +456,7 @@ export default function attachCustomCommands( * @name cy.callFirestore */ Cypress.Commands.add( - options?.commandNames?.callFirestore || 'callFirestore', + options && options.commandName && options.commandNames.callFirestore || 'callFirestore', ( action: FirestoreAction, actionPath: string, @@ -474,7 +474,7 @@ export default function attachCustomCommands( const dataToWrite = dataIsObject ? { ...dataOrOptions } : dataOrOptions; // Add metadata to dataToWrite if specified by options - if (dataIsObject && options?.withMeta) { + if (dataIsObject && options && options.withMeta) { if (!dataToWrite.createdBy) { dataToWrite.createdBy = Cypress.env('TEST_UID'); } @@ -503,7 +503,7 @@ export default function attachCustomCommands( * cy.getAuthUser() */ Cypress.Commands.add( - options?.commandNames?.getAuthUser || 'getAuthUser', + options && options.commandName && options.commandNames.getAuthUser || 'getAuthUser', (uid: string): Promise => cy.task('getAuthUser', uid), ); }