use crate::{json::FromJson as _, tariff, test};

use super::Tariff;

#[test]
fn should_parse_v221_tariff_json_as_v211_with_unexpected_fields() {
    const TARIFF_JSON: &str = include_str!("../../../test_data/v221/every_field_set/tariff.json");

    test::setup();
    let tariff::ParseReport {
        tariff,
        unexpected_fields,
    } = tariff::parse_with_version(TARIFF_JSON, crate::Version::V211).unwrap();

    let expected = vec![
        "$.country_code",
        "$.elements.0.price_components.0.vat",
        "$.elements.0.restrictions.max_current",
        "$.elements.0.restrictions.min_current",
        "$.elements.0.restrictions.reservation",
        "$.elements.1.price_components.0.vat",
        "$.elements.2.price_components.0.vat",
        "$.end_date_time",
        "$.energy_mix.environ_impact.0.category",
        "$.energy_mix.environ_impact.1.category",
        "$.max_price",
        "$.max_price.excl_vat",
        "$.max_price.incl_vat",
        "$.min_price",
        "$.min_price.excl_vat",
        "$.min_price.incl_vat",
        "$.party_id",
        "$.type",
    ];

    assert_eq!(unexpected_fields.into_strings(), expected);

    let tariff = Tariff::from_json(tariff.as_element()).unwrap();
    let (_tariff, warnings) = tariff.into_parts();
    assert!(warnings.is_empty());
}
