hsx/tests/hsx.lisp

70 lines
2 KiB
Common Lisp
Raw Permalink Normal View History

2024-05-25 16:26:26 +00:00
(defpackage #:hsx-test/hsx
(:use #:cl
#:fiveam
#:hsx/hsx
#:hsx/builtin)
(:import-from #:hsx/element
#:element-props
#:element-children))
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-27 02:10:11 +00:00
(test find-symbols
(is (equal '(hsx/builtin:div '(:div "div")
2024-05-29 02:47:48 +00:00
div
(hsx/builtin:div
'div
(hsx/builtin:div)
:div)
"div")
2024-05-29 02:47:48 +00:00
(macroexpand-1
'(hsx (div '(:div "div")
2024-05-28 07:13:41 +00:00
div
(div
'div
(div)
:div)
"div"))))))
(test empty-hsx
(let ((elm (div)))
(is (null (element-props elm)))
(is (null (element-children elm)))))
(test hsx-with-static-props
(let ((elm (div :prop1 "value1" :prop2 "value2")))
(is (equal '(:prop1 "value1" :prop2 "value2")
(element-props elm)))
(is (null (element-children elm)))))
(test hsx-with-dynamic-props
(let* ((props '(:prop1 "value1" :prop2 "value2"))
(elm (div props)))
(is (equal props (element-props elm)))
(is (null (element-children elm)))))
(test hsx-with-children
(let ((elm (div
"child1"
"child2")))
(is (null (element-props elm)))
(is (equal (list "child1" "child2") (element-children elm)))))
(test hsx-with-static-props-and-children
(let ((elm (div :prop1 "value1" :prop2 "value2"
"child1"
"child2")))
(is (equal '(:prop1 "value1" :prop2 "value2")
(element-props elm)))
(is (equal (list "child1" "child2") (element-children elm)))))
(test hsx-with-dynamic-props-and-children
(let* ((props '(:prop1 "value1" :prop2 "value2"))
(elm (div props
"child1"
"child2")))
(is (equal props (element-props elm)))
(is (equal (list "child1" "child2") (element-children elm)))))