From 3992032d2abc3b5d576eab788cbf6d1c24db63ed Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Sat, 10 Sep 2022 06:49:00 -0700 Subject: [PATCH] Fix pretty numbers tests --- frontend/src/utils/prettyNumbers.test.ts | 64 ++++++++++++------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/frontend/src/utils/prettyNumbers.test.ts b/frontend/src/utils/prettyNumbers.test.ts index 132f1d77..1f05b8f6 100644 --- a/frontend/src/utils/prettyNumbers.test.ts +++ b/frontend/src/utils/prettyNumbers.test.ts @@ -1,45 +1,45 @@ -import { pn, amountToString } from './prettyNumbers'; +import { pn, amountToString } from "./prettyNumbers"; -describe('prettyNumbers', () => { - test('pn()', () => { +describe("prettyNumbers", () => { + test("pn()", () => { [ - { input: null, output: undefined }, - { input: undefined, output: undefined }, - { input: 0, output: '0' }, - { input: 1, output: '1' }, - { input: 2, output: '2' }, - { input: 10, output: '10' }, - { input: 11, output: '11' }, - { input: 11.0, output: '11' }, - { input: 12.0, output: '12' }, - { input: 100.5, output: '100.5' }, - { input: 224.56, output: '224.56' }, - { input: 1567, output: '1,567' }, - { input: 15678, output: '15,678' }, - { input: 2984.99, output: '2,984.99' }, - { input: 100000.0, output: '100,000' }, + {input: null, output: undefined}, + {input: undefined, output: undefined}, + {input: 0, output: "0"}, + {input: 1, output: "1"}, + {input: 2, output: "2"}, + {input: 10, output: "10"}, + {input: 11, output: "11"}, + {input: 11.0, output: "11"}, + {input: 12.0, output: "12"}, + {input: 100.50, output: "100.5"}, + {input: 224.56, output: "224.56"}, + {input: 1567, output: "1,567"}, + {input: 15678, output: "15,678"}, + {input: 2984.99, output: "2,984.99"}, + {input: 100000.00, output: "100,000"}, ].forEach((it) => { const response = pn(it.input); expect(response).toBe(it.output); }); }); -}); +}) -describe('amountToString', () => { - test('pn()', () => { +describe("amountToString", () => { + test("pn()", () => { [ - { input: null, output: 'NaN' }, - { input: undefined, output: 'NaN' }, - { input: ['', false, 50, 150], output: '0' }, - { input: ['100.00', false, 50, 150], output: '100' }, - { input: ['100.00', true, undefined, undefined], output: 'NaN-NaN' }, - { input: ['100.00', true, undefined, 150], output: 'NaN-150' }, - { input: ['100.00', true, 50, undefined], output: '50-NaN' }, - { input: ['100.00', true, 50, 150], output: '50-150' }, + {input: null, output: "NaN"}, + {input: undefined, output: "NaN"}, + {input: ["", false, 50, 150] , output: "0"}, + {input: ["100.00", false, 50, 150] , output: "100"}, + {input: ["100.00", true, undefined, undefined] , output: "NaN-NaN"}, + {input: ["100.00", true, undefined, 150] , output: "NaN-150"}, + {input: ["100.00", true, 50, undefined] , output: "50-NaN"}, + {input: ["100.00", true, 50, 150] , output: "50-150"}, ].forEach((it) => { - const params: any[] = (it.input != null) || []; - const response = amountToString(params[0], params[1], params[2], params[3]); + const params: any[] = it.input || [] + const response = amountToString(params[0],params[1],params[2],params[3]); expect(response).toBe(it.output); }); }); -}); +}) \ No newline at end of file