hsx/tests/dsl.lisp

68 lines
2 KiB
Common Lisp
Raw Normal View History

2024-10-03 02:00:19 +00:00
(defpackage #:hsx-test/dsl
2024-05-25 16:26:26 +00:00
(:use #:cl
#:rove
2024-10-03 02:00:19 +00:00
#:hsx/dsl
#:hsx/builtin)
(:import-from #:hsx/element
#:element-props
#:element-children))
2024-10-03 02:00:19 +00:00
(in-package #:hsx-test/dsl)
2024-05-25 16:26:26 +00:00
2024-10-03 02:00:19 +00:00
(deftest dsl-test
(testing "find-symbols"
2024-10-03 02:00:19 +00:00
(ok (expands
'(hsx (div '(:div "div")
div
(div
'div
(div)
:div)
"div"))
'(hsx/builtin:div '(:div "div")
div
(hsx/builtin:div
'div
(hsx/builtin:div)
:div)
2024-10-02 06:00:47 +00:00
"div"))))
(testing "empty-hsx"
(let ((elm (div)))
(ok (null (element-props elm)))
(ok (null (element-children elm)))))
(testing "hsx-with-static-props"
(let ((elm (div :prop1 "value1" :prop2 "value2")))
(ok (equal '(:prop1 "value1" :prop2 "value2")
(element-props elm)))
(ok (null (element-children elm)))))
(testing "hsx-with-dynamic-props"
(let* ((props '(:prop1 "value1" :prop2 "value2"))
(elm (div props)))
(ok (equal props (element-props elm)))
(ok (null (element-children elm)))))
(testing "hsx-with-children"
(let ((elm (div
"child1"
"child2")))
(ok (null (element-props elm)))
(ok (equal (list "child1" "child2") (element-children elm)))))
(testing "hsx-with-static-props-and-children"
(let ((elm (div :prop1 "value1" :prop2 "value2"
"child1"
"child2")))
(ok (equal '(:prop1 "value1" :prop2 "value2")
(element-props elm)))
(ok (equal (list "child1" "child2") (element-children elm)))))
(testing "hsx-with-dynamic-props-and-children"
(let* ((props '(:prop1 "value1" :prop2 "value2"))
(elm (div props
"child1"
"child2")))
(ok (equal props (element-props elm)))
(ok (equal (list "child1" "child2") (element-children elm))))))