import { describe, it, expect } from "vitest";
import { calculateHealthScore, calculateSmokeTestScore, } from "../../../scanners/deploy/health-checker.js";
describe("health-checker", () => {
    describe("calculateHealthScore", () => {
        it("returns 100 for all healthy", () => {
            const results = [
                { endpoint: "/", status: "healthy", responseTime: 100, checkedAt: new Date().toISOString() },
                { endpoint: "/api", status: "healthy", responseTime: 150, checkedAt: new Date().toISOString() },
            ];
            expect(calculateHealthScore(results)).toBe(100);
        });
        it("returns 60 for all degraded", () => {
            const results = [
                { endpoint: "/", status: "degraded", responseTime: 600, checkedAt: new Date().toISOString() },
            ];
            expect(calculateHealthScore(results)).toBe(60);
        });
        it("returns 20 for all unhealthy", () => {
            const results = [
                { endpoint: "/", status: "unhealthy", responseTime: 0, error: "500", checkedAt: new Date().toISOString() },
            ];
            expect(calculateHealthScore(results)).toBe(20);
        });
        it("returns 0 for all timeout", () => {
            const results = [
                { endpoint: "/", status: "timeout", responseTime: 10000, error: "timeout", checkedAt: new Date().toISOString() },
            ];
            expect(calculateHealthScore(results)).toBe(0);
        });
        it("returns 50 for empty results", () => {
            expect(calculateHealthScore([])).toBe(50);
        });
        it("calculates mixed results correctly", () => {
            const results = [
                { endpoint: "/", status: "healthy", responseTime: 100, checkedAt: new Date().toISOString() },
                { endpoint: "/api", status: "degraded", responseTime: 600, checkedAt: new Date().toISOString() },
            ];
            expect(calculateHealthScore(results)).toBe(80); // (100 + 60) / 2
        });
    });
    describe("calculateSmokeTestScore", () => {
        it("returns 100 for all passed", () => {
            const results = [
                { name: "test1", endpoint: "/", passed: true, statusCode: 200, responseTime: 100, assertions: [] },
                { name: "test2", endpoint: "/api", passed: true, statusCode: 200, responseTime: 150, assertions: [] },
            ];
            expect(calculateSmokeTestScore(results)).toBe(100);
        });
        it("returns 0 for all failed", () => {
            const results = [
                { name: "test1", endpoint: "/", passed: false, statusCode: 500, responseTime: 100, assertions: [], error: "error" },
            ];
            expect(calculateSmokeTestScore(results)).toBe(0);
        });
        it("returns 50 for empty results", () => {
            expect(calculateSmokeTestScore([])).toBe(50);
        });
        it("calculates mixed results correctly", () => {
            const results = [
                { name: "test1", endpoint: "/", passed: true, statusCode: 200, responseTime: 100, assertions: [] },
                { name: "test2", endpoint: "/api", passed: false, statusCode: 500, responseTime: 100, assertions: [] },
            ];
            expect(calculateSmokeTestScore(results)).toBe(50);
        });
    });
});
//# sourceMappingURL=health-checker.test.js.map