-
Notifications
You must be signed in to change notification settings - Fork 96
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
MNT Use React Testing Library #1497
MNT Use React Testing Library #1497
Conversation
6d57979
to
21a23fa
Compare
18d5e03
to
c05a763
Compare
a4bec51
to
4e89f22
Compare
|
||
describe('lazyLoad()', () => { |
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.
Even after spending several hours on this, I was simply unable to get lazyLoad() to trigger
4e89f22
to
4ad23cf
Compare
|
||
describe('handleKeyDown()', () => { |
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.
These were all testing whether a class method was called, rather than testing if a callback passed as a callback was called
4ad23cf
to
18fe346
Compare
|
||
describe('getDropdownOptions()', () => { |
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.
These were all testing the output of a class method that was passed as a prop to a react-select component
18fe346
to
9beffce
Compare
|
||
describe('getPath()', () => { | ||
it('should return a breadcrumb path separated by /', () => { |
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 test is now covered by TreeDropdownField getBreadcrumb() should traverse the path given and return the relevant nodes in the tree
9beffce
to
ac44f1e
Compare
expect(wrapper.find(Button).length).toEqual(2); | ||
}); | ||
|
||
it('render all buttons matching the search term', () => { |
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.
These two tests would rely on logic passed in from the onSearch callback i.e. these tests wouldn't be testing anything within the actual code
ac44f1e
to
ec16b84
Compare
@@ -1,96 +0,0 @@ | |||
/* global jest, describe, it, expect, beforeEach */ |
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 component doesn't render at all when using RTL
ec16b84
to
b06da91
Compare
@@ -1,76 +0,0 @@ | |||
/* global jest, describe, beforeEach, it, expect */ |
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.
Changed the casing of the filename to 'Breadcrumb-test.js'
b06da91
to
2af0267
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.
Just small comment from https://testing-library.com/docs/react-testing-library/api/#container-1
If you find yourself using container to query for rendered elements then you should reconsider! The other queries are designed to be more resilient to changes that will be made to the component you're testing. Avoid using container to query for elements!
client/src/components/CompositeField/tests/CompositeField-test.js
Outdated
Show resolved
Hide resolved
We're way too far through this progress to move away from container based querying at this point since that's what the majority of the refactored tests use |
2af0267
to
33391ab
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.
Nice work! Looks good to me 👍
Issue #1508