浏览代码

Add tests as a PoC. Do not for merge.

Javier Olaechea 10 年之前
父节点
当前提交
c286fc1e33
共有 1 个文件被更改,包括 59 次插入0 次删除
  1. 59 0
      tests/plugins/twitter-summary-card.lisp

+ 59 - 0
tests/plugins/twitter-summary-card.lisp

@@ -0,0 +1,59 @@
1
+(stefil:define-test-package :twitter-summary-card-tests
2
+  (:use :cl :coleslaw
3
+             :cl-ppcre))
4
+
5
+(in-package :twitter-summary-card-tests)
6
+;;;; 
7
+;; To run tests first eval the plugin code inside this package and then execute
8
+;; (twitter-summary-card-test:run-package-tests)
9
+;;;
10
+
11
+
12
+(defvar *short-post*
13
+    (make-instance 'post :title "hai" :text "very greetings" :format "html"))
14
+
15
+(defvar *long-post* 
16
+    (make-instance 'post :title "What a Wonderful World"
17
+                   :text "I see trees of green, red roses too.  I see them
18
+bloom, for me and you.  And I think to myself, what a wonderful world.
19
+
20
+I see skies of blue, 
21
+And clouds of white. 
22
+The bright blessed day, 
23
+The dark sacred night. 
24
+And I think to myself, 
25
+What a wonderful world. 
26
+
27
+The colors of the rainbow, 
28
+So pretty in the sky. 
29
+Are also on the faces, 
30
+Of people going by, 
31
+I see friends shaking hands. 
32
+Saying, \"How do you do?\" 
33
+They're really saying, 
34
+\"I love you\". 
35
+
36
+I hear babies cry, 
37
+I watch them grow, 
38
+They'll learn much more, 
39
+Than I'll ever know. 
40
+And I think to myself, 
41
+What a wonderful world. 
42
+
43
+Yes, I think to myself, 
44
+What a wonderful world. " :format "html"))
45
+
46
+(deftest summary-card-sans-twitter-handle ()
47
+  (let ((summary-card (summary-card *short-post* nil)))
48
+    (is (null (scan "twitter:author" summary-card)))))
49
+
50
+(deftest summary-card-with-twitter-handle ()
51
+  (let ((summary-card (summary-card *short-post* "@PuercoPop")))
52
+    (is (scan "twitter:author" summary-card))))
53
+
54
+(deftest summary-card-trims-long-post ()
55
+  (let ((summary-card (summary-card *long-post* nil)))
56
+    ;; (scan "twitter:description\" content=\"(.*)\"" summary-card)
57
+    summary-card))
58
+
59
+