mrml/mj_accordion_title/
json.rs1#[cfg(test)]
2mod tests {
3 use crate::mj_accordion_title::MjAccordionTitle;
4 use crate::text::Text;
5
6 #[test]
7 fn serialize() {
8 let mut elt = MjAccordionTitle::default();
9 elt.attributes
10 .insert("margin".to_string(), Some("12px".to_string()));
11 elt.children.push(Text::from("Hello"));
12 elt.children.push(Text::from("World"));
13 assert_eq!(
14 serde_json::to_string(&elt).unwrap(),
15 r#"{"type":"mj-accordion-title","attributes":{"margin":"12px"},"children":["Hello","World"]}"#
16 );
17 }
18
19 #[test]
20 fn deserialize() {
21 let json = r#"{"type":"mj-accordion-title","attributes":{"margin":"12px"},"children":["Hello","World"]}"#;
22 let res: MjAccordionTitle = serde_json::from_str(json).unwrap();
23 assert_eq!(res.children.len(), 2);
24 let next = serde_json::to_string(&res).unwrap();
25 assert_eq!(next, json);
26 }
27}