Fix floating point math precision

This commit is contained in:
Adam Harvey
2021-01-18 23:40:48 -05:00
parent 4211198c30
commit 4a88f5d5a5
2 changed files with 2 additions and 2 deletions
@@ -38,7 +38,7 @@ const websiteListResponse = data as WebsiteListResponse;
let entityWebsite = websiteListResponse.items[2];
describe('<LastLighthouseAuditCard />', () => {
const asPercentage = (fraction: number) => `${fraction * 100}%`;
const asPercentage = (fraction: number) => `${Math.round(fraction * 100)}%`;
beforeEach(() => {
(useWebsiteForEntity as jest.Mock).mockReturnValue({
@@ -27,7 +27,7 @@ import { useWebsiteForEntity } from '../../hooks/useWebsiteForEntity';
import AuditStatusIcon from '../AuditStatusIcon';
const LighthouseCategoryScoreStatus = ({ score }: { score: number }) => {
const scoreAsPercentage = score * 100;
const scoreAsPercentage = Math.round(score * 100);
switch (true) {
case scoreAsPercentage >= 90:
return (