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