diff options
author | Lars Magne Ingebrigtsen <larsi@gnus.org> | 2016-03-20 13:41:59 +0100 |
---|---|---|
committer | Lars Magne Ingebrigtsen <larsi@gnus.org> | 2016-03-20 13:41:59 +0100 |
commit | 21c89971c31d8f5c14814d2a18749495ed191d8f (patch) | |
tree | ac12bfd5940556d0f44ffa9634bf0058b961e2e2 /test | |
parent | 4f9c775700d250d8626ce679a1fdd6da58a9fa11 (diff) | |
download | emacs-21c89971c31d8f5c14814d2a18749495ed191d8f.tar.gz |
Add more shr HTML rendering tests
Diffstat (limited to 'test')
-rw-r--r-- | test/data/shr/div-div.html | 1 | ||||
-rw-r--r-- | test/data/shr/div-div.txt | 2 | ||||
-rw-r--r-- | test/data/shr/div-p.html | 2 | ||||
-rw-r--r-- | test/data/shr/li-div.html | 10 | ||||
-rw-r--r-- | test/data/shr/li-div.txt | 6 | ||||
-rw-r--r-- | test/lisp/net/shr-tests.el | 13 |
6 files changed, 29 insertions, 5 deletions
diff --git a/test/data/shr/div-div.html b/test/data/shr/div-div.html new file mode 100644 index 00000000000..1c191ae44d8 --- /dev/null +++ b/test/data/shr/div-div.html @@ -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 index 00000000000..62715e12513 --- /dev/null +++ b/test/data/shr/div-div.txt @@ -0,0 +1,2 @@ +foo +Bar diff --git a/test/data/shr/div-p.html b/test/data/shr/div-p.html index 810b2f75e3c..fcbdfc43293 100644 --- a/test/data/shr/div-p.html +++ b/test/data/shr/div-p.html @@ -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 index 00000000000..eca3c511bd9 --- /dev/null +++ b/test/data/shr/li-div.html @@ -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 index 00000000000..9fc54f2bdc6 --- /dev/null +++ b/test/data/shr/li-div.txt @@ -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. diff --git a/test/lisp/net/shr-tests.el b/test/lisp/net/shr-tests.el index 60788174d9c..6606ec58151 100644 --- a/test/lisp/net/shr-tests.el +++ b/test/lisp/net/shr-tests.el @@ -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) |