mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-06 18:12:05 +00:00
20 lines
778 B
TypeScript
20 lines
778 B
TypeScript
|
|
import { describe, expect, it } from "vitest";
|
||
|
|
import { findDuplicateWoNumberRow } from "@/domain/work-orders/utils/find-duplicate-wo-number-row";
|
||
|
|
import type { WorkOrderTableRow } from "@/domain/work-orders/types/work-order-table-row";
|
||
|
|
|
||
|
|
const rows = [
|
||
|
|
{ id: "wo-1", woNumber: "12345678901" },
|
||
|
|
{ id: "wo-2", woNumber: "99999999999" },
|
||
|
|
] as WorkOrderTableRow[];
|
||
|
|
|
||
|
|
describe("findDuplicateWoNumberRow", () => {
|
||
|
|
it("returns a matching row when the wo number already exists", () => {
|
||
|
|
expect(findDuplicateWoNumberRow("12345678901", rows)).toEqual(rows[0]);
|
||
|
|
});
|
||
|
|
|
||
|
|
it("ignores blank values and excluded ids", () => {
|
||
|
|
expect(findDuplicateWoNumberRow("", rows)).toBeUndefined();
|
||
|
|
expect(findDuplicateWoNumberRow("12345678901", rows, "wo-1")).toBeUndefined();
|
||
|
|
});
|
||
|
|
});
|