use std::assert_matches;
use crate::{json, schema, test, warning};
const TARIFF: &str = r#"{
"country_code": "NLD",
"party_id": "ENE",
"currency": "EUR"
}"#;
#[test]
fn should_return_the_element_of_the_matching_warning() {
test::setup();
let doc = json::parse_object(TARIFF).unwrap();
let root = doc.root();
let country_code = root.find_field("country_code").unwrap().element();
let currency = root.find_field("currency").unwrap().element();
let mut warnings = warning::Set::<schema::Warning>::new();
warnings.insert(country_code, schema::Warning::NonSpecField);
warnings.insert(currency, schema::Warning::NullField);
warnings.insert(currency, schema::Warning::UnexpectedField);
let (element, warning) = warnings
.find(|warning| matches!(warning, schema::Warning::UnexpectedField))
.unwrap();
assert_eq!(element.path.as_str(), "$.currency");
assert_matches!(warning, schema::Warning::UnexpectedField);
}