Browse Source

Test post rendering

master
Dylan Baker 5 years ago
parent
commit
3da5f4d4c0
1 changed files with 25 additions and 0 deletions
  1. 25
    0
      src/render.rs

+ 25
- 0
src/render.rs View File

@@ -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
+}

Loading…
Cancel
Save