#[test]
fn html_rejects_node_limit_exceeded() {
let rule = parse_rule_file(
r#"
version: 2
input:
format: html
html:
records_selector: ".item"
fields:
name:
value: text
mappings:
- target: "name"
source: "name"
"#,
)
.expect("parse rule");
let options = NormalizationOptions {
max_html_nodes: 1,
..NormalizationOptions::default()
};
let err = normalize_records_with_options(
&rule,
InputData::Text(r#"<div><p class="item">Alice</p></div>"#),
&options,
)
.expect_err("node limit should fail");
assert_eq!(err.kind, TransformErrorKind::InvalidInput);
}
#[test]
fn html_rejects_parser_created_node_limit_exceeded() {
let rule = parse_rule_file(
r#"
version: 2
input:
format: html
html:
records_selector: ".item"
fields:
name:
value: text
mappings:
- target: "name"
source: "name"
"#,
)
.expect("parse rule");
let options = NormalizationOptions {
max_html_nodes: 1,
..NormalizationOptions::default()
};
let err = normalize_records_with_options(
&rule,
InputData::Text(r#"<p class="item">Alice</p>"#),
&options,
)
.expect_err("parsed DOM node limit should fail");
assert_eq!(err.kind, TransformErrorKind::InvalidInput);
}