Skip to content

Commit

Permalink
Merge pull request #288 from bertdeblock/improve-return-type-of-get-p…
Browse files Browse the repository at this point in the history
…age-title-test-helper

Improve return type of `getPageTitle` test helper
  • Loading branch information
NullVoxPopuli committed Feb 15, 2024
2 parents 051ccd2 + 1a71c02 commit bd273e7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions addon/src/test-support/get-page-title.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// 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 <title> from app/index.html
// We are keeping both for sake for testing browser and fastboot scenarios
const element = [
...(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 '';
}

0 comments on commit bd273e7

Please sign in to comment.