]> git.eshelyaron.com Git - emacs.git/commitdiff
; Add a test for 'dom-print'
authorEshel Yaron <me@eshelyaron.com>
Tue, 16 Jan 2024 14:29:12 +0000 (15:29 +0100)
committerEshel Yaron <me@eshelyaron.com>
Tue, 16 Jan 2024 14:29:12 +0000 (15:29 +0100)
* test/lisp/dom-tests.el (dom-tests-print): New test.

test/lisp/dom-tests.el

index 8cbfb9ad9df81f7b9764440ba14eac83557a91b4..a4e913541bf47293aaf31f8f980dfdeb158badd7 100644 (file)
@@ -209,6 +209,16 @@ child results in an error."
       (dom-pp node t)
       (should (equal (buffer-string) "(\"foo\" nil)")))))
 
+(ert-deftest dom-tests-print ()
+  "Test that `dom-print' correctly encodes HTML reserved characters."
+  (with-temp-buffer
+    (dom-print '(samp ((class . "samp")) "<div class=\"default\"> </div>"))
+    (should (equal
+             (buffer-string)
+             (concat "<samp class=\"samp\">"
+                     "&lt;div class=&quot;default&quot;&gt; &lt;/div&gt;"
+                     "</samp>")))))
+
 (ert-deftest dom-test-search ()
   (let ((dom '(a nil (b nil (c nil)))))
     (should (equal (dom-search dom (lambda (d) (eq (dom-tag d) 'a)))