From 6f8df3e00da00b977c623cc2e1b42d53d06d259f Mon Sep 17 00:00:00 2001 From: paku Date: Wed, 2 Oct 2024 15:00:47 +0900 Subject: [PATCH] Add missing test cases --- tests/hsx.lisp | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/tests/hsx.lisp b/tests/hsx.lisp index f7edd0d..b96b52e 100644 --- a/tests/hsx.lisp +++ b/tests/hsx.lisp @@ -24,4 +24,44 @@ 'div (hsx/builtin:div) :div) - "div"))))) + "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))))))