test: Add test for json filter
This commit is contained in:
parent
e899e99ea1
commit
e71dc3c8ca
|
@ -48,6 +48,7 @@ dependencies = [
|
|||
"sailfish",
|
||||
"sailfish-compiler",
|
||||
"sailfish-macros",
|
||||
"serde_json",
|
||||
"trybuild",
|
||||
]
|
||||
|
||||
|
|
|
@ -6,9 +6,10 @@ edition = "2018"
|
|||
publish = false
|
||||
|
||||
[dependencies]
|
||||
sailfish = { path = "../../sailfish", default-features = false }
|
||||
sailfish = { path = "../../sailfish", default-features = false, features = ["json"] }
|
||||
sailfish-macros = { path = "../../sailfish-macros" }
|
||||
sailfish-compiler = { path = "../../sailfish-compiler" }
|
||||
serde_json = "1.0.60"
|
||||
|
||||
[dev-dependencies]
|
||||
trybuild = "1.0.28"
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"name": "JSON test",
|
||||
"data": {"age":43,"name":"John Doe","phones":["+44 1234567","+44 2345678"]}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"name": "JSON test",
|
||||
"data": <%- data | json %>
|
||||
}
|
|
@ -290,6 +290,26 @@ fn test_filter() {
|
|||
assert_render("filter", Filter { message: "hello" });
|
||||
}
|
||||
|
||||
#[derive(TemplateOnce)]
|
||||
#[template(path = "json-filter.stpl")]
|
||||
struct JsonFilter {
|
||||
data: serde_json::Value,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_json_filter() {
|
||||
let data = serde_json::json!({
|
||||
"name": "John Doe",
|
||||
"age": 43,
|
||||
"phones": [
|
||||
"+44 1234567",
|
||||
"+44 2345678"
|
||||
]
|
||||
});
|
||||
|
||||
assert_render("json-filter", JsonFilter { data });
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
mod unix {
|
||||
use super::*;
|
||||
|
|
Loading…
Reference in New Issue