Fixes from subagent review: - render-tests.lisp: added (in-suite box-suite) — tests were registered to default suite, never executed by runner - dirty-tests.lisp: same fix - cl-tui.asd: version 0.2.0 → 0.3.0 - render.lisp: component-children default method (c t) nil for protocol completeness (component-parent already had this)
49 lines
1.8 KiB
Common Lisp
49 lines
1.8 KiB
Common Lisp
(in-package :cl-tui-box-test)
|
|
(in-suite box-suite)
|
|
|
|
(defun make-capturing-backend ()
|
|
(let* ((s (make-string-output-stream))
|
|
(b (make-modern-backend :output-stream s)))
|
|
(values b s)))
|
|
|
|
(test render-generic-dispatches-box
|
|
"render dispatches to render-box for box instances"
|
|
(multiple-value-bind (b s) (make-capturing-backend)
|
|
(let ((bx (make-box :border-style :single :width 10 :height 5)))
|
|
(compute-layout (box-layout-node bx) 10 5)
|
|
(render bx b)
|
|
(is (search "┌" (get-output-stream-string s)) "box renders border"))))
|
|
|
|
(test render-generic-dispatches-text
|
|
"render dispatches to render-text for text instances"
|
|
(multiple-value-bind (b s) (make-capturing-backend)
|
|
(let ((tx (make-text "Hello" :width 10 :height 1)))
|
|
(compute-layout (text-layout-node tx) 10 1)
|
|
(render tx b)
|
|
(is (search "Hello" (get-output-stream-string s)) "text renders content"))))
|
|
|
|
(test component-layout-node-works
|
|
"component-layout-node returns the right slot for each type"
|
|
(let ((bx (make-box)) (tx (make-text "")))
|
|
(is (typep (component-layout-node bx) 'layout-node))
|
|
(is (typep (component-layout-node tx) 'layout-node))))
|
|
|
|
(test component-children-returns-nil
|
|
"Leaf components have no children"
|
|
(let ((bx (make-box)) (tx (make-text "")))
|
|
(is (null (component-children bx)))
|
|
(is (null (component-children tx)))))
|
|
|
|
(test propagate-dirty-marks-component
|
|
"propagate-dirty marks the component dirty"
|
|
(let ((c (make-box)))
|
|
(mark-clean c)
|
|
(is-false (dirty-p c) "should be clean after mark-clean")
|
|
(propagate-dirty c)
|
|
(is-true (dirty-p c) "should be dirty after propagate-dirty")))
|
|
|
|
(test available-width-defaults
|
|
"available-width returns 0 for components without explicit width"
|
|
(let ((c (make-box)))
|
|
(is (= (available-width c) 0))))
|