diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-09-07 20:42:54 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2017-09-07 20:42:54 +0200 |
commit | e559ed42102d425f23701e061cdea509a0f325b4 (patch) | |
tree | 6a4515df896b388bac3e2e1b9ea4031b1aec0d73 /testing | |
parent | 07e9b307c88d33900f1843239582edc0ac546c4a (diff) | |
download | askama-e559ed42102d425f23701e061cdea509a0f325b4.tar.gz askama-e559ed42102d425f23701e061cdea509a0f325b4.tar.bz2 askama-e559ed42102d425f23701e061cdea509a0f325b4.zip |
Move JSON test into filters test module
Diffstat (limited to '')
-rw-r--r-- | testing/tests/filters.rs | 30 | ||||
-rw-r--r-- | testing/tests/simple.rs | 29 |
2 files changed, 31 insertions, 28 deletions
diff --git a/testing/tests/filters.rs b/testing/tests/filters.rs index 39fe0ff..8e558ba 100644 --- a/testing/tests/filters.rs +++ b/testing/tests/filters.rs @@ -1,7 +1,11 @@ #[macro_use] extern crate askama; +#[macro_use] +extern crate serde_json; use askama::Template; +use serde_json::Value; + #[derive(Template)] #[template(path = "filters.html")] @@ -74,3 +78,29 @@ fn test_vec_join() { let t = VecJoinTemplate { s: vec!["foo".into(), "bar".into(), "bazz".into()] }; assert_eq!(t.render().unwrap(), "foo, bar, bazz"); } + + +#[derive(Template)] +#[template(path = "json.html")] +struct JsonTemplate<'a> { + foo: &'a str, + bar: &'a Value, +} + +#[test] +fn test_json() { + let val = json!({"arr": [ "one", 2, true, null ]}); + let t = JsonTemplate { foo: "a", bar: &val }; + // Note: the json filter lacks a way to specify initial indentation + assert_eq!(t.render().unwrap(), r#"{ + "foo": "a", + "bar": { + "arr": [ + "one", + 2, + true, + null + ] +} +}"#); +} diff --git a/testing/tests/simple.rs b/testing/tests/simple.rs index 93faf50..eac7c4b 100644 --- a/testing/tests/simple.rs +++ b/testing/tests/simple.rs @@ -1,10 +1,8 @@ #[macro_use] extern crate askama; -#[macro_use] -extern crate serde_json; use askama::Template; -use serde_json::Value; + #[derive(Template)] #[template(path = "simple.html")] @@ -146,31 +144,6 @@ fn test_generics() { #[derive(Template)] -#[template(path = "json.html")] -struct JsonTemplate<'a> { - foo: &'a str, - bar: &'a Value, -} - -#[test] -fn test_json() { - let val = json!({"arr": [ "one", 2, true, null ]}); - let t = JsonTemplate { foo: "a", bar: &val }; - // Note: the json filter lacks a way to specify initial indentation - assert_eq!(t.render().unwrap(), r#"{ - "foo": "a", - "bar": { - "arr": [ - "one", - 2, - true, - null - ] -} -}"#); -} - -#[derive(Template)] #[template(path = "composition.html")] struct CompositionTemplate { foo: IfTemplate, |