UNPKG

@gorizond/catalog-backend-module-fleet

Version:

Backstage catalog backend module for Rancher Fleet GitOps entities

105 lines (104 loc) 5.61 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const types_1 = require("./types"); // ============================================================================ // FLEET_STATUS_PRIORITY Tests // ============================================================================ describe("FLEET_STATUS_PRIORITY", () => { it("should have Ready as lowest priority (0)", () => { expect(types_1.FLEET_STATUS_PRIORITY["Ready"]).toBe(0); }); it("should have ErrApplied as highest priority (6)", () => { expect(types_1.FLEET_STATUS_PRIORITY["ErrApplied"]).toBe(6); }); it("should have all expected statuses", () => { expect(types_1.FLEET_STATUS_PRIORITY).toHaveProperty("Ready"); expect(types_1.FLEET_STATUS_PRIORITY).toHaveProperty("NotReady"); expect(types_1.FLEET_STATUS_PRIORITY).toHaveProperty("Pending"); expect(types_1.FLEET_STATUS_PRIORITY).toHaveProperty("OutOfSync"); expect(types_1.FLEET_STATUS_PRIORITY).toHaveProperty("Modified"); expect(types_1.FLEET_STATUS_PRIORITY).toHaveProperty("WaitApplied"); expect(types_1.FLEET_STATUS_PRIORITY).toHaveProperty("ErrApplied"); }); it("should have priorities in correct order", () => { expect(types_1.FLEET_STATUS_PRIORITY["Ready"]).toBeLessThan(types_1.FLEET_STATUS_PRIORITY["NotReady"]); expect(types_1.FLEET_STATUS_PRIORITY["NotReady"]).toBeLessThan(types_1.FLEET_STATUS_PRIORITY["Pending"]); expect(types_1.FLEET_STATUS_PRIORITY["Pending"]).toBeLessThan(types_1.FLEET_STATUS_PRIORITY["OutOfSync"]); expect(types_1.FLEET_STATUS_PRIORITY["OutOfSync"]).toBeLessThan(types_1.FLEET_STATUS_PRIORITY["Modified"]); expect(types_1.FLEET_STATUS_PRIORITY["Modified"]).toBeLessThan(types_1.FLEET_STATUS_PRIORITY["WaitApplied"]); expect(types_1.FLEET_STATUS_PRIORITY["WaitApplied"]).toBeLessThan(types_1.FLEET_STATUS_PRIORITY["ErrApplied"]); }); }); // ============================================================================ // getWorstStatus Tests // ============================================================================ describe("getWorstStatus", () => { it("should return Ready for empty array", () => { expect((0, types_1.getWorstStatus)([])).toBe("Ready"); }); it("should return Ready for array of Ready statuses", () => { expect((0, types_1.getWorstStatus)(["Ready", "Ready", "Ready"])).toBe("Ready"); }); it("should return worst status from mixed array", () => { expect((0, types_1.getWorstStatus)(["Ready", "NotReady", "Pending"])).toBe("Pending"); }); it("should return ErrApplied as worst when present", () => { expect((0, types_1.getWorstStatus)(["Ready", "ErrApplied", "NotReady"])).toBe("ErrApplied"); }); it("should handle undefined values", () => { expect((0, types_1.getWorstStatus)([undefined, "Ready", undefined])).toBe("Ready"); }); it("should handle all undefined values", () => { expect((0, types_1.getWorstStatus)([undefined, undefined])).toBe("Ready"); }); it("should handle unknown status with high priority", () => { expect((0, types_1.getWorstStatus)(["Ready", "UnknownStatus"])).toBe("UnknownStatus"); }); it("should handle single status", () => { expect((0, types_1.getWorstStatus)(["Modified"])).toBe("Modified"); }); it("should prefer OutOfSync over NotReady", () => { expect((0, types_1.getWorstStatus)(["NotReady", "OutOfSync"])).toBe("OutOfSync"); }); it("should prefer Modified over OutOfSync", () => { expect((0, types_1.getWorstStatus)(["OutOfSync", "Modified"])).toBe("Modified"); }); it("should prefer WaitApplied over Modified", () => { expect((0, types_1.getWorstStatus)(["Modified", "WaitApplied"])).toBe("WaitApplied"); }); }); // ============================================================================ // statusToLifecycle Tests // ============================================================================ describe("statusToLifecycle", () => { it("should return production for Ready status", () => { expect((0, types_1.statusToLifecycle)("Ready")).toBe("production"); }); it("should return experimental for Pending status", () => { expect((0, types_1.statusToLifecycle)("Pending")).toBe("experimental"); }); it("should return experimental for WaitApplied status", () => { expect((0, types_1.statusToLifecycle)("WaitApplied")).toBe("experimental"); }); it("should return deprecated for NotReady status", () => { expect((0, types_1.statusToLifecycle)("NotReady")).toBe("deprecated"); }); it("should return deprecated for OutOfSync status", () => { expect((0, types_1.statusToLifecycle)("OutOfSync")).toBe("deprecated"); }); it("should return deprecated for Modified status", () => { expect((0, types_1.statusToLifecycle)("Modified")).toBe("deprecated"); }); it("should return deprecated for ErrApplied status", () => { expect((0, types_1.statusToLifecycle)("ErrApplied")).toBe("deprecated"); }); it("should return production for undefined status", () => { expect((0, types_1.statusToLifecycle)(undefined)).toBe("production"); }); it("should return production for unknown status", () => { expect((0, types_1.statusToLifecycle)("UnknownStatus")).toBe("production"); }); it("should return production for empty string", () => { expect((0, types_1.statusToLifecycle)("")).toBe("production"); }); });