Skip to content

Commit

Permalink
Add new test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
fullofcaffeine committed May 22, 2024
1 parent b8100eb commit 8fc80b0
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/components/src/progress-bar/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { render, screen } from '@testing-library/react';
*/
import { ProgressBar } from '..';
import { INDETERMINATE_TRACK_WIDTH } from '../styles';
import { CONFIG } from '../../utils';

describe( 'ProgressBar', () => {
it( 'should render an indeterminate semantic progress bar element', () => {
Expand Down Expand Up @@ -79,4 +80,27 @@ describe( 'ProgressBar', () => {
);
expect( screen.getByRole( 'progressbar' ) ).toHaveStyle( style );
} );

it( 'should use default width if width for the track if the `width` prop is not passed', () => {
const { container } = render( <ProgressBar /> );

// eslint-disable-next-line testing-library/no-container, testing-library/no-node-access
const track = container.firstChild;

expect( track ).toHaveStyle( {
maxWidth: `${ CONFIG.progressBarWidth }px`,
} );
} );

it( 'should apply custom width to tthe track if the `width` prop is passed', () => {
const customWidth = 400;
const { container } = render( <ProgressBar width={ customWidth } /> );

// eslint-disable-next-line testing-library/no-container, testing-library/no-node-access
const track = container.firstChild;

expect( track ).toHaveStyle( {
maxWidth: `${ customWidth }px`,
} );
} );
} );

0 comments on commit 8fc80b0

Please sign in to comment.