Add more shr HTML rendering tests
This commit is contained in:
parent
4f9c775700
commit
21c89971c3
6 changed files with 29 additions and 5 deletions
1
test/data/shr/div-div.html
Normal file
1
test/data/shr/div-div.html
Normal file
|
@ -0,0 +1 @@
|
|||
<div>foo</div><div>Bar</div>
|
2
test/data/shr/div-div.txt
Normal file
2
test/data/shr/div-div.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
foo
|
||||
Bar
|
|
@ -1 +1 @@
|
|||
<div>foo</div><p>Bar
|
||||
<div>foo</div><p>Bar</p>
|
||||
|
|
10
test/data/shr/li-div.html
Normal file
10
test/data/shr/li-div.html
Normal file
|
@ -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>
|
6
test/data/shr/li-div.txt
Normal file
6
test/data/shr/li-div.txt
Normal file
|
@ -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.
|
|
@ -23,10 +23,14 @@
|
|||
|
||||
;;; 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))
|
||||
|
@ -37,9 +41,10 @@
|
|||
(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)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue