mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-20 00:08:02 +01:00
68 lines
1.6 KiB
TypeScript
68 lines
1.6 KiB
TypeScript
import { screen } from '@testing-library/react';
|
|
import { render } from 'utils/testRenderer';
|
|
import { Limit } from './Limit';
|
|
|
|
test('Render approaching limit variant', () => {
|
|
render(
|
|
<Limit
|
|
name='strategies in this environment'
|
|
shortName='strategies'
|
|
limit={10}
|
|
currentValue={8}
|
|
/>,
|
|
);
|
|
|
|
screen.getByText(
|
|
'You are nearing the limit for strategies in this environment',
|
|
);
|
|
screen.getByText('80%');
|
|
screen.getByText('Limit: 10');
|
|
});
|
|
|
|
test('Render reached limit variant', () => {
|
|
render(
|
|
<Limit
|
|
name='strategies in this environment'
|
|
shortName='strategies'
|
|
limit={10}
|
|
currentValue={10}
|
|
/>,
|
|
);
|
|
|
|
screen.getByText(
|
|
'You have reached the limit for strategies in this environment',
|
|
);
|
|
screen.getByText('100%');
|
|
screen.getByText('Limit: 10');
|
|
});
|
|
|
|
test('Render exceeded limit variant', () => {
|
|
render(
|
|
<Limit
|
|
name='strategies in this environment'
|
|
shortName='strategies'
|
|
limit={10}
|
|
currentValue={20}
|
|
/>,
|
|
);
|
|
|
|
screen.getByText(
|
|
'You have reached the limit for strategies in this environment',
|
|
);
|
|
screen.getByText('200%');
|
|
screen.getByText('Limit: 10');
|
|
});
|
|
|
|
test('Do not render any limit below threshold', () => {
|
|
render(
|
|
<Limit
|
|
name='strategies in this environment'
|
|
shortName='strategies'
|
|
limit={10}
|
|
currentValue={7}
|
|
/>,
|
|
);
|
|
|
|
expect(screen.queryByText('Limit: 10')).not.toBeInTheDocument();
|
|
});
|