-
Notifications
You must be signed in to change notification settings - Fork 327
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-button
component
#461
Conversation
This PR includes duplicate testing for inputs based on an assumption that the forking elements could break 'attributes' 'classes' (etc) from being applied. I'm not sure if we need to be so strict. Comments welcome. |
govuk-c-button
component
1469f36
to
cff0629
Compare
@36degrees I've reworded the tests so they read correctly, I'm not sure how to break them up as you described without losing track of the code coverage, if you want to do more than in this PR let's catch up and do it together. |
}) | ||
|
||
describe('implicit button element', () => { | ||
it('renders a link if you pass an href', () => { |
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.
Context is 'implicit button element' but this is testing for an implicit link?
const $component = $('.govuk-c-button') | ||
expect($component.get(0).tagName).toEqual('input') | ||
expect($component.attr('type')).toEqual('submit') | ||
expect($component.val()).toContain('Save and continue') |
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 don't think this should be being expected as part of this test.
|
||
const $component = $('.govuk-c-button') | ||
expect($component.get(0).tagName).toEqual('a') | ||
expect($component.attr('href')).toEqual('/') |
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 doesn't relate to the test description. I think we should just be testing that it's rendering a link.
|
||
const $component = $('.govuk-c-button') | ||
expect($component.get(0).tagName).toEqual('button') | ||
expect($component.html()).toContain('Start <em>now</em>') |
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.
Again, I think we should just be testing that we render a button
.
|
||
describe('link', () => { | ||
it('renders with anchor, href and an accessible role of button', () => { | ||
const { $ } = render('button', examples.link) |
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.
The link
example is an implicit link, because it specifies an href
but not an element
. So I think this is testing the same thing as the implicit link test on :223
?
cff0629
to
92026b9
Compare
92026b9
to
9a33c88
Compare
@36degrees updated based on your comments |
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.
Looks good to me 👍
One last thing - I need to add an entry to the changelog. |
We break this down into four groups (as represented by describe blocks). 1. Input buttons 2. Link buttons 3. Explicit buttons 4. Implicit buttons Also removes examples in `button.yaml` that are now covered by tests.
9a33c88
to
580eb45
Compare
We break this down into four groups (as represented by describe blocks).
Also removes examples in
button.yaml
that are now covered by tests.As per https://trello.com/c/LzkwDRYe/639-automated-tests-for-button-component