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

const source = fs.readFileSync(
  path.resolve(__dirname, "../../src/views/ccdiProject/components/detail/FamilyAssetLiabilitySection.vue"),
  "utf8"
);

[
  "姓名",
  "身份证号",
  "所属部门",
  "家庭总年收入",
  "家庭总负债",
  "家庭总资产",
  "风险情况",
  "操作",
  "查看详情",
  "el-table",
  "el-table-column",
].forEach((token) => assert(source.includes(token), token));

assert(source.includes("loading"), "列表区块应接收加载状态");
assert(source.includes("rows"), "列表区块应消费列表数据");

const incomeIndex = source.indexOf('label="家庭总年收入"');
const debtIndex = source.indexOf('label="家庭总负债"');
const assetIndex = source.indexOf('label="家庭总资产"');

assert(incomeIndex > -1, "缺少家庭总年收入列");
assert(debtIndex > -1, "缺少家庭总负债列");
assert(assetIndex > -1, "缺少家庭总资产列");
assert(
  incomeIndex < debtIndex && debtIndex < assetIndex,
  "汇总列顺序应为家庭总年收入、家庭总负债、家庭总资产"
);
