From 1a71c02613de5639b4ce653fb79d30a7bdec567f Mon Sep 17 00:00:00 2001 From: Bert De Block Date: Thu, 15 Feb 2024 09:54:27 +0100 Subject: [PATCH] Improve return type of `getPageTitle` test helper --- addon/src/test-support/get-page-title.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/addon/src/test-support/get-page-title.ts b/addon/src/test-support/get-page-title.ts index 6918ca9..35ea1cb 100644 --- a/addon/src/test-support/get-page-title.ts +++ b/addon/src/test-support/get-page-title.ts @@ -1,7 +1,7 @@ // Testem appends progress to the title... // and there's no way to stop this at the moment -export function getPageTitle(doc: Document) { +export function getPageTitle(doc?: Document): string { // In Fastboot context we get 2 title elements if we don't remove one from app/index.html // In real world applications, it is mandatory to remove from app/index.html // We are keeping both for sake for testing browser and fastboot scenarios @@ -9,9 +9,9 @@ export function getPageTitle(doc: Document) { ...(doc || window.document).querySelectorAll('head title'), ].pop(); - return ( - element && - element instanceof HTMLTitleElement && - element.innerText.trim().replace(/^\(\d+\/\d+\)/, '') - ); + if (element instanceof HTMLTitleElement) { + return element.innerText.trim().replace(/^\(\d+\/\d+\)/, ''); + } + + return ''; }