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

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

assert(
  /:picker-options="pullBankInfoDatePickerOptions"/.test(source),
  "拉取本行信息日期范围应绑定专用的 picker-options"
);

assert(
  /pullBankInfoDatePickerOptions/.test(source),
  "组件脚本中应定义拉取本行信息日期范围的专用配置"
);

assert(
  /getPullBankInfoMaxSelectableDate/.test(source),
  "组件脚本中应提供“最晚可选日期”为昨天的统一 helper"
);

assert(
  /getPullBankInfoMinSelectableDate\(\)[\s\S]*?getPullBankInfoMaxSelectableDate\(\)[\s\S]*?setFullYear\([^)]*getFullYear\(\) - 1\)/.test(source),
  "拉取本行信息最早可选日期应跟随最晚可选日期滚动到近一年内"
);

assert(
  !/return new Date\(2025, 0, 1\)/.test(source),
  "拉取本行信息日期范围不应再固定从 2025-01-01 开始"
);

console.log("upload-data-pull-bank-info-date-limit test passed");
