const assert = require("assert");
const fs = require("fs");
const path = require("path");

const apiPath = path.resolve(__dirname, "../../src/api/ccdiCreditInfo.js");
assert(fs.existsSync(apiPath), "未找到征信维护 API 文件 ccdiCreditInfo.js");

const source = fs.readFileSync(apiPath, "utf8");

[
  "export function uploadCreditHtml(files)",
  "export function listCreditInfo(query)",
  "export function getCreditInfoDetail(personId)",
  "export function deleteCreditInfo(personId)",
  "/ccdi/creditInfo/upload",
  "/ccdi/creditInfo/list",
  "/ccdi/creditInfo/",
  "encodeURIComponent(personId)",
].forEach((token) => {
  assert(source.includes(token), `征信维护 API 缺少关键契约: ${token}`);
});

console.log("credit-info-api-contract test passed");
