/*
 This file is part of GNU Taler
 (C) 2026 Taler Systems S.A.

 GNU Taler is free software; you can redistribute it and/or modify it under the
 terms of the GNU General Public License as published by the Free Software
 Foundation; either version 3, or (at your option) any later version.

 GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

 You should have received a copy of the GNU General Public License along with
 GNU Taler; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
 */

import test from "ava";
import { TalerAmlProperties } from "../taler-account-properties.js";
import { TalerFormAttributes } from "../taler-form-attributes.js";
import { deriveTopsAmlProperties } from "./properties.js";

test("AML prop derivation for TOPS, unknown form", (t) => {
  {
    const props = deriveTopsAmlProperties("custom_does_not_exist132", {}, {});
    t.deepEqual(props, {});
  }
});

test("AML prop derivation for TOPS, vqf_902_4", (t) => {
  {
    const props = deriveTopsAmlProperties(
      "vqf_902_4",
      {
        [TalerFormAttributes.RISK_CLASSIFICATION_LEVEL]: "HIGH_RISK",
      },
      {
        PEP_FOREIGN: true,
      },
    );
    t.deepEqual(props, {
      [TalerAmlProperties.PEP_DOMESTIC]: false,
      [TalerAmlProperties.PEP_INTERNATIONAL_ORGANIZATION]: false,
      [TalerAmlProperties.HIGH_RISK_CUSTOMER]: true,
      [TalerAmlProperties.HIGH_RISK_COUNTRY]: false,
      // Value from form overrides old prop by default
      [TalerAmlProperties.PEP_FOREIGN]: false,
    });
  }
});

test("AML prop derivation for TOPS, vqf_902_1_officer", (t) => {
  {
    const props = deriveTopsAmlProperties("vqf_902_1_officer", {}, {});
    t.deepEqual(props, {
      [TalerAmlProperties.ACCOUNT_OPEN]: true,
    });
  }
});
