39 lines
1.2 KiB
Common Lisp
39 lines
1.2 KiB
Common Lisp
(defpackage #:hsx-test/utils
|
|
(:use #:cl
|
|
#:rove
|
|
#:hsx/utils))
|
|
(in-package #:hsx-test/utils)
|
|
|
|
(deftest text-util-test
|
|
(testing "escape-html-attribute"
|
|
(ok (string= ""foo""
|
|
(escape-html-attribute "\"foo\""))))
|
|
|
|
(testing "escape-html-text-content"
|
|
(ok (string= "&<>"'/`="
|
|
(escape-html-text-content "&<>\"'/`="))))
|
|
|
|
(testing "minify"
|
|
;; Test with Alpine.js
|
|
(ok (string= (minify "{
|
|
open: false,
|
|
get isOpen() { return this.open },
|
|
toggle() { this.open = ! this.open },
|
|
}")
|
|
"{ open: false, get isOpen() { return this.open }, toggle() { this.open = ! this.open }, }"))))
|
|
|
|
(defgroup fruit
|
|
apple banana)
|
|
|
|
(deftest group-util-test
|
|
(testing "defgroup"
|
|
(ok (expands '(defgroup fruit apple banana)
|
|
'(progn
|
|
(defparameter *fruit*
|
|
(hsx/utils::make-keyword-hash-table '(apple banana)))
|
|
(defun fruit-p (keyword)
|
|
(gethash keyword *fruit*)))))
|
|
(ok (hash-table-p *fruit*))
|
|
(ok (fboundp 'fruit-p))
|
|
(ok (fruit-p :apple))
|
|
(ng (fruit-p :tomato))))
|