Skip to content
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

Merged
merged 2 commits into from
Jan 29, 2018

Conversation

NickColley
Copy link
Contributor

@NickColley NickColley commented Jan 24, 2018

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.

As per https://trello.com/c/LzkwDRYe/639-automated-tests-for-button-component

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-461 January 24, 2018 16:35 Inactive
@NickColley
Copy link
Contributor Author

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.

@NickColley NickColley changed the title Add Jest test for button component Add tests for govuk-c-button component Jan 24, 2018
@NickColley NickColley force-pushed the add-tests-for-button-component branch from 1469f36 to cff0629 Compare January 25, 2018 11:06
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-461 January 25, 2018 11:07 Inactive
@NickColley
Copy link
Contributor Author

@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', () => {
Copy link
Contributor

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')
Copy link
Contributor

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('/')
Copy link
Contributor

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>')
Copy link
Contributor

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)
Copy link
Contributor

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?

@NickColley NickColley force-pushed the add-tests-for-button-component branch from cff0629 to 92026b9 Compare January 29, 2018 10:53
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-461 January 29, 2018 10:53 Inactive
@NickColley NickColley force-pushed the add-tests-for-button-component branch from 92026b9 to 9a33c88 Compare January 29, 2018 10:57
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-461 January 29, 2018 10:57 Inactive
@NickColley
Copy link
Contributor Author

@36degrees updated based on your comments

Copy link
Contributor

@alex-ju alex-ju left a 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 👍

@NickColley
Copy link
Contributor Author

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.
@NickColley NickColley merged commit 60a75ea into master Jan 29, 2018
@NickColley NickColley deleted the add-tests-for-button-component branch January 29, 2018 16:50
@alex-ju alex-ju mentioned this pull request Feb 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants