FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(unit tests): tests now pass in util.test.js by jenny-s51 · Pull Request #2489 · patternfly/patternfly-react · GitHub

fix(unit tests): tests now pass in util.test.js - #2489

Merged
redallen merged 5 commits into
patternfly:masterfrom
jenny-s51:iss1624
Jul 9, 2019
Merged

fix(unit tests): tests now pass in util.test.js#2489
redallen merged 5 commits into
patternfly:masterfrom
jenny-s51:iss1624

Conversation

Copy link
Copy Markdown
Contributor

What: Closes #1624 and fixes keyHandler tests in util.test.js -- tests are now passing.

Copy link
Copy Markdown
Collaborator

PatternFly-React preview: https://patternfly-react-pr-2489.surge.sh

secondDropdownItem.simulate('keydown', { key: 'ArrowUp', keyCode: KEY_CODES.ARROW_UP, which: KEY_CODES.ARROW_UP });
expect(firstDropdownItem === document.activeElement).toBe(true);
let focusedElement = document.activeElement;
expect(focusedElement.getAttribute('id')).toEqual('second');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I would remove the initial expected focus item check from each of the tests. This makes each test depend on the previous test.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Since there is no set-up or tear-down between each test case, they will depend on the previous test regardless. The following tests will fail if the DOM is not in the correct state. Maybe we should be initializing the DOM state from scratch on each test case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@jeff-phillips-18 what do you think?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think it's ok to just remove the init checks. The initial state is not handled by the utils and thus need not be tested here.

secondDropdownItem.simulate('keydown', { key: 'ArrowUp', keyCode: KEY_CODES.ARROW_UP, which: KEY_CODES.ARROW_UP });
expect(firstDropdownItem === document.activeElement).toBe(true);
let focusedElement = document.activeElement;
expect(focusedElement.getAttribute('id')).toEqual('second');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Since there is no set-up or tear-down between each test case, they will depend on the previous test regardless. The following tests will fail if the DOM is not in the correct state. Maybe we should be initializing the DOM state from scratch on each test case?

jenny-s51 and others added 2 commits July 9, 2019 14:03
Co-Authored-By: Jon Jackson <jonjacks@redhat.com>
Co-Authored-By: Jon Jackson <jonjacks@redhat.com>

jeff-phillips-18 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM! 👍

redallen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Jest is fun :) 👍

redallen merged commit 86981f6 into patternfly:master Jul 9, 2019
jenny-s51 deleted the iss1624 branch July 17, 2019 18:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

Unit tests for util.ts are broken.

5 participants


Back | FazBrowse Home | New Git URL