use std::path::PathBuf;
use react_remove_properties::Options;
use swc_common::Mark;
use swc_ecma_parser::{EsSyntax, Syntax};
use swc_ecma_transforms_base::resolver;
use swc_ecma_transforms_testing::{test_fixture, FixtureTestConfig};
fn syntax() -> Syntax {
Syntax::Es(EsSyntax {
jsx: true,
..Default::default()
})
}
#[testing::fixture("tests/fixture/**/input.js")]
fn fixture(input: PathBuf) {
let output = input.parent().unwrap().join("output.js");
test_fixture(
syntax(),
&|_tr| {
let unresolved_mark = Mark::new();
let top_level_mark = Mark::new();
(
resolver(unresolved_mark, top_level_mark, false),
react_remove_properties::react_remove_properties(
if input.to_string_lossy().contains("custom") {
react_remove_properties::Config::WithOptions(Options {
properties: vec!["^data-custom$".into()],
})
} else {
react_remove_properties::Config::All(true)
},
),
)
},
&input,
&output,
FixtureTestConfig {
..Default::default()
},
);
}