-
Notifications
You must be signed in to change notification settings - Fork 13
feat: [UEPR-56] Migrate to React 18 #139
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: develop
Are you sure you want to change the base?
feat: [UEPR-56] Migrate to React 18 #139
Conversation
…ct-tooltip back to 4.5.1
expect(handleClick).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
test('matches snapshot', () => { |
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.
If the component matches the snapshot it would be the same as the result of renders with all props correctly
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 would rather leave the snapshot test rather than renders with all props correctly
. The second one will not fail if we add new props to the component and we may miss updating the test. Whereas if the snapshot is old it will fail
const component = renderer.create( | ||
<ButtonComponent onClick={onClick} /> | ||
const { container } = render( | ||
<ButtonComponent onClick={jest.fn()} /> |
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.
At some places it is used const onClick = jest.fn();
and at others jest.fn()
is passed directly to onClick. We should unify the syntax everywhere
); | ||
expect(component.toJSON()).toMatchSnapshot(); | ||
|
||
expect(container.firstChild).toMatchSnapshot(); | ||
}); | ||
|
||
test('triggers callback when clicked', () => { |
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 would add a test that the callback is not triggered if not clicked.
expect(imageStep.props().title).toEqual('id1 - name'); | ||
const divWithText = [...container.querySelectorAll('div')].find(el => el.textContent.includes('id1 - name')); | ||
expect(divWithText).toBeTruthy(); | ||
expect(divWithText).toHaveTextContent('id1 - name'); |
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.
if divWithText
is truthy wouldn't that mean it has the text context, because we use it in the query selector. Same for the image
img={imgSrc} | ||
title={title} | ||
onClick={onClick} | ||
test('triggers callback only once when clicked', () => { |
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 would add a test that the callback is not triggered if not clicked.
if (!button) { | ||
throw new Error('Button not found'); | ||
} |
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 am not sure if we need such error handling here
…le buttons, save status
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.
🤝
Ticket:
UEPR-56
This pull request includes an upgrade to the intl library and react 18.