From c44869d7c6741ef4b9ce1c905baf917733019799 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Mon, 25 Jun 2018 14:46:07 +0200 Subject: Add test for 'truncate' filter --- testing/tests/filters.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/testing/tests/filters.rs b/testing/tests/filters.rs index 96f03f6..e05e1f6 100644 --- a/testing/tests/filters.rs +++ b/testing/tests/filters.rs @@ -155,3 +155,17 @@ fn test_filter_let_filter() { }; assert_eq!(t.render().unwrap(), "BAR"); } + +#[derive(Template)] +#[template(source = "{{ foo|truncate(10) }}{{ foo|truncate(5) }}", ext = "txt", print = "code")] +struct TruncateFilter { + foo: String, +} + +#[test] +fn test_filter_truncate() { + let t = TruncateFilter { + foo: "alpha bar".into(), + }; + assert_eq!(t.render().unwrap(), "alpha baralpha..."); +} -- cgit