Reorganize repo structure and standards references
This commit is contained in:
1 parent
3cb93a81be
commit
be2054274d
5885 files changed
+2588
-195
No files matched your search
+48
@@ -0,0 +1,48 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import NumberUtils, { NumberFormats } from "./NumberUtils";
|
||||
|
||||
describe("Number Formatting", () => {
|
||||
it("should format integer values correctly", () => {
|
||||
const input = 1234567890;
|
||||
const expectedOutput = "1,234,567,890";
|
||||
const output = NumberUtils.intFormat(input);
|
||||
expect(output).toStrictEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should format decimal values correctly", () => {
|
||||
const input = 1234567.89;
|
||||
const expectedOutput = "1,234,567.89";
|
||||
const output = NumberUtils.decimalFormat(input);
|
||||
expect(output).toStrictEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should format numbers as currency correctly", () => {
|
||||
const input = 1234567.89;
|
||||
const expectedOutput = "1,234,568";
|
||||
const output = NumberUtils.numberFormat(input);
|
||||
expect(output).toStrictEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should pad numbers correctly", () => {
|
||||
const input = 42;
|
||||
const expectedOutput = "00042";
|
||||
const output = NumberUtils.pad(input, 5);
|
||||
expect(output).toStrictEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should have the correct default currency symbol", () => {
|
||||
const expectedOutput = "$";
|
||||
expect(NumberUtils.defaultCurrencySymbol).toStrictEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should have the correct number formats", () => {
|
||||
const expectedOutput = [
|
||||
{ name: "Integer", value: "integer", labelKey: "formats.number.integer" },
|
||||
{ name: "Decimal", value: "decimal", labelKey: "formats.number.decimal" },
|
||||
{ name: "Currency", value: "currency", labelKey: "formats.number.currency" },
|
||||
{ name: "Percent", value: "percentage", labelKey: "formats.number.percent" },
|
||||
{ name: "Rating", value: "rating", labelKey: "formats.number.rating" },
|
||||
];
|
||||
expect(NumberFormats).toStrictEqual(expectedOutput);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user