shoc-frontend-new/src/test/domain/work-orders/utils/service-notes-ui.test.ts

28 lines
909 B
TypeScript

import { describe, expect, it } from "vitest";
import {
hasServiceNotesDetails,
truncateServiceNotesPreview,
} from "@/domain/work-orders/utils/service-notes-ui";
describe("hasServiceNotesDetails", () => {
it("is false when empty", () => {
expect(hasServiceNotesDetails("", [])).toBe(false);
expect(hasServiceNotesDetails(null, null)).toBe(false);
});
it("is true when notes or extras exist", () => {
expect(hasServiceNotesDetails("service notes", [])).toBe(true);
expect(hasServiceNotesDetails("", ["Filter change"])).toBe(true);
});
});
describe("truncateServiceNotesPreview", () => {
it("keeps short notes", () => {
expect(truncateServiceNotesPreview("service notes")).toBe("service notes");
});
it("truncates long notes with ellipsis", () => {
const long = "a".repeat(40);
expect(truncateServiceNotesPreview(long)).toBe(`${"a".repeat(30)}…`);
});
});