summaryrefslogtreecommitdiffstats
path: root/vendor/handlebars/tests
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/handlebars/tests')
-rw-r--r--vendor/handlebars/tests/escape.rs25
-rw-r--r--vendor/handlebars/tests/helper_macro.rs20
2 files changed, 45 insertions, 0 deletions
diff --git a/vendor/handlebars/tests/escape.rs b/vendor/handlebars/tests/escape.rs
index 4a737f5ce..2b9512290 100644
--- a/vendor/handlebars/tests/escape.rs
+++ b/vendor/handlebars/tests/escape.rs
@@ -27,19 +27,44 @@ fn test_string_no_escape_422() {
handlebars_helper!(replace: |input: str, from: str, to: str| {
input.replace(from, to)
});
+ handlebars_helper!(echo: |input: str| {
+ input
+ });
hbs.register_helper("replace", Box::new(replace));
+ hbs.register_helper("echo", Box::new(echo));
assert_eq!(
r#"some\ path"#,
hbs.render_template(r#"{{replace "some/path" "/" "\\ " }}"#, &())
.unwrap()
);
+ assert_eq!(
+ r#"some\ path"#,
+ hbs.render_template(r#"{{replace 'some/path' '/' '\\ ' }}"#, &())
+ .unwrap()
+ );
assert_eq!(
r#"some\path"#,
hbs.render_template(r#"{{replace "some/path" "/" "\\" }}"#, &())
.unwrap()
);
+ assert_eq!(
+ r#"some\path"#,
+ hbs.render_template(r#"{{replace 'some/path' '/' '\\' }}"#, &())
+ .unwrap()
+ );
+
+ assert_eq!(
+ r#"double-quoted \ 'with' "nesting""#,
+ hbs.render_template(r#"{{echo "double-quoted \\ 'with' \"nesting\""}}"#, &())
+ .unwrap()
+ );
+ assert_eq!(
+ r#"single-quoted \ 'with' "nesting""#,
+ hbs.render_template(r#"{{echo 'single-quoted \\ \'with\' "nesting"'}}"#, &())
+ .unwrap()
+ );
}
#[test]
diff --git a/vendor/handlebars/tests/helper_macro.rs b/vendor/handlebars/tests/helper_macro.rs
index cc5ed914b..f40ab778a 100644
--- a/vendor/handlebars/tests/helper_macro.rs
+++ b/vendor/handlebars/tests/helper_macro.rs
@@ -86,4 +86,24 @@ fn test_macro_helper() {
.unwrap(),
"2015-02-18"
);
+
+ assert_eq!(
+ hbs.render_template("{{eq image.link null}}", &json!({"image": {"link": null}}))
+ .unwrap(),
+ "true"
+ );
+
+ assert_eq!(
+ hbs.render_template(
+ "{{eq image.link null}}",
+ &json!({"image": {"link": "https://url"}})
+ )
+ .unwrap(),
+ "false"
+ );
+
+ assert_eq!(
+ hbs.render_template("{{tag 'html'}}", &()).unwrap(),
+ "<html>"
+ );
}