Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog/unreleased/pr-25138.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
type = "f"
message = "Showing neutral trend in number widget when delta is zero."

pulls = ["25138"]
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,21 @@ describe('Trend', () => {
});

describe('renders background according to values and trend preference', () => {
it('shows neutral background if values are equal', async () => {
renderTrend();

const background = await screen.findByTestId('trend-background');

expect(background).toHaveStyleRule('background-color', '#fff!important');
});
it.each`
trendPreference
${'NEUTRAL'}
${'HIGHER'}
${'LOWER'}
`(
'shows neutral background if values are equal and trend preference is $trendPreference',
async ({ trendPreference }: { trendPreference: 'NEUTRAL' | 'LOWER' | 'HIGHER' }) => {
renderTrend({ trendPreference });

const background = await screen.findByTestId('trend-background');

expect(background).toHaveStyleRule('background-color', '#fff!important');
},
);

it('shows good background if current value and preference are higher', async () => {
renderTrend({ current: 43, trendPreference: 'HIGHER' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ const StyledIcon = styled(Icon)<{ $trend: TrendDirection | undefined }>(({ theme
});

const _trendDirection = (delta: number, trendPreference: TrendPreference): TrendDirection => {
if (delta === 0) {
return 'neutral';
}
switch (trendPreference) {
case 'LOWER':
return delta > 0 ? 'bad' : 'good';
Expand Down
Loading