codama_nodes/contextual_value_nodes/
account_value_node.rs1use crate::{AccountValueNode, CamelCaseString};
2
3impl AccountValueNode {
4 pub fn new<T>(name: T) -> Self
5 where
6 T: Into<CamelCaseString>,
7 {
8 Self { name: name.into() }
9 }
10}
11
12#[cfg(test)]
13mod tests {
14 use super::*;
15
16 #[test]
17 fn new() {
18 let node = AccountValueNode::new("my_account");
19 assert_eq!(node.name, CamelCaseString::new("myAccount"));
20 }
21
22 #[test]
23 fn to_json() {
24 let node = AccountValueNode::new("myAccount");
25 let json = serde_json::to_string(&node).unwrap();
26 assert_eq!(json, r#"{"kind":"accountValueNode","name":"myAccount"}"#);
27 }
28
29 #[test]
30 fn from_json() {
31 let json = r#"{"kind":"accountValueNode","name":"myAccount"}"#;
32 let node: AccountValueNode = serde_json::from_str(json).unwrap();
33 assert_eq!(node, AccountValueNode::new("myAccount"));
34 }
35}