2024-05-25 16:26:26 +00:00
|
|
|
(defpackage #:hsx-test/hsx
|
|
|
|
(:use #:cl
|
|
|
|
#:fiveam
|
2024-06-06 05:59:46 +00:00
|
|
|
#: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
|
|
|
|
2024-05-28 03:33:01 +00:00
|
|
|
(test find-symbols
|
2024-05-30 03:55:13 +00:00
|
|
|
(is (equal '(hsx/builtin:div '(:div "div")
|
2024-05-29 02:47:48 +00:00
|
|
|
div
|
|
|
|
(hsx/builtin:div
|
2024-05-30 03:55:13 +00:00
|
|
|
'div
|
|
|
|
(hsx/builtin:div)
|
|
|
|
:div)
|
|
|
|
"div")
|
2024-05-29 02:47:48 +00:00
|
|
|
(macroexpand-1
|
2024-05-30 03:55:13 +00:00
|
|
|
'(hsx (div '(:div "div")
|
2024-05-28 07:13:41 +00:00
|
|
|
div
|
|
|
|
(div
|
2024-05-30 03:55:13 +00:00
|
|
|
'div
|
|
|
|
(div)
|
|
|
|
:div)
|
|
|
|
"div"))))))
|
2024-06-06 05:59:46 +00:00
|
|
|
|
|
|
|
(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)))))
|