Skip to content

Commit

Permalink
Update table pagination tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoAndai committed Sep 22, 2023
1 parent 5859dc3 commit 9f0e07d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('<TablePagination />', () => {

describe('prop: labelRowsPerPage', () => {
it('labels the select for the current page', () => {
const { getAllByRole } = render(
const { getByRole } = render(
<table>
<TableFooter>
<TableRow>
Expand All @@ -100,13 +100,12 @@ describe('<TablePagination />', () => {
</table>,
);

// will be `getByRole('combobox')` in aria 1.2
const [combobox] = getAllByRole('combobox');
const combobox = getByRole('combobox');
expect(combobox).toHaveAccessibleName('lines per page:');
});

it('accepts React nodes', () => {
const { getAllByRole } = render(
const { getByRole } = render(
<table>
<TableFooter>
<TableRow>
Expand All @@ -127,8 +126,7 @@ describe('<TablePagination />', () => {
</table>,
);

// will be `getByRole('combobox')` in aria 1.2
const [combobox] = getAllByRole('combobox');
const combobox = getByRole('combobox');
expect(combobox).toHaveAccessibleName('lines per page:');
});
});
Expand Down Expand Up @@ -382,7 +380,7 @@ describe('<TablePagination />', () => {

describe('prop: SelectProps', () => {
it('does allow manual label ids', () => {
const { getAllByRole } = render(
const { getByRole } = render(
<table>
<TableFooter>
<TableRow>
Expand All @@ -399,8 +397,7 @@ describe('<TablePagination />', () => {
</table>,
);

// will be `getByRole('combobox')` in aria 1.2
const [combobox] = getAllByRole('combobox');
const combobox = getByRole('combobox');
expect(combobox).toHaveAccessibleName('Rows per page:');
});
});
Expand Down
19 changes: 8 additions & 11 deletions packages/mui-material/src/TablePagination/TablePagination.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describe('<TablePagination />', () => {

describe('prop: labelRowsPerPage', () => {
it('labels the select for the current page', () => {
const { getAllByRole } = render(
const { getByRole } = render(
<table>
<TableFooter>
<TableRow>
Expand All @@ -101,13 +101,12 @@ describe('<TablePagination />', () => {
</table>,
);

// will be `getByRole('combobox')` in aria 1.2
const [combobox] = getAllByRole('combobox');
const combobox = getByRole('combobox');
expect(combobox).toHaveAccessibleName('lines per page:');
});

it('accepts React nodes', () => {
const { getAllByRole } = render(
const { getByRole } = render(
<table>
<TableFooter>
<TableRow>
Expand All @@ -128,8 +127,7 @@ describe('<TablePagination />', () => {
</table>,
);

// will be `getByRole('combobox')` in aria 1.2
const [combobox] = getAllByRole('combobox');
const combobox = getByRole('combobox');
expect(combobox).toHaveAccessibleName('lines per page:');
});
});
Expand Down Expand Up @@ -383,7 +381,7 @@ describe('<TablePagination />', () => {

describe('prop: SelectProps', () => {
it('does allow manual label ids', () => {
const { getAllByRole } = render(
const { getByRole } = render(
<table>
<TableFooter>
<TableRow>
Expand All @@ -400,14 +398,13 @@ describe('<TablePagination />', () => {
</table>,
);

// will be `getByRole('combobox')` in aria 1.2
const [combobox] = getAllByRole('combobox');
const combobox = getByRole('combobox');
expect(combobox).toHaveAccessibleName('Rows per page:');
});

['standard', 'outlined', 'filled'].forEach((variant) => {
it(`should be able to apply the ${variant} variant to select`, () => {
const { getAllByRole } = render(
const { getByRole } = render(
<table>
<TableFooter>
<TableRow>
Expand All @@ -424,7 +421,7 @@ describe('<TablePagination />', () => {
</table>,
);

const [combobox] = getAllByRole('combobox');
const combobox = getByRole('combobox');
const comboboxContainer = combobox.parentElement;

if (variant === 'standard') {
Expand Down

0 comments on commit 9f0e07d

Please sign in to comment.