diff --git a/packages/material-ui/src/Hidden/Hidden.test.js b/packages/material-ui/src/Hidden/Hidden.test.js
index 08b2a440c01c31..4c7451d83f4d3e 100644
--- a/packages/material-ui/src/Hidden/Hidden.test.js
+++ b/packages/material-ui/src/Hidden/Hidden.test.js
@@ -1,26 +1,23 @@
import * as React from 'react';
import { expect } from 'chai';
-import { createShallow } from 'test/utils';
+import { createClientRender } from 'test/utils';
import Hidden from './Hidden';
-import HiddenJs from './HiddenJs';
-import HiddenCss from './HiddenCss';
describe('', () => {
- let shallow;
-
- before(() => {
- shallow = createShallow();
- });
+ const render = createClientRender();
+ const child = Hello;
describe('prop: implementation', () => {
it('should use HiddenJs by default', () => {
- const wrapper = shallow(Hello);
- expect(wrapper.find(HiddenJs).length).to.equal(1);
+ const { container } = render({child});
+ // JS implementation doesn't requires wrapping
+ expect(container.firstChild).to.have.tagName('span');
});
it('should change the implementation', () => {
- const wrapper = shallow(Hello);
- expect(wrapper.find(HiddenCss).length).to.equal(1);
+ const { container } = render({child});
+ // CSS implementation requires wrapping
+ expect(container.firstChild).to.have.tagName('div');
});
});
});
diff --git a/packages/material-ui/src/Hidden/HiddenCss.test.js b/packages/material-ui/src/Hidden/HiddenCss.test.js
index 5fdcd4db027dea..b7b265873d170a 100644
--- a/packages/material-ui/src/Hidden/HiddenCss.test.js
+++ b/packages/material-ui/src/Hidden/HiddenCss.test.js
@@ -1,21 +1,20 @@
import * as React from 'react';
import { expect } from 'chai';
-import { createShallow, getClasses, createMount } from 'test/utils';
+import { getClasses, createMount, createClientRender } from 'test/utils';
import HiddenCss from './HiddenCss';
import { createMuiTheme, MuiThemeProvider } from '../styles';
-const Foo = () => bar
;
+const TestChild = () => bar
;
describe('', () => {
/**
* @type {ReturnType}
*/
const mount = createMount();
- let shallow;
+ const render = createClientRender();
let classes;
before(() => {
- shallow = createShallow({ untilSelector: 'div' });
classes = getClasses(
@@ -25,72 +24,76 @@ describe('', () => {
describe('the generated class names', () => {
it('should be ok with only', () => {
- const wrapper = shallow(
+ const { container } = render(
,
);
+ const root = container.firstChild;
- expect(wrapper.type()).to.equal('div');
- expect(wrapper.hasClass(classes.onlySm)).to.equal(true);
-
- const div = wrapper.childAt(0);
- expect(div.type()).to.equal('div');
- expect(div.props().className).to.equal('foo');
+ expect(root).to.have.tagName('div');
+ expect(root).to.have.class(classes.onlySm);
+ expect(root.firstChild).to.have.tagName('div');
+ expect(root.firstChild).to.have.class('foo');
});
it('should be ok with only as an array', () => {
- const wrapper = shallow(
+ const { container } = render(
,
);
+ const root = container.firstChild;
- expect(wrapper.type()).to.equal('div');
- expect(wrapper.props().className.split(' ')[0]).to.equal(classes.onlyXs);
- expect(wrapper.props().className.split(' ')[1]).to.equal(classes.onlySm);
+ expect(root).to.have.tagName('div');
+ expect(root).to.have.class(classes.onlyXs);
+ expect(root).to.have.class(classes.onlySm);
});
it('should be ok with only as an empty array', () => {
- const wrapper = shallow(
+ const { container } = render(
,
);
+ const root = container.firstChild;
- expect(wrapper.type()).to.equal('div');
- expect(wrapper.props().className).to.equal('');
+ expect(root).to.have.tagName('div');
+ Object.keys(classes).forEach((className) => expect(root).to.not.have.class(className));
});
it('should be ok with mdDown', () => {
- const wrapper = shallow(
+ const { container } = render(
,
);
- expect(wrapper.hasClass(classes.mdDown)).to.equal(true);
+
+ expect(container.firstChild).to.have.class(classes.mdDown);
});
it('should be ok with mdUp', () => {
- const wrapper = shallow(
+ const { container } = render(
,
);
- expect(wrapper.hasClass(classes.mdUp)).to.equal(true);
+
+ expect(container.firstChild).to.have.class(classes.mdUp);
});
it('should handle provided className prop', () => {
- const wrapper = shallow(
+ const { container } = render(
,
);
- expect(wrapper.hasClass('custom')).to.equal(true);
+
+ expect(container.firstChild).to.have.class('custom');
});
it('allows custom breakpoints', () => {
const theme = createMuiTheme({ breakpoints: { keys: ['xxl'] } });
- const wrapper = mount(
+ const { container } = render(
@@ -98,43 +101,48 @@ describe('', () => {
,
);
- expect(wrapper.find('div.testid').hasClass('xxlUp')).to.equal(true);
+ expect(container.querySelector('.testid')).to.have.class('xxlUp');
});
});
describe('prop: children', () => {
it('should work when text Node', () => {
- const wrapper = shallow(foo);
- expect(wrapper.type()).to.equal('div');
- expect(wrapper.hasClass(classes.mdUp)).to.equal(true);
- expect(wrapper.childAt(0).text()).to.equal('foo');
+ const { container, queryByText } = render(foo);
+ const root = container.firstChild;
+
+ expect(root).to.have.tagName('div');
+ expect(root).to.have.class(classes.mdUp);
+ expect(queryByText('foo')).to.not.equal(null);
});
it('should work when Element', () => {
- const wrapper = shallow(
+ const { container, queryByTestId } = render(
-
+
,
);
- expect(wrapper.type()).to.equal('div');
- expect(wrapper.hasClass(classes.mdUp)).to.equal(true);
- expect(wrapper.childAt(0).is(Foo)).to.equal(true);
+ const root = container.firstChild;
+
+ expect(root).to.have.tagName('div');
+ expect(root).to.have.class(classes.mdUp);
+ expect(queryByTestId('test-child')).to.not.equal(null);
});
it('should work when mixed ChildrenArray', () => {
- const wrapper = shallow(
+ const { container, queryAllByTestId, queryByText } = render(
-
-
+
+
foo
,
);
+ const root = container.firstChild;
+ const children = queryAllByTestId('test-child');
- expect(wrapper.type()).to.equal('div');
- expect(wrapper.hasClass(classes.mdUp)).to.equal(true);
- expect(wrapper.childAt(0).is(Foo)).to.equal(true);
- expect(wrapper.childAt(1).is(Foo)).to.equal(true);
- expect(wrapper.childAt(2).text()).to.equal('foo');
+ expect(root).to.have.tagName('div');
+ expect(root).to.have.class(classes.mdUp);
+ expect(children.length).to.equal(2);
+ expect(queryByText('foo')).to.not.equal(null);
});
});
diff --git a/packages/material-ui/src/Hidden/HiddenJs.test.js b/packages/material-ui/src/Hidden/HiddenJs.test.js
index b2ae40d2342236..c549299ae7b1e9 100644
--- a/packages/material-ui/src/Hidden/HiddenJs.test.js
+++ b/packages/material-ui/src/Hidden/HiddenJs.test.js
@@ -1,14 +1,10 @@
import * as React from 'react';
import { expect } from 'chai';
-import { createShallow } from 'test/utils';
+import { createClientRender } from 'test/utils';
import HiddenJs from './HiddenJs';
describe('', () => {
- let shallow;
-
- before(() => {
- shallow = createShallow({ dive: true });
- });
+ const render = createClientRender();
function resolvePropName(upDownOnly, breakpoint) {
if (upDownOnly === 'only') {
@@ -29,12 +25,13 @@ describe('', () => {
const props = { [prop]: upDownOnly === 'only' ? breakpoint : true };
it(descriptions[upDownOnly], () => {
- const wrapper = shallow(
+ const { container } = render(
foo
,
);
- expect(wrapper.type()).to.equal(null);
+
+ expect(container.firstChild).to.equal(null);
});
});
}
@@ -50,14 +47,14 @@ describe('', () => {
const props = { [prop]: upDownOnly === 'only' ? breakpoint : true };
it(descriptions[upDownOnly], () => {
- const wrapper = shallow(
+ const { container, queryByText } = render(
foo
,
);
- expect(wrapper.type()).to.not.equal(null);
- expect(wrapper.name()).to.equal('div');
- expect(wrapper.first().text()).to.equal('foo');
+
+ expect(container.firstChild).to.have.tagName('div');
+ expect(queryByText('foo')).to.not.equal(null);
});
});
}