const fs = require('fs')
const path = require('path')
const assert = require('assert')

function read(relativePath) {
  return fs.readFileSync(path.join(__dirname, '..', relativePath), 'utf8')
}

const personalCreateDialog = read('src/views/loanPricing/workflow/components/PersonalCreateDialog.vue')
const corporateCreateDialog = read('src/views/loanPricing/workflow/components/CorporateCreateDialog.vue')

assert(
  !personalCreateDialog.includes('const validateIdNum ='),
  '个人新增弹窗仍包含证件号码格式校验函数'
)

assert(
  !corporateCreateDialog.includes('const validateIdNum ='),
  '企业新增弹窗仍包含证件号码格式校验函数'
)

assert(
  personalCreateDialog.includes("idNum: [") &&
    personalCreateDialog.includes('{required: true, message: "证件号码不能为空", trigger: "blur"}'),
  '个人新增弹窗证件号码规则应仅保留必填'
)

assert(
  corporateCreateDialog.includes("idNum: [") &&
    corporateCreateDialog.includes('{required: true, message: "证件号码不能为空", trigger: "blur"}'),
  '企业新增弹窗证件号码规则应仅保留必填'
)

console.log('id number validation removal assertions passed')
