hsx/tests/hsx.lisp

64 lines
1.5 KiB
Common Lisp
Raw Normal View History

2024-05-25 16:26:26 +00:00
(defpackage #:hsx-test/hsx
(:use #:cl
#:fiveam
2024-05-26 03:26:09 +00:00
#:hsx/hsx)
(:import-from #:hsx/element
#:create-element))
2024-05-25 16:26:26 +00:00
(in-package #:hsx-test/hsx)
2024-05-26 03:26:09 +00:00
(def-suite hsx-test)
(in-suite hsx-test)
2024-05-25 16:26:26 +00:00
(test empty-hsx
2024-05-26 03:26:09 +00:00
(is (equal (macroexpand-1
'(div))
'(create-element
"div"
'nil))))
2024-05-25 16:26:26 +00:00
(test hsx-with-props
2024-05-26 03:26:09 +00:00
(is (equal (macroexpand-1
'(div :prop1 "value1" :prop2 "value2"))
'(create-element
"div"
'(:prop1 "value1" :prop2 "value2")))))
2024-05-25 16:26:26 +00:00
(test hsx-with-children
2024-05-26 03:26:09 +00:00
(is (equal (macroexpand-1
'(div
"child1"
"child2"))
'(create-element
"div"
'nil
"child1"
"child2"))))
2024-05-25 16:26:26 +00:00
(test hsx-with-props-and-children
2024-05-26 03:26:09 +00:00
(is (equal (macroexpand-1
'(div :prop1 "value1" :prop2 "value2"
"child1"
"child2"))
'(create-element
"div"
'(:prop1 "value1" :prop2 "value2")
"child1"
"child2"))))
(defcomp comp (&key prop1 prop2 children)
(div
prop1
prop2
children))
(test component-hsx
(is (equal (macroexpand-1
'(comp :prop1 "value1" :prop2 "value2"
"child1"
"child2"))
'(create-element
#'%comp
'(:prop1 "value1" :prop2 "value2")
"child1"
"child2"))))