Flexible Lisp Blogware. Fork for personal use. Mirrored from https://github.com/kingcons/coleslaw originally.

twitter-summary-card.lisp 1.6KB

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