Skip to content

Commit

Permalink
Fix inconsistent formatting of scheduled rewards. Closes #1685 (#1696)
Browse files Browse the repository at this point in the history
* fix inconsistent formatting of scheduled rewards. closes #1685

* fix tests

* fix test
  • Loading branch information
juliangruber authored Jul 15, 2024
1 parent e01c7b7 commit 0eb4c1f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion renderer/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ export function truncateString (value: string, size = 6) {
}

export function formatFilValue (value = '') {
return new FilecoinNumber(String(value), 'fil')
const str = new FilecoinNumber(String(value), 'fil')
.decimalPlaces(3, BigNumber.ROUND_DOWN)
.toString()
const [whole, decimal = ''] = str.split('.')
return `${whole}.${decimal.padEnd(3, '0')}`
}

export function openExplorerLink (hash?: string) {
Expand Down
6 changes: 3 additions & 3 deletions renderer/src/test/dashboard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('Dashboard page', () => {
})

test('displays earnings counter null', () => {
expect(screen.getByTestId('earnings-counter').textContent).toBe('1 FIL')
expect(screen.getByTestId('earnings-counter').textContent).toBe('1.000 FIL')
})

test('displays empty activity log', () => {
Expand Down Expand Up @@ -183,7 +183,7 @@ describe('Dashboard page', () => {
})

test('subscribes and listens the earnings counter', async () => {
expect(screen.getByTestId('earnings-counter').textContent).toBe('0 FIL')
expect(screen.getByTestId('earnings-counter').textContent).toBe('0.000 FIL')

act(() => {
vi.runAllTimers()
Expand All @@ -193,7 +193,7 @@ describe('Dashboard page', () => {
vi.useRealTimers()

await waitFor(() => {
expect(screen.getByTestId('earnings-counter').textContent).toBe('10 FIL')
expect(screen.getByTestId('earnings-counter').textContent).toBe('10.000 FIL')
})
})
})
Expand Down

0 comments on commit 0eb4c1f

Please sign in to comment.