Add questionnaire tests

This commit is contained in:
Marcus Kammer 2023-08-26 14:28:30 +02:00
parent 075944afcd
commit ad9e376f15
Signed by: marcuskammer
GPG key ID: C374817BE285268F
3 changed files with 32 additions and 2 deletions

View file

@ -55,6 +55,7 @@
(:file "list-group")
(:file "navbar")
(:file "nav-tab")
(:file "form"))))
(:file "form")
(:file "questionnaire"))))
:description "Test system for cl-sbt"
:perform (test-op (op c) (symbol-call :rove :run c)))

View file

@ -123,5 +123,4 @@ Example:
`(question ,ask
(:group ,group :type ,input-type)
,@remaining-choices)))))
(btn-primary (:type "submit") "Submit"))))

View file

@ -0,0 +1,30 @@
(defpackage cl-sbt/tests/questionnaire
(:use
:cl
:cl-sbt
:rove)
(:import-from
:cl-sbt/questionnaire
:question
:resolve-input-type
:resolve-input-and-choices
:questionnaire))
(in-package :cl-sbt/tests/questionnaire)
(deftest test-resolve-input-type
(testing "Test for resolve-input-type"
(ok (string= "radio" (resolve-input-type "single")))
(ok (string= "checkbox" (resolve-input-type "multiple")))
(ok (string= "text" (resolve-input-type "text")))))
(deftest test-resolve-input-and-choices
(testing "Test for resolve-input-and-choices"
(multiple-value-bind (type choices)
(resolve-input-and-choices '(:radio "A" "B"))
(ok (string= type "radio"))
(ok (equal choices '("A" "B"))))
(multiple-value-bind (type choices)
(resolve-input-and-choices '("A" "B"))
(ok (null type))
(ok (equal choices '("A" "B"))))))