Skip to content

Commit

Permalink
Update template title tests to not catch SVG title element
Browse files Browse the repository at this point in the history
  • Loading branch information
querkmachine committed Oct 3, 2023
1 parent 46aac75 commit ebeab96
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/govuk-frontend/src/govuk/template.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,27 +121,29 @@ describe('Template', () => {
})
})

// These tests use a select that specifically looks for a <title> within the <head> of the page
// to prevent them from matching <title> elements within embedded SVGs.
describe('<title>', () => {
const expectedTitle =
'GOV.UK - The best place to find government services and information'
it(`defaults to '${expectedTitle}'`, () => {
const $ = renderTemplate()
expect($('title').text()).toEqual(expectedTitle)
expect($('head > title').text()).toEqual(expectedTitle)
})

it('can be overridden using the pageTitle block', () => {
const $ = renderTemplate({}, { pageTitle: 'Foo' })
expect($('title').text()).toEqual('Foo')
expect($('head > title').text()).toEqual('Foo')
})

it('does not have a lang attribute by default', () => {
const $ = renderTemplate()
expect($('title').attr('lang')).toBeUndefined()
expect($('head > title').attr('lang')).toBeUndefined()
})

it('can have a lang attribute specified using pageTitleLang', () => {
const $ = renderTemplate({ pageTitleLang: 'zu' })
expect($('title').attr('lang')).toEqual('zu')
expect($('head > title').attr('lang')).toEqual('zu')
})
})
})
Expand Down

0 comments on commit ebeab96

Please sign in to comment.