Skip to content

Commit

Permalink
[test] Migrate TabIndicator to react-testing-library (#22906)
Browse files Browse the repository at this point in the history
  • Loading branch information
eladmotola committed Oct 7, 2020
1 parent ab33be8 commit a1c945e
Showing 1 changed file with 13 additions and 11 deletions.
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');
});
});
});

0 comments on commit a1c945e

Please sign in to comment.