branch: elpa/markdown-mode
commit 799a8e91d878d81643627edbb4a30daa9130124e
Author: Shohei YOSHIDA <[email protected]>
Commit: Shohei YOSHIDA <[email protected]>
Fix tests
---
.gitignore | 1 +
tests/markdown-test.el | 45 +++++++++++++++++++---------------
tests/wiki/pr666/Foo.md | 0
tests/wiki/pr666/jump_wiki_link.md | 1 +
tests/wiki/pr666/wiki_link_in_table.md | 1 +
5 files changed, 28 insertions(+), 20 deletions(-)
diff --git a/.gitignore b/.gitignore
index d24783d..3db2449 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
*.elc
index.text
+*~
diff --git a/tests/markdown-test.el b/tests/markdown-test.el
index f0a08fd..4c7d92a 100644
--- a/tests/markdown-test.el
+++ b/tests/markdown-test.el
@@ -1558,32 +1558,37 @@ the opening bracket of [^2], and then subsequent
functions would kill [^2])."
(markdown-footnote-kill)
(should (string-equal (current-kill 0) "foo\n")))))
-(ert-deftest test-markdown-do/jump-wikilink ()
+(ert-deftest test-markdown-do/jump-wiki-link ()
"Test `markdown-do' jumps to wiki links"
- (markdown-test-string
- "[[Foo]]"
- (goto-char 3) ; Foo
- (markdown-do) ; open Foo.md
- (should (string= (buffer-string) ""))))
+ (with-current-buffer (find-file-noselect "wiki/pr666/jump_wiki_link.md")
+ (let ((markdown-enable-wiki-links t))
+ (goto-char 3)
+ (markdown-do)
+ (should (string= (buffer-name) "Foo.md")))))
(ert-deftest test-markdown-do/jump-link ()
"Test `markdown-do' jumps to markdown links"
- (markdown-test-string
- "[bar](https://duckduckgo.com)"
- (goto-char 3) ; Foo
- (markdown-do) ; open browser
- (should (string= (buffer-string) ""))))
+ (markdown-test-string "[bar](https://duckduckgo.com)"
+ (let* ((opened-url nil)
+ (browse-url-browser-function
+ (lambda (url &rest _args) (setq opened-url url))))
+ (goto-char 3)
+ (markdown-do)
+ (should (string= opened-url "https://duckduckgo.com")))))
-(ert-deftest test-markdown-do/wikilink-in-table ()
+(ert-deftest test-markdown-do/wiki-link-in-table ()
"Test `markdown-do' jumps to markdown links"
- (markdown-test-string
- "| [[Foo]] |"
- (goto-char 1) ; Table cell
- (markdown-do) ; align
- (should (string= (buffer-string) "| [[Foo]] |"))
- (goto-char 4) ; Foo
- (markdown-do) ; open Foo.md
- (should (string= (buffer-string) "| [[Foo]] |"))))
+ (with-current-buffer (find-file-noselect "wiki/pr666/wiki_link_in_table.md")
+ (let ((markdown-enable-wiki-links t))
+ ;; alignment
+ (markdown-do)
+ (should (string= (buffer-string) "| [[Foo]] |\n"))
+
+ (forward-char 4)
+
+ ;; wiki link
+ (markdown-do)
+ (should (string= (buffer-name) "Foo.md")))))
(ert-deftest test-markdown-footnote-reference/jump ()
"Test `markdown-do' for footnotes and reference links."
diff --git a/tests/wiki/pr666/Foo.md b/tests/wiki/pr666/Foo.md
new file mode 100644
index 0000000..e69de29
diff --git a/tests/wiki/pr666/jump_wiki_link.md
b/tests/wiki/pr666/jump_wiki_link.md
new file mode 100644
index 0000000..ea8532e
--- /dev/null
+++ b/tests/wiki/pr666/jump_wiki_link.md
@@ -0,0 +1 @@
+[[Foo]]
diff --git a/tests/wiki/pr666/wiki_link_in_table.md
b/tests/wiki/pr666/wiki_link_in_table.md
new file mode 100644
index 0000000..df6742f
--- /dev/null
+++ b/tests/wiki/pr666/wiki_link_in_table.md
@@ -0,0 +1 @@
+| [[Foo]] |