From a0a870d238c4ab7c44e23373ab36a653abe39be0 Mon Sep 17 00:00:00 2001 From: marcosvega91 Date: Wed, 22 Apr 2020 14:27:56 +0200 Subject: [PATCH] [AppBar] using test-library --- .../material-ui/src/AppBar/AppBar.test.js | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/packages/material-ui/src/AppBar/AppBar.test.js b/packages/material-ui/src/AppBar/AppBar.test.js index 3f5d4f3c941ad6..5ddcc67e5ad317 100644 --- a/packages/material-ui/src/AppBar/AppBar.test.js +++ b/packages/material-ui/src/AppBar/AppBar.test.js @@ -1,18 +1,17 @@ import * as React from 'react'; -import { assert } from 'chai'; -import { createMount, createShallow, getClasses } from '@material-ui/core/test-utils'; +import { expect } from 'chai'; +import { createMount, getClasses } from '@material-ui/core/test-utils'; +import { createClientRender } from 'test/utils/createClientRender'; import describeConformance from '../test-utils/describeConformance'; import AppBar from './AppBar'; import Paper from '../Paper'; describe('', () => { let mount; - let shallow; let classes; - + const render = createClientRender(); before(() => { mount = createMount({ strict: true }); - shallow = createShallow({ dive: true }); classes = getClasses(Hello World); }); @@ -29,30 +28,34 @@ describe('', () => { })); it('should render with the root class and primary', () => { - const wrapper = shallow(Hello World); - assert.strictEqual(wrapper.hasClass(classes.root), true); - assert.strictEqual(wrapper.hasClass(classes.colorPrimary), true); - assert.strictEqual(wrapper.hasClass(classes.colorSecondary), false); + const { container } = render(Hello World); + const appBar = container.firstChild; + expect(appBar).to.have.class(classes.root); + expect(appBar).to.have.class(classes.colorPrimary); + expect(appBar).to.not.have.class(classes.colorSecondary); }); it('should render a primary app bar', () => { - const wrapper = shallow(Hello World); - assert.strictEqual(wrapper.hasClass(classes.root), true); - assert.strictEqual(wrapper.hasClass(classes.colorPrimary), true); - assert.strictEqual(wrapper.hasClass(classes.colorSecondary), false); + const { container } = render(Hello World); + const appBar = container.firstChild; + expect(appBar).to.have.class(classes.root); + expect(appBar).to.have.class(classes.colorPrimary); + expect(appBar).to.not.have.class(classes.colorSecondary); }); it('should render an secondary app bar', () => { - const wrapper = shallow(Hello World); - assert.strictEqual(wrapper.hasClass(classes.root), true); - assert.strictEqual(wrapper.hasClass(classes.colorPrimary), false); - assert.strictEqual(wrapper.hasClass(classes.colorSecondary), true); + const { container } = render(Hello World); + const appBar = container.firstChild; + expect(appBar).to.have.class(classes.root); + expect(appBar).to.not.have.class(classes.colorPrimary); + expect(appBar).to.have.class(classes.colorSecondary); }); describe('Dialog', () => { it('should add a .mui-fixed class', () => { - const wrapper = shallow(Hello World); - assert.strictEqual(wrapper.hasClass('mui-fixed'), true); + const { container } = render(Hello World); + const appBar = container.firstChild; + expect(appBar).to.have.class('mui-fixed'); }); }); });