hsx/tests/hsx.lisp

60 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"
2024-05-26 12:45:49 +00:00
(list)))))
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"
2024-05-26 12:45:49 +00:00
(list :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"
2024-05-26 12:45:49 +00:00
(list)
2024-05-26 03:26:09 +00:00
"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"
2024-05-26 12:45:49 +00:00
(list :prop1 "value1" :prop2 "value2")
2024-05-26 03:26:09 +00:00
"child1"
"child2"))))
(defcomp comp (&key prop1 prop2 children)
2024-05-26 07:14:33 +00:00
(declare (ignore prop1 prop2 children)))
2024-05-26 03:26:09 +00:00
(test component-hsx
(is (equal (macroexpand-1
'(comp :prop1 "value1" :prop2 "value2"
"child1"
"child2"))
'(create-element
#'%comp
2024-05-26 12:45:49 +00:00
(list :prop1 "value1" :prop2 "value2")
2024-05-26 03:26:09 +00:00
"child1"
"child2"))))