Skip to content

Fix RoundedBalance prop combinations #1902

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 19, 2025
Merged

Conversation

lukaw3d
Copy link
Member

@lukaw3d lukaw3d commented Apr 16, 2025

No description provided.

Copy link

github-actions bot commented Apr 16, 2025

Deployed to Cloudflare Pages

Latest commit: b736f1665670b10f495be39249a2d924a6c9f925
Status:✅ Deploy successful!
Preview URL: https://c4f4ad12.oasis-explorer.pages.dev
Alias: https://pr-1902.oasis-explorer.pages.dev

@@ -91,4 +93,45 @@ describe('RoundedBalance', () => {
expect(screen.getByText('99,999.00000…')).toBeInTheDocument()
})
})

for (const compactLargeNumbers of [false, true]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every possible combination of params creates tons of useless snapshots. Can we define some test cases instead?

  describe('should match snapshot for key configurations', () => {
    const testCases = [
      // common
      { value: '0.002231', ticker: 'ROSE' },

      // compactLargeNumbers
      { value: '15000000', compactLargeNumbers: true },
      { value: '15000000', compactLargeNumbers: false },

      // showSign
      { value: '5', showSign: true },
      { value: '-0.0047956', showSign: true },

      // link 
      {
        value: '5',
        ticker: 'wROSE',
        tickerAsLink: true,
        tokenAddress: '0x8Bc2B030b299964eEfb5e1e0b36991352E56D2D3',
      },

      // Very small value
      { value: '0.00000000000002231' }, 
      // Very large value
      { value: '1111111111111111111111111111111111111111111111111111' }, 

      // Additional combos / whatever
      { value: '15000000', compactLargeNumbers: true, showSign: true, ticker: 'wROSE' },
      { value: '0.002231', tickerAsLink: true, tokenAddress: '0x8Bc2B030b299964eEfb5e1e0b36991352E56D2D3' },
    ]

    testCases.forEach(params => {
      it(`should match snapshot ${util.inspect(params)}`, () => {
         ...
      })
    })
  })

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also have more normal tests above but I also want to have all the snapshots because it is not implemented in a composable way

@lukaw3d lukaw3d force-pushed the lw/rounded-balance-params branch from f42b3a4 to b736f16 Compare May 19, 2025 21:06
@lukaw3d lukaw3d merged commit a457982 into master May 19, 2025
9 checks passed
@lukaw3d lukaw3d deleted the lw/rounded-balance-params branch May 19, 2025 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants