Add tests as a PoC. Do not for merge.
This commit is contained in:
parent
d857acfeee
commit
0d057a6d07
2 changed files with 63 additions and 2 deletions
|
@ -31,11 +31,13 @@
|
|||
(intern "COLESLAW-TESTS" :coleslaw-tests))))
|
||||
|
||||
(defsystem #:coleslaw-tests
|
||||
:depends-on (coleslaw fiveam)
|
||||
:depends-on (coleslaw fiveam stefil)
|
||||
:pathname "tests/"
|
||||
:serial t
|
||||
:components ((:file "packages")
|
||||
(:file "tests")))
|
||||
(:file "tests")
|
||||
(:module "plugins"
|
||||
(:file "twitter-summary-card"))))
|
||||
|
||||
(defmethod operation-done-p ((op test-op)
|
||||
(c (eql (find-system :coleslaw))))
|
||||
|
|
59
tests/plugins/twitter-summary-card.lisp
Normal file
59
tests/plugins/twitter-summary-card.lisp
Normal file
|
@ -0,0 +1,59 @@
|
|||
(stefil:define-test-package :twitter-summary-card-tests
|
||||
(:use :cl :coleslaw
|
||||
:cl-ppcre))
|
||||
|
||||
(in-package :twitter-summary-card-tests)
|
||||
;;;;
|
||||
;; To run tests first eval the plugin code inside this package and then execute
|
||||
;; (twitter-summary-card-test:run-package-tests)
|
||||
;;;
|
||||
|
||||
|
||||
(defvar *short-post*
|
||||
(make-instance 'post :title "hai" :text "very greetings" :format "html"))
|
||||
|
||||
(defvar *long-post*
|
||||
(make-instance 'post :title "What a Wonderful World"
|
||||
:text "I see trees of green, red roses too. I see them
|
||||
bloom, for me and you. And I think to myself, what a wonderful world.
|
||||
|
||||
I see skies of blue,
|
||||
And clouds of white.
|
||||
The bright blessed day,
|
||||
The dark sacred night.
|
||||
And I think to myself,
|
||||
What a wonderful world.
|
||||
|
||||
The colors of the rainbow,
|
||||
So pretty in the sky.
|
||||
Are also on the faces,
|
||||
Of people going by,
|
||||
I see friends shaking hands.
|
||||
Saying, \"How do you do?\"
|
||||
They're really saying,
|
||||
\"I love you\".
|
||||
|
||||
I hear babies cry,
|
||||
I watch them grow,
|
||||
They'll learn much more,
|
||||
Than I'll ever know.
|
||||
And I think to myself,
|
||||
What a wonderful world.
|
||||
|
||||
Yes, I think to myself,
|
||||
What a wonderful world. " :format "html"))
|
||||
|
||||
(deftest summary-card-sans-twitter-handle ()
|
||||
(let ((summary-card (summary-card *short-post* nil)))
|
||||
(is (null (scan "twitter:author" summary-card)))))
|
||||
|
||||
(deftest summary-card-with-twitter-handle ()
|
||||
(let ((summary-card (summary-card *short-post* "@PuercoPop")))
|
||||
(is (scan "twitter:author" summary-card))))
|
||||
|
||||
(deftest summary-card-trims-long-post ()
|
||||
(let ((summary-card (summary-card *long-post* nil)))
|
||||
;; (scan "twitter:description\" content=\"(.*)\"" summary-card)
|
||||
summary-card))
|
||||
|
||||
|
Loading…
Add table
Reference in a new issue