Skip to content

Commit

Permalink
Improve existing test coverage for navigation item
Browse files Browse the repository at this point in the history
  • Loading branch information
hannalaakso committed Sep 3, 2020
1 parent 41e25bf commit f3d5aaf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/govuk/components/header/header.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,19 @@ examples:
attributes:
data-attribute: my-attribute
data-attribute-2: my-attribute-2
- name: navigation item with html as text
hidden: true
data:
serviceName: Service Name
serviceUrl: '/components/header'
navigation:
- href: '#1'
text: <em>Navigation item 1</em>
active: true
- href: '#2'
text: <em>Navigation item 2</em>
- href: '#3'
text: <em>Navigation item 3</em>
- name: navigation item with html without link
hidden: true
data:
Expand Down
9 changes: 8 additions & 1 deletion src/govuk/components/header/template.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,14 @@ describe('header', () => {
expect($activeItem.hasClass('govuk-header__navigation-item--active'))
})

it('renders navigation item with html', () => {
it('allows navigation item text to be passed whilst escaping HTML entities', () => {
const $ = render('header', examples['navigation item with html as text'])

const $navigationLink = $('.govuk-header__navigation-item a')
expect($navigationLink.html()).toContain('&lt;em&gt;Navigation item 1&lt;/em&gt;')
})

it('allows navigation item HTML to be passed un-escaped', () => {
const $ = render('header', examples['navigation item with html'])

const $navigationLink = $('.govuk-header__navigation-item a')
Expand Down

0 comments on commit f3d5aaf

Please sign in to comment.