use super::Tariff;
use crate::{
json::{self, FromJson as _},
tariff, test,
};
#[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, warnings) = tariff::build(
json::parse_object(TARIFF_JSON).unwrap(),
crate::Version::V211,
)
.into_parts();
let unexpected_fields = warnings.unexpected_fields();
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",
"$.min_price",
"$.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());
}