2024-07-28 15:45:06 +02:00
|
|
|
(defpackage ml-sbt/tests/main
|
2023-06-29 17:19:12 +02:00
|
|
|
(:use :cl
|
2024-07-28 15:45:06 +02:00
|
|
|
:ml-sbt
|
2023-06-29 17:19:12 +02:00
|
|
|
:rove))
|
2024-03-30 08:45:53 +01:00
|
|
|
|
2024-07-28 15:45:06 +02:00
|
|
|
(in-package :ml-sbt/tests/main)
|
2023-06-29 17:19:12 +02:00
|
|
|
|
2023-11-25 09:59:03 +01:00
|
|
|
;; NOTE: To run this test file, execute `(asdf:test-system :dev.metalisp.sbt)' in your Lisp.
|
2024-01-27 21:30:25 +01:00
|
|
|
|
|
|
|
(deftest test-with-page
|
|
|
|
(let ((result (with-output-to-string (spinneret:*html*)
|
|
|
|
(with-page (:title "Example")
|
|
|
|
(:h2 "Hello World")))))
|
|
|
|
(testing "Testing with-page macro"
|
|
|
|
(ok (search "<title>Example</title>" result))
|
|
|
|
(ok (search "<h2>Hello World</h2>" result)))))
|
2024-03-30 08:45:53 +01:00
|
|
|
|
|
|
|
(deftest test-remove-special-chars
|
|
|
|
(testing "Removes all special characters from the string STR except numbers and alphabets."
|
|
|
|
(ok (string= (remove-special-chars "a1b!@#$%^&*()c2") "a1bc2"))))
|
|
|
|
|
|
|
|
(deftest test-clean-form-str
|
|
|
|
(testing "Cleans a form string for use as a name or identifier."
|
|
|
|
(ok (string= (clean-form-str " hello WORLD") "hello-world"))))
|
|
|
|
|
2024-04-03 10:34:08 +02:00
|
|
|
(deftest test-build-str-name
|
2024-03-30 08:45:53 +01:00
|
|
|
(testing "Builds a standardized string by adding a 'group-' prefix and applying cleaning functions."
|
2024-04-03 10:34:08 +02:00
|
|
|
(ok (string= (build-str-name "somename") "group-somename"))))
|
2024-03-30 08:45:53 +01:00
|
|
|
|
2024-04-03 10:34:08 +02:00
|
|
|
(deftest test-build-str-value
|
2024-03-30 08:45:53 +01:00
|
|
|
(testing "Trims leading and trailing spaces from the given value string."
|
2024-04-03 10:34:08 +02:00
|
|
|
(ok (string= (build-str-value " hello-world ") "hello-world"))))
|
2024-03-30 08:45:53 +01:00
|
|
|
|
2024-04-03 10:34:08 +02:00
|
|
|
(deftest test-build-str-value-prop
|
2024-03-30 08:45:53 +01:00
|
|
|
(testing "Builds a value property string by applying various cleaning functions."
|
2024-04-03 10:34:08 +02:00
|
|
|
(ok (string= (build-str-value-prop " hello world ") "hello-world"))))
|