codama_nodes/value_nodes/
none_value_node.rs

1use codama_nodes_derive::node;
2
3#[node]
4#[derive(Default)]
5pub struct NoneValueNode {}
6
7impl From<NoneValueNode> for crate::Node {
8    fn from(val: NoneValueNode) -> Self {
9        crate::Node::Value(val.into())
10    }
11}
12
13impl NoneValueNode {
14    pub fn new() -> Self {
15        Self::default()
16    }
17}
18
19#[cfg(test)]
20mod tests {
21    use super::*;
22
23    #[test]
24    fn new() {
25        let node = NoneValueNode::new();
26        assert_eq!(node, NoneValueNode {});
27    }
28
29    #[test]
30    fn to_json() {
31        let node = NoneValueNode::new();
32        let json = serde_json::to_string(&node).unwrap();
33        assert_eq!(json, r#"{"kind":"noneValueNode"}"#);
34    }
35
36    #[test]
37    fn from_json() {
38        let json = r#"{"kind":"noneValueNode"}"#;
39        let node: NoneValueNode = serde_json::from_str(json).unwrap();
40        assert_eq!(node, NoneValueNode::new());
41    }
42}