hsx/tests/defhsx.lisp

75 lines
1.9 KiB
Common Lisp
Raw Normal View History

(defpackage #:hsx-test/defhsx
(:use #:cl
#:fiveam
#:hsx/defhsx
#:hsx/builtin)
(:import-from #:hsx/element
#:create-element))
(in-package #:hsx-test/defhsx)
(def-suite defhsx-test)
(in-suite defhsx-test)
(test empty-hsx
2024-05-29 02:47:48 +00:00
(is (equal '(create-element
:div
2024-05-29 02:47:48 +00:00
(list))
(macroexpand-1
'(div)))))
(test hsx-with-props
2024-05-29 02:47:48 +00:00
(is (equal '(create-element
:div
2024-05-29 02:47:48 +00:00
(list :prop1 "value1" :prop2 "value2"))
(macroexpand-1
'(div :prop1 "value1" :prop2 "value2")))))
(test hsx-with-children
2024-05-29 02:47:48 +00:00
(is (equal '(create-element
:div
(list)
"child1"
2024-05-29 02:47:48 +00:00
"child2")
(macroexpand-1
'(div
"child1"
"child2")))))
(test hsx-with-props-and-children
2024-05-29 02:47:48 +00:00
(is (equal '(create-element
:div
(list :prop1 "value1" :prop2 "value2")
"child1"
2024-05-29 02:47:48 +00:00
"child2")
(macroexpand-1
'(div :prop1 "value1" :prop2 "value2"
"child1"
"child2")))))
(deftag custom)
2024-05-28 11:48:39 +00:00
(test hsx-for-custom-tag
2024-05-29 02:47:48 +00:00
(is (equal '(create-element
:custom
(list :prop1 "value1" :prop2 "value2")
"child1"
2024-05-29 02:47:48 +00:00
"child2")
(macroexpand-1
'(custom :prop1 "value1" :prop2 "value2"
"child1"
"child2")))))
(defcomp comp (&key prop1 prop2 children)
(declare (ignore prop1 prop2 children)))
2024-05-28 11:48:39 +00:00
(test hsx-for-component
2024-05-29 02:47:48 +00:00
(is (equal '(create-element
(fdefinition '%comp)
(list :prop1 "value1" :prop2 "value2")
"child1"
2024-05-29 02:47:48 +00:00
"child2")
(macroexpand-1
'(comp :prop1 "value1" :prop2 "value2"
"child1"
"child2")))))