-
Notifications
You must be signed in to change notification settings - Fork 58
Increase test coverage #4394
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
base: main
Are you sure you want to change the base?
Increase test coverage #4394
Conversation
c1cc734
to
10815d6
Compare
); | ||
const btn = container.querySelector('.change-bg-btn'); | ||
await act(async () => { | ||
btn && fireEvent.click(btn); |
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.
I suppose this is only because of the querySelector possibly returning null? To satisfy the typechecking?
If the btn
does not exist in the document, the event will not be fired and the error might be hard to debug.
maybe something like this works as well:
const btn = await waitFor(() => container.querySelector('.btn'));
await act(async () => {
fireEvent.click(btn);
});
?
<div className="layer-cards"> | ||
{ | ||
layers.map(layer => ( | ||
layers.filter(backgroundLayerFilter).map(layer => ( |
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 catches!
it('calls onCancel when cancel is clicked', () => { | ||
const onCancel = jest.fn(); | ||
render(<FeatureLabelModal feature={feature} onOk={jest.fn()} onCancel={onCancel} />); | ||
// AntD Modal renders a button with aria-label 'Close' for cancel |
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.
// AntD Modal renders a button with aria-label 'Close' for cancel |
aria-label 'Close' is not used so the comment is not needed?
fireEvent.change(input, { target: { value: '1234567890' } }); | ||
const okBtn = screen.getByRole('button', { name: /ok/i }); | ||
fireEvent.click(okBtn); | ||
// the implementation is a bit surprising, but this is it rght now |
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.
I think the problem is this line:
https://github.com/terrestris/base-util/blob/1fa9960e00ef1c7189e5625b3662faffa3873a29/src/StringUtil/StringUtil.ts#L70C11-L70C12
And the test in the base-util
seems also off:
https://github.com/terrestris/base-util/blob/1fa9960e00ef1c7189e5625b3662faffa3873a29/src/StringUtil/StringUtil.spec.ts#L79
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! And some good catches.
Some tests might be dublicated? #4379 |
@sdobbert Yes, I am i favour of mergin yours first and then I'll update this PR. @simonseyock thanks for the Feedback, will adjust when I update this PR. |
I opened a new PR (#4399) merging some of these tests and changes into the existing testsuites from #4379 |
Description
This PR suggests to add several unit tests to increase the coverage percentage.
Two bugs wer uncovered, these are adressed in c2b5824, this should be carefully checked by any reviewers.
Related issues or pull requests
None.
Pull request type
Do you introduce a breaking change?
Checklist
BSD-2-Clause.
npm run check
locally).