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

twitter-summary-card.lisp 1.8KB

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