codama_nodes/contextual_value_nodes/
account_bump_value_node.rs

1use crate::CamelCaseString;
2use codama_nodes_derive::node;
3
4#[node]
5pub struct AccountBumpValueNode {
6    // Data.
7    pub name: CamelCaseString,
8}
9
10impl From<AccountBumpValueNode> for crate::Node {
11    fn from(val: AccountBumpValueNode) -> Self {
12        crate::Node::ContextualValue(val.into())
13    }
14}
15
16impl AccountBumpValueNode {
17    pub fn new<T>(name: T) -> Self
18    where
19        T: Into<CamelCaseString>,
20    {
21        Self { name: name.into() }
22    }
23}
24
25#[cfg(test)]
26mod tests {
27    use super::*;
28
29    #[test]
30    fn new() {
31        let node = AccountBumpValueNode::new("my_account");
32        assert_eq!(node.name, CamelCaseString::new("myAccount"));
33    }
34
35    #[test]
36    fn to_json() {
37        let node = AccountBumpValueNode::new("myAccount");
38        let json = serde_json::to_string(&node).unwrap();
39        assert_eq!(
40            json,
41            r#"{"kind":"accountBumpValueNode","name":"myAccount"}"#
42        );
43    }
44
45    #[test]
46    fn from_json() {
47        let json = r#"{"kind":"accountBumpValueNode","name":"myAccount"}"#;
48        let node: AccountBumpValueNode = serde_json::from_str(json).unwrap();
49        assert_eq!(node, AccountBumpValueNode::new("myAccount"));
50    }
51}