Skip to content

Commit c28646b

Browse files
refactor(shared table): use within within(baseElement) when available
1 parent 8449905 commit c28646b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/shared/components/Table/Body/__tests__/Body.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('Body', () => {
2424

2525
it('Render <Body/> with 1 item', () => {
2626
const { baseElement } = renderWithContainer(<Body items={items} />, container);
27-
expect(screen.getAllByRole('row').length).toBe(1);
27+
expect(within(baseElement).getAllByRole('row').length).toBe(1);
2828
within(baseElement).getByText(items[0].cols.firstname.label);
2929
within(baseElement).getByText(items[0].cols.lastname.label);
3030
within(baseElement).getByText(items[0].cols.birthdate.label);

src/shared/components/Table/Header/__tests__/Header.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { renderWithContainer } from 'shared/testsUtils';
2-
import { screen } from 'shared/testsUtils/customRender';
2+
import { screen, within } from 'shared/testsUtils/customRender';
33
import Header from '../Header';
44

55
const defaultProps = {
@@ -30,7 +30,7 @@ describe('Header', () => {
3030
${undefined} | ${sortingMock} | ${undefined}
3131
${headersMock} | ${sortingMock} | ${(<th>child header</th>)}
3232
`('Should render Header when headers: $headers, sorting: $sorting', ({ headers, sorting, children }) => {
33-
renderWithContainer(
33+
const { baseElement } = renderWithContainer(
3434
<Header {...defaultProps} headers={headers} sorting={sorting}>
3535
{children}
3636
</Header>,
@@ -47,7 +47,7 @@ describe('Header', () => {
4747
columnHeaderNumber += 1;
4848
}
4949

50-
expect(screen.queryAllByRole('columnheader').length).toBe(columnHeaderNumber);
50+
expect(within(baseElement).queryAllByRole('columnheader').length).toBe(columnHeaderNumber);
5151
if (headers?.length > 0) {
5252
screen.getByText('label');
5353
}

0 commit comments

Comments
 (0)