add data-testid to Progress placeholder

Signed-off-by: Wiktor Czajkowski <wiktor.czajkowski@allegro.pl>
This commit is contained in:
Wiktor Czajkowski
2024-11-14 15:38:16 +01:00
parent 13180c5260
commit 66dfb03b86
2 changed files with 8 additions and 3 deletions
@@ -23,12 +23,17 @@ import { Progress } from './Progress';
describe('<Progress />', () => {
it('renders without exploding', async () => {
jest.useFakeTimers();
const { getByTestId, queryByTestId } = await renderInTestApp(<Progress />);
const { getByTestId, queryByTestId, debug } = await renderInTestApp(
<Progress />,
);
debug();
expect(queryByTestId('progress-placeholder')).toBeInTheDocument();
expect(queryByTestId('progress')).not.toBeInTheDocument();
act(() => {
jest.advanceTimersByTime(250);
});
expect(getByTestId('progress')).toBeInTheDocument();
expect(queryByTestId('progress-placeholder')).not.toBeInTheDocument();
expect(queryByTestId('progress')).toBeInTheDocument();
jest.useRealTimers();
});
});
@@ -36,6 +36,6 @@ export function Progress(props: PropsWithChildren<LinearProgressProps>) {
return isVisible ? (
<LinearProgress {...props} data-testid="progress" />
) : (
<Box display="none" />
<Box display="none" data-testid="progress-placeholder" />
);
}