Skip to content

Commit 0ce8854

Browse files
authored
[AppBar] Migrate to testing-library (#20693)
1 parent 39063ab commit 0ce8854

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed
+22-19
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
import * as React from 'react';
2-
import { assert } from 'chai';
3-
import { createMount, createShallow, getClasses } from '@material-ui/core/test-utils';
2+
import { expect } from 'chai';
3+
import { createMount, getClasses } from '@material-ui/core/test-utils';
4+
import { createClientRender } from 'test/utils/createClientRender';
45
import describeConformance from '../test-utils/describeConformance';
56
import AppBar from './AppBar';
67
import Paper from '../Paper';
78

89
describe('<AppBar />', () => {
910
let mount;
10-
let shallow;
1111
let classes;
12-
12+
const render = createClientRender();
1313
before(() => {
1414
mount = createMount({ strict: true });
15-
shallow = createShallow({ dive: true });
1615
classes = getClasses(<AppBar>Hello World</AppBar>);
1716
});
1817

@@ -29,30 +28,34 @@ describe('<AppBar />', () => {
2928
}));
3029

3130
it('should render with the root class and primary', () => {
32-
const wrapper = shallow(<AppBar>Hello World</AppBar>);
33-
assert.strictEqual(wrapper.hasClass(classes.root), true);
34-
assert.strictEqual(wrapper.hasClass(classes.colorPrimary), true);
35-
assert.strictEqual(wrapper.hasClass(classes.colorSecondary), false);
31+
const { container } = render(<AppBar>Hello World</AppBar>);
32+
const appBar = container.firstChild;
33+
expect(appBar).to.have.class(classes.root);
34+
expect(appBar).to.have.class(classes.colorPrimary);
35+
expect(appBar).to.not.have.class(classes.colorSecondary);
3636
});
3737

3838
it('should render a primary app bar', () => {
39-
const wrapper = shallow(<AppBar color="primary">Hello World</AppBar>);
40-
assert.strictEqual(wrapper.hasClass(classes.root), true);
41-
assert.strictEqual(wrapper.hasClass(classes.colorPrimary), true);
42-
assert.strictEqual(wrapper.hasClass(classes.colorSecondary), false);
39+
const { container } = render(<AppBar color="primary">Hello World</AppBar>);
40+
const appBar = container.firstChild;
41+
expect(appBar).to.have.class(classes.root);
42+
expect(appBar).to.have.class(classes.colorPrimary);
43+
expect(appBar).to.not.have.class(classes.colorSecondary);
4344
});
4445

4546
it('should render an secondary app bar', () => {
46-
const wrapper = shallow(<AppBar color="secondary">Hello World</AppBar>);
47-
assert.strictEqual(wrapper.hasClass(classes.root), true);
48-
assert.strictEqual(wrapper.hasClass(classes.colorPrimary), false);
49-
assert.strictEqual(wrapper.hasClass(classes.colorSecondary), true);
47+
const { container } = render(<AppBar color="secondary">Hello World</AppBar>);
48+
const appBar = container.firstChild;
49+
expect(appBar).to.have.class(classes.root);
50+
expect(appBar).to.not.have.class(classes.colorPrimary);
51+
expect(appBar).to.have.class(classes.colorSecondary);
5052
});
5153

5254
describe('Dialog', () => {
5355
it('should add a .mui-fixed class', () => {
54-
const wrapper = shallow(<AppBar position="fixed">Hello World</AppBar>);
55-
assert.strictEqual(wrapper.hasClass('mui-fixed'), true);
56+
const { container } = render(<AppBar position="fixed">Hello World</AppBar>);
57+
const appBar = container.firstChild;
58+
expect(appBar).to.have.class('mui-fixed');
5659
});
5760
});
5861
});

0 commit comments

Comments
 (0)