feat : notify new update income
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
isDeploymentId,
|
||||
isDeploymentStatus,
|
||||
parseDeploymentStatusEvent,
|
||||
} from "./status";
|
||||
|
||||
const deploymentId = "a".repeat(40);
|
||||
|
||||
describe("deployment lifecycle status", () => {
|
||||
it("accepts supported statuses and full commit identifiers", () => {
|
||||
expect(isDeploymentId(deploymentId)).toBe(true);
|
||||
expect(isDeploymentId("abc123")).toBe(false);
|
||||
expect(isDeploymentStatus("deploying")).toBe(true);
|
||||
expect(isDeploymentStatus("ready")).toBe(true);
|
||||
expect(isDeploymentStatus("failed")).toBe(true);
|
||||
expect(isDeploymentStatus("unknown")).toBe(false);
|
||||
});
|
||||
|
||||
it("parses a valid lifecycle event", () => {
|
||||
expect(parseDeploymentStatusEvent(JSON.stringify({
|
||||
deploymentId,
|
||||
status: "deploying",
|
||||
updatedAt: "2026-09-26T12:00:00.000Z",
|
||||
}))).toEqual({
|
||||
deploymentId,
|
||||
status: "deploying",
|
||||
updatedAt: "2026-09-26T12:00:00.000Z",
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects malformed or incomplete events", () => {
|
||||
expect(parseDeploymentStatusEvent("not-json")).toBeNull();
|
||||
expect(parseDeploymentStatusEvent(JSON.stringify({
|
||||
deploymentId,
|
||||
status: "unknown",
|
||||
updatedAt: "2026-09-26T12:00:00.000Z",
|
||||
}))).toBeNull();
|
||||
expect(parseDeploymentStatusEvent(JSON.stringify({
|
||||
deploymentId,
|
||||
status: "ready",
|
||||
updatedAt: "not-a-date",
|
||||
}))).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user