import type { ContentExpectations, ExpectationResult } from "../../expect/types";

import { checkContentExpectations } from "../../expect/content";
import { mismatchFailure } from "../../expect/failure";

export function checkBanner(banner: string, expectations: ContentExpectations): ExpectationResult {
  return checkContentExpectations(banner, expectations, { path: "banner", phase: "banner" });
}

export function checkConnected(connected: boolean, expected: boolean): ExpectationResult {
  if (connected === expected) return { failure: null, matched: true };
  if (!connected && expected) {
    return {
      failure: mismatchFailure("connected", "connected", true, false, "期望端口可达但连接失败"),
      matched: false,
    };
  }
  return {
    failure: mismatchFailure("connected", "connected", false, true, "期望端口不可达但连接成功"),
    matched: false,
  };
}
