use super::base_parse; use crate::common::serialize_yaml; use compiler::parser; use insta::assert_snapshot; fn test_dir(case: &str) { let mut elem = mock_element(case); let name = insta::_macro_support::AutoName; let dir = elem.properties.pop().unwrap(); let val = serialize_yaml(dir); assert_snapshot!(name, val, case); } #[test] fn test_custom_dir() { let cases = [ r#"

"#, // test, N/A, r#"

"#, // test, N/A, add ]; for case in cases { test_dir(case); } } #[test] fn test_bind_dir() { let cases = [ r#"

"#, // bind, N/A, r#"

"#, // bind, ^_^ r#"

"#, // bind, ^_^, prop r#"

"#, // bind, _:, prop r#"

"#, // bind, [a.b], stop r#"

"#, // bind, nothing r#"

"#, // bind, nothing, r#"

"#, // unicode, VUE in hand sign ]; for case in cases { test_dir(case); } } #[test] fn test_prop_dir() { let cases = [ r#"

"#, // bind, stop, prop r#"

"#, // bind, ^-^, attr|prop r#"

"#, // bind, dynamic, prop r#"

"#, // t, N/A, [dynamic] ]; for case in cases { test_dir(case); } } #[test] fn test_on_dir() { let cases = [ r#"

"#, // on, N/A, r#"

"#, // on , :: , r#"

"#, // on , _@ , r#"

"#, // on, _@, stop r#"

"#, // on, N/A, stop ]; for case in cases { test_dir(case); } } #[test] fn test_slot_dir() { let cases = [ r#"

"#, // slot, default, r#"

"#, // slot, :), r#"

"#, // slot, @_@, r#"

"#, // slot, .-., r#"

"#, // slot@, N/A, @ ]; for case in cases { test_dir(case); } } #[test] fn test_dir_parse_error() { let cases = [ r#"

"#, // ERROR, r#"

"#, // ERROR, r#"

"#, // ERROR, r#"

"#, // ERROR r#"

"#, // ERROR r#"

"#, // ERROR: slot, N/A, - ]; for case in cases { test_dir(case); } } pub fn mock_element(s: &str) -> parser::Element { let mut m = base_parse(s).children; m.pop().unwrap().into_element() }