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

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

Merged
merged 5 commits into from Jul 9, 2019

Conversation

@jenny-s51
Copy link
Contributor

jenny-s51 commented Jul 9, 2019

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

@patternfly-build

This comment has been minimized.

Copy link
Contributor

patternfly-build commented Jul 9, 2019

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');

This comment has been minimized.

Copy link
@jeff-phillips-18

jeff-phillips-18 Jul 9, 2019

Member

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

This comment has been minimized.

Copy link
@TheRealJon

TheRealJon Jul 9, 2019

Contributor

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?

This comment has been minimized.

Copy link
@jenny-s51

jenny-s51 Jul 9, 2019

Author Contributor

@jeff-phillips-18 what do you think?

This comment has been minimized.

Copy link
@jeff-phillips-18

jeff-phillips-18 Jul 9, 2019

Member

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');

This comment has been minimized.

Copy link
@TheRealJon

TheRealJon Jul 9, 2019

Contributor

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 Jul 9, 2019
Co-Authored-By: Jon Jackson <jonjacks@redhat.com>
Co-Authored-By: Jon Jackson <jonjacks@redhat.com>
@jenny-s51 jenny-s51 requested review from jeff-phillips-18 and TheRealJon Jul 9, 2019
Copy link
Member

jeff-phillips-18 left a comment

LGTM! 👍

Copy link
Contributor

redallen left a comment

Jest is fun :) 👍

@redallen redallen merged commit 86981f6 into patternfly:master Jul 9, 2019
8 checks passed
8 checks passed
ci/circleci: build Your tests passed on CircleCI!
Details
ci/circleci: build_integration Your tests passed on CircleCI!
Details
ci/circleci: build_pf3_docs Your tests passed on CircleCI!
Details
ci/circleci: build_pf4_docs Your tests passed on CircleCI!
Details
ci/circleci: lint Your tests passed on CircleCI!
Details
ci/circleci: test_jest_other Your tests passed on CircleCI!
Details
ci/circleci: test_jest_pf4 Your tests passed on CircleCI!
Details
ci/circleci: upload_docs Your tests passed on CircleCI!
Details
@jenny-s51 jenny-s51 deleted the jenny-s51:iss1624 branch Jul 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.