From c37d4f7b9301d718597094bd35b470b63362bb09 Mon Sep 17 00:00:00 2001 From: Marija Najdova Date: Sat, 12 Dec 2020 23:24:25 +0100 Subject: [PATCH] updated tests --- .../src/styles/experimentalStyled.test.js | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/packages/material-ui/src/styles/experimentalStyled.test.js b/packages/material-ui/src/styles/experimentalStyled.test.js index 6de23ca96e9f50..c39edb0b99ef55 100644 --- a/packages/material-ui/src/styles/experimentalStyled.test.js +++ b/packages/material-ui/src/styles/experimentalStyled.test.js @@ -441,12 +441,20 @@ describe('experimentalStyled', () => { const { container } = render(Test); - 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' }, @@ -458,7 +466,17 @@ describe('experimentalStyled', () => { const { container } = render(Test); - 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); }); }); });