Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AppBar] Migrate to testing-library #20693

Merged
merged 1 commit into from Apr 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 22 additions & 19 deletions 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('<AppBar />', () => {
let mount;
let shallow;
let classes;

const render = createClientRender();
before(() => {
mount = createMount({ strict: true });
shallow = createShallow({ dive: true });
classes = getClasses(<AppBar>Hello World</AppBar>);
});

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

it('should render with the root class and primary', () => {
const wrapper = shallow(<AppBar>Hello World</AppBar>);
assert.strictEqual(wrapper.hasClass(classes.root), true);
assert.strictEqual(wrapper.hasClass(classes.colorPrimary), true);
assert.strictEqual(wrapper.hasClass(classes.colorSecondary), false);
const { container } = render(<AppBar>Hello World</AppBar>);
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(<AppBar color="primary">Hello World</AppBar>);
assert.strictEqual(wrapper.hasClass(classes.root), true);
assert.strictEqual(wrapper.hasClass(classes.colorPrimary), true);
assert.strictEqual(wrapper.hasClass(classes.colorSecondary), false);
const { container } = render(<AppBar color="primary">Hello World</AppBar>);
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(<AppBar color="secondary">Hello World</AppBar>);
assert.strictEqual(wrapper.hasClass(classes.root), true);
assert.strictEqual(wrapper.hasClass(classes.colorPrimary), false);
assert.strictEqual(wrapper.hasClass(classes.colorSecondary), true);
const { container } = render(<AppBar color="secondary">Hello World</AppBar>);
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(<AppBar position="fixed">Hello World</AppBar>);
assert.strictEqual(wrapper.hasClass('mui-fixed'), true);
const { container } = render(<AppBar position="fixed">Hello World</AppBar>);
const appBar = container.firstChild;
expect(appBar).to.have.class('mui-fixed');
});
});
});