Showing neutral trend when delta is zero. (#25138)

* Showing neutral trend when delta is zero.

* Adding changelog snippet.

* Unnecessary data attribute.
This commit is contained in:
Dennis Oelkers
2026-02-27 14:09:07 +01:00
committed by GitHub
parent 0cc3fe50d6
commit 891f1ec577
3 changed files with 20 additions and 5 deletions

View File

@@ -0,0 +1,4 @@
type = "f"
message = "Showing neutral trend in number widget when delta is zero."
pulls = ["25138"]

View File

@@ -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();
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');
const background = await screen.findByTestId('trend-background');
expect(background).toHaveStyleRule('background-color', '#fff!important');
});
expect(background).toHaveStyleRule('background-color', '#fff!important');
},
);
it('shows good background if current value and preference are higher', async () => {
renderTrend({ current: 43, trendPreference: 'HIGHER' });

View File

@@ -71,6 +71,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';