1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-05-12 01:17:04 +02:00
unleash.unleash/frontend/src/component/common/StrategyItemContainer/StrategyItemContainer.test.tsx
Thomas Heartman 97fd1c0fec
chore(1-3423): adapt existing tests to new components (#9396)
Adds tests for the new version of components that were moved to legacy
files in https://github.com/Unleash/unleash/pull/9361 and where there
were tests already.
2025-02-28 09:45:29 +00:00

49 lines
1.6 KiB
TypeScript

import { screen } from '@testing-library/react';
import { render } from 'utils/testRenderer';
import { StrategyItemContainer as LegacyStrategyItemContainer } from './LegacyStrategyItemContainer';
import type { IFeatureStrategy } from 'interfaces/strategy';
import { StrategyItemContainer } from './StrategyItemContainer';
// todo: remove this test along with the flag flagOverviewRedesign
test('(deprecated) should render strategy name, custom title and description', async () => {
const strategy: IFeatureStrategy = {
id: 'irrelevant',
name: 'strategy name',
title: 'custom title',
constraints: [],
parameters: {},
};
render(
<LegacyStrategyItemContainer
strategy={strategy}
description={'description'}
/>,
);
expect(screen.getByText('strategy name')).toBeInTheDocument();
expect(screen.getByText('description')).toBeInTheDocument();
await screen.findByText('custom title'); // behind async flag
});
test('should render strategy name, custom title and description', async () => {
const strategy: IFeatureStrategy = {
id: 'irrelevant',
name: 'strategy name',
title: 'custom title',
constraints: [],
parameters: {},
};
render(
<StrategyItemContainer
strategy={strategy}
description={'description'}
/>,
);
expect(screen.getByText('strategy name')).toBeInTheDocument();
expect(screen.getByText('description')).toBeInTheDocument();
await screen.findByText('custom title'); // behind async flag
});