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

[test] Migrate TabIndicator to react-testing-library #22906

Merged
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
24 changes: 13 additions & 11 deletions packages/material-ui/src/Tabs/TabIndicator.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as React from 'react';
import { expect } from 'chai';
import { createShallow, getClasses } from 'test/utils';
import { getClasses, createClientRender } from 'test/utils';
import TabIndicator from './TabIndicator';

describe('<TabIndicator />', () => {
let shallow;
const render = createClientRender();
let classes;
const defaultProps = {
direction: 'left',
Expand All @@ -14,28 +14,30 @@ describe('<TabIndicator />', () => {
const style = { left: 1, width: 2 };

before(() => {
shallow = createShallow({ dive: true });
classes = getClasses(<TabIndicator {...defaultProps} />);
});

it('should render with the root class', () => {
const wrapper = shallow(<TabIndicator {...defaultProps} />);
expect(wrapper.name()).to.equal('span');
expect(wrapper.hasClass(classes.root)).to.equal(true);
const { container } = render(<TabIndicator {...defaultProps} />);
expect(container.firstChild).to.have.tagName('span');
expect(container.firstChild).to.have.class(classes.root);
});

describe('prop: style', () => {
it('should be applied on the root element', () => {
const wrapper = shallow(<TabIndicator {...defaultProps} style={style} />);
expect(wrapper.props().style).to.equal(style);
const { container } = render(<TabIndicator {...defaultProps} style={style} />);
const tab = container.firstChild;

expect(tab.style).to.have.property('left', '1px');
expect(tab.style).to.have.property('width', '2px');
});
});

describe('prop: className', () => {
it('should append the className on the root element', () => {
const wrapper = shallow(<TabIndicator {...defaultProps} className="foo" />);
expect(wrapper.name()).to.equal('span');
expect(wrapper.hasClass('foo')).to.equal(true);
const { container } = render(<TabIndicator {...defaultProps} className="foo" />);
expect(container.firstChild).to.have.tagName('span');
expect(container.firstChild).to.have.class('foo');
});
});
});