#![cfg(all(feature = "codegen-v2", feature = "serde"))]
use tree_type::tree_type;
#[test]
fn test_transparent_root_node() {
tree_type! {
#[transparent]
Root {
#[default("test content")]
file("test.txt")
}
}
let root = Root::new("/tmp/test").unwrap();
let json = serde_json::to_string(&root).unwrap();
assert!(
!json.contains("\"path\""),
"Transparent type should not wrap path in object"
);
assert!(
json.contains("/tmp/test"),
"Should serialize as path string"
);
}
#[test]
fn test_transparent_root_child() {
tree_type! {
Root {
#[transparent]
#[default("child content")]
child("child.txt")
}
}
let root = Root::new("/tmp/test").unwrap();
let child = root.child();
let json = serde_json::to_string(&child).unwrap();
assert!(
!json.contains("\"path\""),
"Transparent child should not wrap path in object"
);
assert!(
json.contains("/tmp/test/child.txt"),
"Should serialize as path string"
);
}