import ListDetailModel from "../ListDetailModel";

import data from "./instrument-detail-data.json";
import contributions from "./instrument-detail-contributions.json";

import Href from "../../href/Href";
import CompositeAttributeModel from "../../attributes/CompositeAttributeModel";

describe("listResultDetail", () => {
  it("should be able to retrieve result information", () => {
    const result = new ListDetailModel({
      request: {
        href: new Href(
          "/decision-instruments/decision-instrument-placeholder-resolving/1/decisions/1",
        ),
      },
      key: "CalculateTotalCost_ConceptDataResolving",
      data: data.CalculateTotalCost_ConceptDataResolving,
      contributions: contributions.CalculateTotalCost_ConceptDataResolving,
    });

    expect(result.attributeCollection).toHaveLength(4);
    expect(result.titleAttribute.readonlyvalue).toBe(
      "Calculate total cost - Concept data resolving",
    );

    expect(result.hasResults).toBe(true);
    expect(result.results).toBeInstanceOf(CompositeAttributeModel);
    expect(result.givenAnswers).toBeInstanceOf(CompositeAttributeModel);

    expect(result.results.children).toHaveLength(5);
    expect(result.givenAnswers.children).toHaveLength(3);
    expect(
      result.givenAnswers.children.map((child) => child.key).join("|"),
    ).toBe("EstimatedPropertyValue|InterestRateType|MortgageTermInYears");
  });
});
