[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/toc-org 95a558b362 099/128: add tests for markdown-style s
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/toc-org 95a558b362 099/128: add tests for markdown-style syntax |
Date: |
Sun, 2 Jan 2022 09:59:13 -0500 (EST) |
branch: elpa/toc-org
commit 95a558b3624d50b28314eafbe1585a301a84f4cf
Author: Sergei Nosov <sergei.nosov@gmail.com>
Commit: Sergei Nosov <sergei.nosov@gmail.com>
add tests for markdown-style syntax
---
toc-org-test.el | 36 +++++++++++++++++++++++++++++-------
1 file changed, 29 insertions(+), 7 deletions(-)
diff --git a/toc-org-test.el b/toc-org-test.el
index edbf1b4d71..16a0601c49 100644
--- a/toc-org-test.el
+++ b/toc-org-test.el
@@ -141,13 +141,15 @@
(should (equal (toc-org-format-visible-link "Context Extraction Service
[60%]") "Context Extraction Service")))
(ert-deftest test-toc-org-hrefify-toc ()
- (let ((hash (make-hash-table :test 'equal)))
- (should (equal (toc-org-hrefify-toc "* About\n"
- (lambda (str &optional hash) (upcase
str))
- nil
- hash)
- "- [[ABOUT][About]]\n"))
- (should (equal (gethash "ABOUT" hash) "About")))
+ (dolist (params '((nil . "- [[ABOUT][About]]\n") ('t . "-
[About](ABOUT)\n")))
+ (let ((hash (make-hash-table :test 'equal)))
+ (should (equal (toc-org-hrefify-toc "* About\n"
+ (lambda (str &optional hash) (upcase
str))
+ (car params)
+ hash)
+ (cdr params)))
+ (should (equal (gethash "ABOUT" hash) "About"))))
+
;; check trailing space: https://github.com/snosov1/toc-org/pull/31
(let ((hash (make-hash-table :test 'equal)))
(should (equal (toc-org-hrefify-toc "* About \n"
@@ -239,3 +241,23 @@
"* H1\n* TODO H2\n* TOC :TOC:\n \n"
"* H1\n* TODO H2\n* TOC :TOC:\n- [[#h1][H1]]\n- [[#h2][H2]]\n")
))
+
+(ert-deftest test-toc-org-insert-toc-markdown ()
+ "Test the `toc-org-insert-toc' function"
+
+ (defun test-toc-org-insert-toc-gold-test-markdown (content gold)
+ (with-temp-buffer
+ (markdown-mode)
+ (insert content)
+ (toc-org-insert-toc)
+ (should (equal
+ (buffer-substring-no-properties
+ (point-min) (point-max))
+ gold))))
+ (declare-function test-toc-org-insert-toc-gold-test-markdown "toc-org") ;;
suppress compiler warning
+
+ (let ((beg "# About\n:TOC:\n drawer\n:END:\n\ntoc-org is a utility to have
an up-to-date table of contents in the\norg files without exporting (useful
primarily for readme files on\nGitHub).\n\nIt is similar to the
[[https://github.com/ardumont/markdown-toc][markdown-toc]] package, but works
for org files.\n:TOC:\n drawer\n:END:\n# Hello\n## Good-bye\n### Salut\n#
Table of Contents "))
+ (test-toc-org-insert-toc-gold-test-markdown
+ (concat beg "<-- :TOC: -->")
+ "# About\n:TOC:\n drawer\n:END:\n\ntoc-org is a utility to have an
up-to-date table of contents in the\norg files without exporting (useful
primarily for readme files on\nGitHub).\n\nIt is similar to the
[[https://github.com/ardumont/markdown-toc][markdown-toc]] package, but works
for org files.\n:TOC:\n drawer\n:END:\n# Hello\n## Good-bye\n### Salut\n#
Table of Contents <-- :TOC:
-->\n- [About](#about)\n- [Hello](#hello)\n - [Go [...]
+ ))
- [nongnu] elpa/toc-org 90894242a6 046/128: treat org-list-indent-offset properly, (continued)
- [nongnu] elpa/toc-org 90894242a6 046/128: treat org-list-indent-offset properly, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 4c0b28da59 037/128: add more tags for easier search, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org e38e81af3f 088/128: Merge pull request #57 from JAremko/master, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org cda8f73640 073/128: Merge pull request #37 from snosov1/handle-comment, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org ee70dd23e1 104/128: resolve missing functions warnings, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org d52f95fae8 105/128: Handle trailing #'s, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 5ce7c24920 096/128: handle paranthesis in #+TODO line (fixes #65), ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org b1bab4c078 072/128: handle nil that is sometimes returned by (current-word), ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 9efeec690c 111/128: Remove the "backup" variable, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org ff8d49c2c7 113/128: Merge pull request #69 from htsr/comment-stripping, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 95a558b362 099/128: add tests for markdown-style syntax,
ELPA Syncer <=
- [nongnu] elpa/toc-org e33e4cc00a 084/128: Merge pull request #50 from snosov1/handle-custom-keywords, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 7291a3b08d 100/128: Enable link following in markdown mode, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org f455bd4c88 103/128: Call batch compile before running the tests, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 8321d3c76b 120/128: Revert "Respect the file-local value of org-list-indent-offset.", ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 6eca67f9a8 127/128: Merge pull request #83 from skangas/silence-byte-compiler, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 328d34144f 124/128: Bump version to 1.1, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org ebff38bfa4 094/128: make toc-org a minor mode (#61), ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org aa9aea6d69 102/128: Supress warnings, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 215d3e41e3 114/128: fix C-c C-o for links with cookies, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org a2cb4c254f 128/128: Merge pull request #84 from skangas/nongnu-elpa, ELPA Syncer, 2022/01/02