mirror of
https://github.com/mempool/mempool.git
synced 2026-08-13 12:33:11 +02:00
Increase fiat precision
This commit is contained in:
parent
be08b954ec
commit
ad08c931fc
3 changed files with 7 additions and 4 deletions
|
|
@ -94,12 +94,11 @@ describe('Calculator', () => {
|
|||
});
|
||||
|
||||
it('updates fiat and sats when entering 1 sat (0.00000001 BTC)', () => {
|
||||
const expectedFiat = Math.round((MOCK_BTC_PRICE_USD / 100_000_000) * 100) / 100;
|
||||
const expectedFiat = (MOCK_BTC_PRICE_USD / 100_000_000 * 100 / 100).toFixed(8);
|
||||
cy.get('input[formControlName="bitcoin"]').clear().type('0.00000001');
|
||||
cy.get('input[formControlName="satoshis"]').invoke('val').should('equal', '1');
|
||||
cy.get('input[formControlName="fiat"]').invoke('val').then((fiatVal) => {
|
||||
const fiat = parseFloat(String(fiatVal).replace(/,/g, '')) || 0;
|
||||
expect(fiat).to.equal(expectedFiat);
|
||||
expect(String(fiatVal)).to.equal(expectedFiat);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
|
||||
<div class="row justify-content-center">
|
||||
<div class="fiat-text">
|
||||
<app-fiat [value]="form.get('satoshis').value" digitsInfo="1.0-0"></app-fiat>
|
||||
<app-fiat [value]="form.get('satoshis').value" digitsInfo="1.2-2"></app-fiat>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -186,6 +186,10 @@ export class CalculatorComponent implements OnInit {
|
|||
if (num % 1 === 0) {
|
||||
return Math.round(num);
|
||||
}
|
||||
// For small values (< 1), show more precision
|
||||
if (Math.abs(num) < 1 && num !== 0) {
|
||||
return num.toFixed(8);
|
||||
}
|
||||
return (Math.round(num * 100) / 100).toFixed(2);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue