Skip to content

Commit

Permalink
[tests] Replace query selectors with getByTestId
Browse files Browse the repository at this point in the history
  • Loading branch information
jaebradley committed Sep 18, 2020
1 parent f948fa2 commit dfa3d8c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
6 changes: 2 additions & 4 deletions packages/material-ui/src/Checkbox/Checkbox.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,8 @@ describe('<Checkbox />', () => {

describe('prop: indeterminate', () => {
it('should render an indeterminate icon', () => {
const { container } = render(<Checkbox indeterminate />);
expect(container.querySelector('svg[data-testid="IndeterminateCheckBoxIcon"]')).not.to.equal(
null,
);
const { getByTestId } = render(<Checkbox indeterminate />);
expect(getByTestId('IndeterminateCheckBoxIcon')).not.to.equal(null);
});
});

Expand Down
4 changes: 2 additions & 2 deletions packages/material-ui/src/Chip/Chip.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,9 @@ describe('<Chip />', () => {
});

it('should render the delete icon with the deleteIcon and deleteIconSmall classes', () => {
const { container } = render(<Chip size="small" onDelete={() => {}} />);
const { getByTestId } = render(<Chip size="small" onDelete={() => {}} />);

const icon = container.querySelector('svg[data-testid="CancelIcon"]');
const icon = getByTestId('CancelIcon');
expect(icon).to.have.class(classes.deleteIcon);
expect(icon).to.have.class(classes.deleteIconSmall);
});
Expand Down
8 changes: 2 additions & 6 deletions packages/material-ui/src/Radio/Radio.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,14 @@ describe('<Radio />', () => {
describe('prop: unchecked', () => {
it('should render an unchecked icon', () => {
const { getAllByTestId } = render(<Radio />);
expect(
getAllByTestId("RadioButtonUncheckedIcon").length
).to.equal(1);
expect(getAllByTestId('RadioButtonUncheckedIcon').length).to.equal(1);
});
});

describe('prop: checked', () => {
it('should render a checked icon', () => {
const { getAllByTestId } = render(<Radio checked />);
expect(
getAllByTestId("RadioButtonCheckedIcon").length
).to.equal(1);
expect(getAllByTestId('RadioButtonCheckedIcon').length).to.equal(1);
});
});

Expand Down

0 comments on commit dfa3d8c

Please sign in to comment.