-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests for govuk-c-warning-text
component
#479
Conversation
govuk-c-warning-text
component
govuk-c-warning-text
componentgovuk-c-warning-text
component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks great. I think there's a couple of places where we could be clearer about what we want to be happening, either by using a clearer description or just making sure we're not testing too much at once.
expect($assistiveText.text()).toEqual('Warning') | ||
}) | ||
|
||
it('renders the default example with aria attribute for icon', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could be clearer with our intent here. How about something like…
It hides the icon from screen readers using the aria-hidden attribute
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A very good call 💯 Have amended.
expect($component.hasClass('govuk-c-warning-text--custom-class')).toBeTruthy() | ||
}) | ||
|
||
it('renders custom text and custom assistive text', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would make more sense as two different tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was in two minds about that but I think you're right. Have split it into two tests.
'data-test': 'attribute', | ||
'id': 'my-warning-text' | ||
}, | ||
html: '<span>Some custom warning text</span>' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't being tested here. Can it just be omitted?
fccf2fd
to
fb0d6f5
Compare
fb0d6f5
to
2fa7815
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff 👌
They test if the component: - renders the default example with text and assistive text - renders the default example with aria attribute for icon - renders classes - renders custom text and custom assistive text - renders escaped html when passed to text - renders html - renders attributes
2fa7815
to
e90a6af
Compare
This PR adds Jest tests for the warning text component.
They test if the component: