import assert from "node:assert/strict"; import test from "node:test"; import { purchaseSheetModel, settingsModel } from "./pro-view-model.js";
test("purchase model explains limits, localized price, and all safe outcomes", () => {
  const free = purchaseSheetModel({ product:{available:true,localizedPrice:"₩9,900"}, entitlement:{tier:"free"} });
  assert.match(free.description,/모든 원격 기능은 무료/); assert.match(free.description,/계정 1개/); assert.match(free.description,/최대 5개/); assert.equal(free.price,"₩9,900");
  assert.match(purchaseSheetModel({outcome:"pending",entitlement:{tier:"free"}}).message,/결제 확인 중/);
  assert.match(purchaseSheetModel({outcome:"canceled",entitlement:{tier:"free"}}).message,/구매가 취소/);
  assert.match(purchaseSheetModel({outcome:"unavailable",entitlement:{tier:"free"}}).message,/Google Play/);
  assert.match(purchaseSheetModel({entitlement:{tier:"pro"}}).message,/Pro가 활성화/);
});
test("settings model shows tier, configured count, grace, and expiry", () => {
  assert.deepEqual(settingsModel({entitlement:{tier:"free",maxAccounts:1},accountCount:1}),{label:"무료",count:"1 / 1",warning:null,expiresAt:null,restoreLabel:"구매 복원",manageLabel:"Google Play에서 관리",expiresLabel:"만료"});
  assert.deepEqual(settingsModel({entitlement:{tier:"grace",maxAccounts:5,expiresAt:"2026-09-01"},accountCount:3}),{label:"Pro 유예",count:"3 / 5",warning:"검증 서비스에 다시 연결해야 합니다.",expiresAt:"2026-09-01",restoreLabel:"구매 복원",manageLabel:"Google Play에서 관리",expiresLabel:"만료"});
});

test("Pro purchase and settings copy follows the selected English language", () => {
  const purchase = purchaseSheetModel({ language:"en", product:{available:true,localizedPrice:"$9.99"}, entitlement:{tier:"free"}, outcome:"pending" });
  assert.match(purchase.description,/remote features remain free/i);
  assert.match(purchase.description,/one account/i);
  assert.match(purchase.description,/up to five/i);
  assert.equal(purchase.title,"Pro multi-account");
  assert.equal(purchase.purchaseLabel,"Purchase");
  assert.match(purchase.message,/confirming your payment/i);
  const settings = settingsModel({ language:"en", entitlement:{tier:"grace",maxAccounts:5,expiresAt:"2026-09-01"},accountCount:3 });
  assert.equal(settings.label,"Pro grace period");
  assert.match(settings.warning,/verification service/i);
  assert.equal(settings.restoreLabel,"Restore purchase");
  assert.equal(settings.manageLabel,"Manage in Google Play");
});
