|
@@ -33,3 +33,28 @@ pub fn render_post_listing(
|
33
|
33
|
),
|
34
|
34
|
)
|
35
|
35
|
}
|
|
36
|
+
|
|
37
|
+mod tests {
|
|
38
|
+ #[allow(unused_imports)]
|
|
39
|
+ use super::render_post;
|
|
40
|
+
|
|
41
|
+ #[test]
|
|
42
|
+ fn test_render_post() {
|
|
43
|
+ let output = render_post(
|
|
44
|
+ "<html><head><title>Test</title></head><body>{{ contents }}</body></html>",
|
|
45
|
+ "<article><h1>{{ title }}</h1><div>{{ body }}</div></article>",
|
|
46
|
+ &Post {
|
|
47
|
+ title: String::from("hello world"),
|
|
48
|
+ body: String::from("lorem ipsum dolor sit amet"),
|
|
49
|
+ slug: String::from("hello-world"),
|
|
50
|
+ },
|
|
51
|
+ ).replace("\n", "");
|
|
52
|
+
|
|
53
|
+ assert_eq!(
|
|
54
|
+ "<html><head><title>Test</title></head><body><article><h1>hello wo\
|
|
55
|
+ rld</h1><div><p>lorem ipsum dolor sit amet</p></div></article></b\
|
|
56
|
+ ody></html>",
|
|
57
|
+ &output,
|
|
58
|
+ );
|
|
59
|
+ }
|
|
60
|
+}
|