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

const componentPath = path.resolve(
  __dirname,
  "../../src/views/ccdiStaffFmyRelation/index.vue"
);
const source = fs.readFileSync(componentPath, "utf8");

[
  "annualIncome: null",
  "label=\"家庭成员年收入\"",
  "v-model=\"form.annualIncome\"",
  "this.form.annualIncome = response.data.annualIncome",
  "payload.annualIncome = this.normalizeAnnualIncome(payload.annualIncome);",
  "normalizeAnnualIncome(value)",
  "validateAnnualIncome(value, fieldLabel = \"家庭成员年收入\")",
  "assetInfoList: []",
  "normalizeAssetInfoList()",
  "response.data.assetInfoList || []",
  "this.form.assetInfoList = this.normalizeAssetInfoList();",
  "this.form.assetInfoList.push(this.createEmptyAssetRow());",
  "relationCertType: null",
  "relationCertNo: null",
].forEach((token) => {
  assert(
    source.includes(token),
    `亲属资产提交流程缺少关键处理: ${token}`
  );
});

[
  "delete payload.assetInfoList[index].familyId",
  "delete payload.assetInfoList[index].personId",
  "delete asset.familyId",
  "delete asset.personId",
].forEach((token) => {
  assert(
    source.includes(token),
    `提交前需要清理归属字段: ${token}`
  );
});

console.log("staff-family-asset-submit-flow test passed");
