@crossed/ui
Version:
A universal & performant styling library for React Native, Next.js & React
47 lines (46 loc) • 1.72 kB
JavaScript
import { getSeparator, getFormat, getOrderWithFormat } from "../utils";
describe("Date Utilities", () => {
describe("getSeparator", () => {
it("should return the separator used in French locale", () => {
const result = getSeparator("fr");
expect(result).toBe("/");
});
it("should return the separator used in US locale", () => {
const result = getSeparator("en-US");
expect(result).toBe("/");
});
});
describe("getFormat", () => {
it("should return the date format for French locale", () => {
const result = getFormat("fr");
expect(result).toBe("dd-mm-yyyy");
});
it("should return the date format for US locale", () => {
const result = getFormat("en-US");
expect(result).toBe("mm-dd-yyyy");
});
});
describe("getOrderWithFormat", () => {
it("should return the correct order for French locale", () => {
const format = "yyyy-mm-dd";
const result = getOrderWithFormat("fr", format);
expect(result).toEqual(["dd", "mm", "yyyy"]);
});
it("should return the correct order for US locale", () => {
const format = "yyyy-mm-dd";
const result = getOrderWithFormat("en-US", format);
expect(result).toEqual(["mm", "dd", "yyyy"]);
});
it("should handle different formats correctly", () => {
const format = "yyyy-mm-dd";
const result = getOrderWithFormat("en-US", format);
expect(result).toEqual(["mm", "dd", "yyyy"]);
});
it("should return an empty array for an unknown format", () => {
const format = "abcd";
const result = getOrderWithFormat("en-US", format);
expect(result).toEqual([]);
});
});
});
//# sourceMappingURL=utils.spec.js.map