import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";

const viewPath = path.resolve("src/views/PurchaseOrderView.vue");
const source = fs.readFileSync(viewPath, "utf8");

assert.match(
  source,
  /function\s+formatUnitPriceTonHint\s*\(/,
  "purchase order view should provide a unit-price ton hint formatter"
);

assert.match(
  source,
  /formatUnitPriceTonHint\(item\.unit_price\)/,
  "purchase order item editor should show 元/kg converted to 元/t"
);

assert.match(
  source,
  /formatUnitPriceDisplay\(item\.unit_price\)/,
  "purchase order detail rows should show both 元/kg and 元/t"
);

assert.match(
  source,
  /materialChipSubtitle[\s\S]*formatUnitPriceDisplay\(item\.unit_price\)/,
  "purchase order material chips should show both 元/kg and 元/t"
);

console.log("purchase order ton price hint checks passed");
