import React from 'react'; import { render, screen } from '@testing-library/react'; import { Progress, ProgressSize } from '../Progress'; import { ProgressVariant, ProgressMeasureLocation } from '../ProgressContainer'; test('Simple progress', () => { const { asFragment } = render(); expect(asFragment()).toMatchSnapshot(); }); test('no value specified', () => { const { asFragment } = render(); expect(asFragment()).toMatchSnapshot(); }); test('additional label', () => { const { asFragment } = render(); expect(asFragment()).toMatchSnapshot(); }); test('Progress with aria-valuetext', () => { const { asFragment } = render(); expect(asFragment()).toMatchSnapshot(); }); test('value lower than minValue', () => { const { asFragment } = render(); expect(asFragment()).toMatchSnapshot(); }); test('value higher than maxValue', () => { const { asFragment } = render(); expect(asFragment()).toMatchSnapshot(); }); test('value scaled with minValue', () => { const { asFragment } = render(); expect(asFragment()).toMatchSnapshot(); }); test('value scaled with maxValue', () => { const { asFragment } = render(); expect(asFragment()).toMatchSnapshot(); }); test('value scaled between minValue and maxValue', () => { const { asFragment } = render(); expect(asFragment()).toMatchSnapshot(); }); describe('Progress size', () => { Object.keys(ProgressSize).forEach(oneSize => { test(oneSize, () => { const { asFragment } = render(); expect(asFragment()).toMatchSnapshot(); }); }); }); describe('Progress variant', () => { Object.keys(ProgressVariant).forEach(oneVariant => { test(oneVariant, () => { const { asFragment } = render( ); expect(asFragment()).toMatchSnapshot(); }); }); }); describe('Progress measure location', () => { Object.keys(ProgressMeasureLocation).forEach(oneLocation => { test(oneLocation, () => { const { asFragment } = render( ); expect(asFragment()).toMatchSnapshot(); }); }); test('inside and small should render large', () => { const { asFragment } = render( ); expect(asFragment()).toMatchSnapshot(); }); }); test('progress component generates console warning when no accessible name is provided', () => { const consoleWarnMock = jest.fn(); global.console = { warn: consoleWarnMock } as any; render(); expect(consoleWarnMock).toHaveBeenCalled(); }); test('Does not render helper text by default', () => { render(); expect(screen.queryByText('Test helper text')).not.toBeInTheDocument(); }) test('Renders passed helper text', () => { render(); expect(screen.getByText('Test helper text')).toBeVisible(); });