use super::cargo::emit_cargo_toml;
use crate::core::config::ResolvedCrateConfig;
use crate::core::config::languages::DartConfig;
use crate::core::ir::ApiSurface;
#[test]
fn cargo_toml_excludes_named_feature_from_core_dep_line_but_keeps_others() {
let api = ApiSurface::default();
let config = ResolvedCrateConfig {
name: "sample-lib".to_string(),
dart: Some(DartConfig {
features: Some(vec!["native-http".to_string(), "wasm-http".to_string()]),
excluded_default_features: vec!["native-http".to_string()],
..Default::default()
}),
..Default::default()
};
let file = emit_cargo_toml("packages/dart/rust", &api, &config, "sample_lib");
let core_dep_line = file
.content
.lines()
.find(|l| l.trim_start().starts_with("sample_lib ="))
.expect("core dependency line must be emitted");
assert!(
!core_dep_line.contains("native-http"),
"excluded_default_features must drop the name from the core dependency's own explicit \
features = [...] line, not just the wrapper's default array:\n{core_dep_line}"
);
assert!(
core_dep_line.contains("wasm-http"),
"a feature nobody excluded must still be forwarded to the core dependency line:\n{core_dep_line}"
);
toml::from_str::<toml::Value>(&file.content).expect("generated Cargo.toml must be valid TOML");
}