Skip to content

Commit

Permalink
add test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Jun 22, 2021
1 parent 96cd8bb commit c0192d0
Showing 1 changed file with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as React from 'react';
import { expect } from 'chai';
import { createMount, createClientRender, describeConformanceV5 } from 'test/utils';
import Step, { stepClasses } from '@material-ui/core/Step';
import { stepIconClasses } from '@material-ui/core/StepIcon';
import Step, { StepProps, stepClasses } from '@material-ui/core/Step';
import StepLabel from '@material-ui/core/StepLabel';
import StepConnector, { stepConnectorClasses } from '@material-ui/core/StepConnector';
import StepContent, { stepContentClasses } from '@material-ui/core/StepContent';
Expand Down Expand Up @@ -113,7 +114,7 @@ describe('<Stepper />', () => {
});

it('passes index down correctly when rendering children containing arrays', () => {
const CustomStep = ({ index }) => <div data-index={index} data-testid="step" />;
const CustomStep = ({ index }: StepProps) => <div data-index={index} data-testid="step" />;

const { getAllByTestId } = render(
<Stepper nonLinear>
Expand Down Expand Up @@ -239,17 +240,23 @@ describe('<Stepper />', () => {
it('should be able to force a state', () => {
const { container } = render(
<Stepper>
<Step />
<Step active />
<Step />
<Step>
<StepLabel>one</StepLabel>
</Step>
<Step active>
<StepLabel>two</StepLabel>
</Step>
<Step>
<StepLabel>tree</StepLabel>
</Step>
</Stepper>,
);

const steps = container.querySelectorAll(`.${stepClasses.root}`);
const steps = container.querySelectorAll(`.${stepIconClasses.root}`);

expect(steps[0]).not.to.have.class(stepClasses.active);
expect(steps[1]).not.to.have.class(stepClasses.active);
expect(steps[2]).not.to.have.class(stepClasses.active);
expect(steps[0]).to.have.class(stepIconClasses.active);
expect(steps[1]).to.have.class(stepIconClasses.active);
expect(steps[2]).not.to.have.class(stepIconClasses.active);
});

it('should hide the last connector', () => {
Expand Down

0 comments on commit c0192d0

Please sign in to comment.