Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mnajdova committed Dec 12, 2020
1 parent 2e991bc commit c37d4f7
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions packages/material-ui/src/styles/experimentalStyled.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,12 +441,20 @@ describe('experimentalStyled', () => {

const { container } = render(<Component>Test</Component>);

expect(container.firstChild.getAttribute('class').includes('MuiComponent-slot')).to.equal(
true,
);
const classList = Array.from(container.firstChild.classList);
const regExp = new RegExp(`.*-MuiComponent-slot$`);
let containsValidClass = false;

classList.forEach((className) => {
if (regExp.test(className)) {
containsValidClass = true;
}
});

expect(containsValidClass).to.equal(true);
});

it('should use name as className when slot is not specified', () => {
it('should set the className as root if no slot is specified', () => {
const Component = styled(
'div',
{ shouldForwardProp: (prop) => prop !== 'variant' && prop !== 'size' && prop !== 'sx' },
Expand All @@ -458,7 +466,17 @@ describe('experimentalStyled', () => {

const { container } = render(<Component>Test</Component>);

expect(container.firstChild.getAttribute('class').includes('Component')).to.equal(true);
const classList = Array.from(container.firstChild.classList);
const regExp = new RegExp(`.*-MuiComponent-root$`);
let containsValidClass = false;

classList.forEach((className) => {
if (regExp.test(className)) {
containsValidClass = true;
}
});

expect(containsValidClass).to.equal(true);
});
});
});

0 comments on commit c37d4f7

Please sign in to comment.