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

const source = fs.readFileSync(
  path.resolve(__dirname, "../../src/api/ccdi/projectSpecialCheck.js"),
  "utf8"
);

[
  "getExtendedPurchaseList",
  "getExtendedPurchaseDetail",
  "getExtendedRecruitmentList",
  "getExtendedRecruitmentDetail",
  "getExtendedTransferList",
  "getExtendedTransferDetail",
  "/ccdi/project/special-check/extended-query/purchase/list",
  "/ccdi/project/special-check/extended-query/purchase/detail",
  "/ccdi/project/special-check/extended-query/recruitment/list",
  "/ccdi/project/special-check/extended-query/recruitment/detail",
  "/ccdi/project/special-check/extended-query/transfer/list",
  "/ccdi/project/special-check/extended-query/transfer/detail",
].forEach((token) => assert(source.includes(token), token));

const purchaseListBlock = source.slice(
  source.indexOf("export function getExtendedPurchaseList"),
  source.indexOf("export function getExtendedPurchaseDetail")
);
assert(purchaseListBlock.includes("projectId"), "采购列表缺少 projectId");
assert(purchaseListBlock.includes("applicantName"), "采购列表缺少 applicantName");
assert(purchaseListBlock.includes("applyDateStart"), "采购列表缺少 applyDateStart");
assert(purchaseListBlock.includes("applyDateEnd"), "采购列表缺少 applyDateEnd");

const recruitmentListBlock = source.slice(
  source.indexOf("export function getExtendedRecruitmentList"),
  source.indexOf("export function getExtendedRecruitmentDetail")
);
assert(recruitmentListBlock.includes("projectId"), "招聘列表缺少 projectId");
assert(recruitmentListBlock.includes("interviewerName"), "招聘列表缺少 interviewerName");

const transferListBlock = source.slice(
  source.indexOf("export function getExtendedTransferList"),
  source.indexOf("export function getExtendedTransferDetail")
);
assert(transferListBlock.includes("projectId"), "调动列表缺少 projectId");
assert(transferListBlock.includes("staffName"), "调动列表缺少 staffName");
assert(transferListBlock.includes("transferDateStart"), "调动列表缺少 transferDateStart");
assert(transferListBlock.includes("transferDateEnd"), "调动列表缺少 transferDateEnd");

const purchaseDetailBlock = source.slice(source.indexOf("export function getExtendedPurchaseDetail"), source.length);
assert(purchaseDetailBlock.includes("purchaseId"), "采购详情缺少 purchaseId");
assert(purchaseDetailBlock.includes("recruitId"), "招聘详情缺少 recruitId");
assert(purchaseDetailBlock.includes("id"), "调动详情缺少 id");
