From 267916b237cb4b3a409be39d553a6eb0f5a54aca Mon Sep 17 00:00:00 2001 From: Marcus Kammer Date: Fri, 28 Jul 2023 18:38:12 +0200 Subject: [PATCH] Add tests for card component --- cl-sbt.asd | 3 ++- tests/component/card.lisp | 55 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 tests/component/card.lisp diff --git a/cl-sbt.asd b/cl-sbt.asd index f260c0f..a8dc386 100644 --- a/cl-sbt.asd +++ b/cl-sbt.asd @@ -47,6 +47,7 @@ ((:file "accordion") (:file "alert") (:file "badge") - (:file "button")))) + (:file "button") + (:file "card")))) :description "Test system for cl-sbt" :perform (test-op (op c) (symbol-call :rove :run c))) diff --git a/tests/component/card.lisp b/tests/component/card.lisp new file mode 100644 index 0000000..a094437 --- /dev/null +++ b/tests/component/card.lisp @@ -0,0 +1,55 @@ +(defpackage cl-sbt/tests/card + (:use + :cl + :cl-sbt + :rove) + (:import-from + :cl-sbt/card + :title + :subtitle + :text + :link + :header + :img + :body + :card-with-img + :card + :card-group)) + +(in-package :cl-sbt/tests/card) + +(deftest test-title + (let ((result (spinneret:with-html-string (title "My Title")))) + (testing "Testing title macro" + (ok (string= "
My Title
" result))))) + +(deftest test-subtitle + (let ((result (spinneret:with-html-string (subtitle "My Subtitle")))) + (testing "Testing subtitle macro" + (ok (string= "
My Subtitle
" result))))) + +(deftest test-text + (let ((result (spinneret:with-html-string (text "Some card text here")))) + (testing "Testing text macro" + (ok (string= "

Some card text here" result))))) + +(deftest test-link + (let ((result (spinneret:with-html-string (link (:href "https://example.com") "Example link")))) + (testing "Testing link macro" + (ok (string= "Example link" result))))) + +(deftest test-header + (let ((result (spinneret:with-html-string (header "My Card Header")))) + (testing "Testing header macro" + (ok (search "class=header" result)) + (ok (search "My Card Header" result))))) + +(deftest test-img + (let ((result (spinneret:with-html-string (img (:src "https://example.com/image.jpg" :alt "An example image"))))) + (testing "Testing img macro" + (ok (string= "\"An" result))))) + +(deftest test-body + (let ((result (spinneret:with-html-string (body (title "My Title") (text "Some card text here"))))) + (testing "Testing body macro" + (ok (string= "

My Title

Some card text here

" result)))))