use foundation_core::extensions::serde_ext::{DynamicValueExt, JsonValueExt};
use serde_json::json;
#[test]
fn test_value_can_walk() {
let mut value = json!({"tokens": 3, "hello": {"word": "hello"}});
assert!(value.d_walk(|tree, key| {
assert!(tree.contains_key(key));
true
}));
}
#[test]
fn test_value_insert_ok() {
let mut value = json!({"tokens": 3});
let fx_node_value = "hello";
value.d_insert("/happy/word", fx_node_value).unwrap();
let actual_value: String = value.d_get("/happy/word").unwrap();
dbg!(&actual_value);
assert_eq!(actual_value.as_str(), fx_node_value);
}
#[test]
fn test_value_can_take() {
let mut value = json!({"tokens": 3, "hello": {"word": "hello"}});
let content: String = value.d_take("/hello/word").unwrap();
assert_eq!(&content, "hello");
assert!(value.d_get::<String>("hello").is_err());
assert!(value.d_get::<String>("hello/word").is_err());
}