Skip to content

Commit

Permalink
fix: improve test case
Browse files Browse the repository at this point in the history
  • Loading branch information
kkmch committed Oct 31, 2023
1 parent 6ccbcec commit 8c88946
Showing 1 changed file with 1 addition and 31 deletions.
32 changes: 1 addition & 31 deletions src/hooks/useUniqId/__tests__/useUniqId.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,37 +38,7 @@ const TestComponentWithFallback = () => {
);
};
describe('useUniqId', () => {
test.each([
{
Component: TestComponentReact,
uniqId: 'g-:r0:',
},
{
Component: TestComponentWithFallback,
uniqId: 'yc-uniq-1',
},
])('should return the same id on different calls', ({Component, uniqId}) => {
render(<Component />);

const uniqIdElement = screen.getByTestId(uniqId);
const clickedAmountElement = screen.getByTestId(
`${TEST_COMPONENT_CLICKED_AMOUNT_ID}${uniqId}`,
);
const uniqId1 = uniqIdElement.textContent;
const clickedAmount1 = Number(clickedAmountElement.textContent);
act(() => {
uniqIdElement.click();
});
const uniqId2 = uniqIdElement.textContent;
const clickedAmount2 = Number(clickedAmountElement.textContent);

expect(uniqId1).toBe(uniqId);
expect(uniqId2).toBe(uniqId);
expect(clickedAmount1).toBe(0);
expect(clickedAmount2).toBe(1);
});

test.each([
it.each([
{
Component: TestComponentReact,
uniqId1: 'g-:r0:',
Expand Down

0 comments on commit 8c88946

Please sign in to comment.