Skip to content

Commit

Permalink
[fix] +- Change appearing for a PR (#3619)
Browse files Browse the repository at this point in the history
Co-authored-by: sentry-autofix[bot] <157164994+sentry-autofix[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 0e9f64a commit ecdafdb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/ui/TotalsNumber/TotalsNumber.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,25 @@ describe('TotalsNumber', () => {

const changeValue = screen.getByTestId('change-value')
expect(changeValue).toHaveTextContent('0')
expect(changeValue).not.toHaveClass("before:content-['+']")

const numberValue = screen.getByTestId('number-value')
expect(numberValue).toHaveClass('bg-ds-coverage-covered')
})

it('does not render + sign for zero value', () => {
render(
<TotalsNumber
value={0}
variant="default"
showChange
data-testid="change-value"
/>
)

const changeValue = screen.getByTestId('change-value')
expect(changeValue).toHaveTextContent('0')
expect(changeValue).not.toHaveClass("before:content-['+']")

const numberValue = screen.getByTestId('number-value')
expect(numberValue).toHaveClass('bg-ds-coverage-covered')
Expand Down
2 changes: 1 addition & 1 deletion src/ui/TotalsNumber/TotalsNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const getNumberClasses = ({
hasValue && parseFloat(value.toFixed(2)) < 0 && !plain,
'bg-ds-coverage-covered':
hasValue && parseFloat(value.toFixed(2)) >= 0 && !plain,
"before:content-['+']": hasValue && showChange,
"before:content-['+']": hasValue && showChange && value > 0,
})
}

Expand Down

0 comments on commit ecdafdb

Please sign in to comment.