-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: Adds findAll finder to test utils #53
Conversation
a8e1435
to
2337d60
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #53 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 27 27
Lines 348 348
Branches 31 31
=========================================
Hits 348 348 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
// Every component has the same set of selector functions. | ||
// For this reason, casting the function names into the Alert component. | ||
const findName = `find${componentNamePascalCase}` as "findCodeView"; | ||
const findAllName = wrapperPropsList.find((selector) => findAllRegex.test(selector)) as "findAllCodeViews"; |
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.
Why here the type of findName and findAllName as "findCodeView"
? Can it be other component?
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 is for simplification. All of the findAllXX
and findXX
behave exactly the same. So casting it into one of them is enough for this test. Otherwise there's nothing special about CodeViews
. It can be any other component from this repo.
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.
Also fixed the comment above ✅
}, | ||
]; | ||
|
||
function renderComponents(componentName: string, props = RENDER_COMPONENTS_DEFAULT_PROPS) { |
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.
Will we extend it to more than CodeView? What to do if different components need different props?
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.
We have the same pattern in all of the repos (except components
), which we read the needed props from defaultProps
file (Line 25
).
2337d60
to
0610b55
Compare
Description
Adds two
findAll[COMPONENT_NAME]s()
test utils selectors to each component wrapper.Similar to: cloudscape-design/components#3024
Depends on cloudscape-design/test-utils#74
Related links, issue #, if available: Test utils API improvements project
How has this been tested?
✅ Copies including the JSDocs and the pluralizations have been reviewed by the content team.
🧪 Unit tests added to both selectors and dom test utils.
Related links, issue #, if available: Test utils API improvements project
Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md
.CONTRIBUTING.md
.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.