1#[cfg(test)]
2mod tests {
3 use crate::mj_wrapper::MjWrapper;
4
5 #[test]
6 fn serialize() {
7 let mut elt = MjWrapper::default();
8 elt.attributes.insert("margin".into(), Some("42px".into()));
9 assert_eq!(
10 serde_json::to_string(&elt).unwrap(),
11 r#"{"type":"mj-wrapper","attributes":{"margin":"42px"}}"#
12 );
13 }
14
15 #[test]
16 fn deserialize() {
17 let json = r#"{"type":"mj-wrapper","attributes":{"margin-bottom":"20px"},"children":[{"type":"comment","children":"Hello World!"},"Hello World!"]}"#;
18 let res: MjWrapper = serde_json::from_str(json).unwrap();
19 assert_eq!(res.attributes.len(), 1);
20 assert_eq!(res.children.len(), 2);
21 }
22}