]> git.eshelyaron.com Git - emacs.git/commitdiff
Add more shr HTML rendering tests
authorLars Magne Ingebrigtsen <larsi@gnus.org>
Sun, 20 Mar 2016 12:41:59 +0000 (13:41 +0100)
committerLars Magne Ingebrigtsen <larsi@gnus.org>
Sun, 20 Mar 2016 12:41:59 +0000 (13:41 +0100)
test/data/shr/div-div.html [new file with mode: 0644]
test/data/shr/div-div.txt [new file with mode: 0644]
test/data/shr/div-p.html
test/data/shr/li-div.html [new file with mode: 0644]
test/data/shr/li-div.txt [new file with mode: 0644]
test/lisp/net/shr-tests.el

diff --git a/test/data/shr/div-div.html b/test/data/shr/div-div.html
new file mode 100644 (file)
index 0000000..1c191ae
--- /dev/null
@@ -0,0 +1 @@
+<div>foo</div><div>Bar</div>
diff --git a/test/data/shr/div-div.txt b/test/data/shr/div-div.txt
new file mode 100644 (file)
index 0000000..62715e1
--- /dev/null
@@ -0,0 +1,2 @@
+foo
+Bar
index 810b2f75e3c3cf75ff03cf896706295ea9176b5f..fcbdfc432935c9db83c4aaacfc123443f91b9a1c 100644 (file)
@@ -1 +1 @@
-<div>foo</div><p>Bar
+<div>foo</div><p>Bar</p>
diff --git a/test/data/shr/li-div.html b/test/data/shr/li-div.html
new file mode 100644 (file)
index 0000000..eca3c51
--- /dev/null
@@ -0,0 +1,10 @@
+<ul>
+  <li>
+    <div>
+      <p >This is the first paragraph of a list item.</div>
+    <p >This is the second paragraph of a list item.</li>
+  <li>
+    <div>This is the first paragraph of a list item.</div>
+    <div>This is the second paragraph of a list item.</div>
+  </li>
+</ul>
diff --git a/test/data/shr/li-div.txt b/test/data/shr/li-div.txt
new file mode 100644 (file)
index 0000000..9fc54f2
--- /dev/null
@@ -0,0 +1,6 @@
+* This is the first paragraph of a list item.
+
+  This is the second paragraph of a list item.
+
+* This is the first paragraph of a list item.
+  This is the second paragraph of a list item.
index 60788174d9c9a6b9cefadf455477ec6c6eaf1078..6606ec58151dc17cb6fd30650472cd4ea13648df 100644 (file)
 
 ;;; Code:
 
+(require 'shr)
+
 (defun shr-test (name)
   (with-temp-buffer
     (insert-file-contents (format "data/shr/%s.html" name))
-    (let ((dom (libxml-parse-html-region (point-min) (point-max))))
+    (let ((dom (libxml-parse-html-region (point-min) (point-max)))
+          (shr-width 80)
+          (shr-use-fonts nil))
       (erase-buffer)
       (shr-insert-document dom)
       (cons (buffer-substring-no-properties (point-min) (point-max))
 (ert-deftest rendering ()
   (skip-unless (fboundp 'libxml-parse-html-region))
   (dolist (file (directory-files "data/shr" nil "\\.html\\'"))
-    (let ((result (shr-test (replace-regexp-in-string
-                             "\\.html\\'" "" file))))
-      (should (equal (car result) (cdr result))))))
+    (let* ((name (replace-regexp-in-string "\\.html\\'" "" file))
+           (result (shr-test name)))
+      (unless (equal (car result) (cdr result))
+        (should (not (list name (car result) (cdr result))))))))
 
 (require 'shr)