[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/toc-org 17c6cf1d1a 060/128: add tests
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/toc-org 17c6cf1d1a 060/128: add tests |
Date: |
Sun, 2 Jan 2022 09:59:09 -0500 (EST) |
branch: elpa/toc-org
commit 17c6cf1d1a28036177d5ffd38eaaa449b50ae0f6
Author: Sergei Nosov <sergei.nosov@gmail.com>
Commit: Sergei Nosov <sergei.nosov@gmail.com>
add tests
---
toc-org.el | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/toc-org.el b/toc-org.el
index ec7c4e50b6..8a049ad068 100644
--- a/toc-org.el
+++ b/toc-org.el
@@ -66,7 +66,7 @@ files on GitHub)"
(defconst toc-org-special-chars-regexp "[^[:alnum:]_-]"
"Regexp with the special characters (which are omitted in hrefs
by GitHub)")
-(defconst toc-org-statistics-cookies-regexp
"\s*\\[[0-9]*\\(%\\|/[0-9]*\\)\\]\s*$"
+(defconst toc-org-statistics-cookies-regexp
"\s*\\[[0-9]*\\(%\\|/[0-9]*\\)\\]\s*"
"Regexp to find statistics cookies on the line")
(defconst toc-org-leave-todo-regexp "^#\\+OPTIONS:.*\stodo:t[\s\n]"
"Regexp to find the todo export setting")
@@ -173,10 +173,18 @@ auxiliary text."
(test-toc-org-raw-toc-gold-test (concat beg ":TOC@1_hello:" "\n\n\n") gold)
(test-toc-org-raw-toc-gold-test (concat beg ":TOC@1_hello:" "\n\n\nsdfd")
gold))
- ;; more complex case
+ ;; more complex cases
(test-toc-org-raw-toc-gold-test
"* 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\n* Table of Contents
:TOC:\n - [[#about][About]]\n -
[[#use][Use]]\n - [[#different-href-styles][Different href st [...]
- "* About\n* Installation\n** via package.el\n** Manual\n* Use\n* Different
href styles\n* Example\n"))
+ "* About\n* Installation\n** via package.el\n** Manual\n* Use\n* Different
href styles\n* Example\n")
+
+ (test-toc-org-raw-toc-gold-test
+ "* About\n:TOC:\n drawer\n:END:\n\n* Table of Contents
:TOC:\n - [[#about][About]]\n - [[#use][Use]]\n
- [[#different-href-styles][Different href styles]]\n -
[[#example][Example]]\n\n#+OPTIONS: todo:t\n\n* Installation\n** DONE via
package.el\nThis is the simplest method if you have the package.el
module\n(built-in since Emacs 24.1) you can simply use =M-x
package-install=\nand then put the following snippet in your ~/.emacs file\n#
[...]
+ "* About\n* Installation\n** DONE via package.el\n** TODO Manual\n")
+
+ (test-toc-org-raw-toc-gold-test
+ "* About\n:TOC:\n drawer\n:END:\n\n* Table of Contents
:TOC:\n - [[#about][About]]\n - [[#use][Use]]\n
- [[#different-href-styles][Different href styles]]\n -
[[#example][Example]]\n\n#+OPTIONS: num: nil todo:t |:t\n\n* Installation\n**
DONE via package.el\nThis is the simplest method if you have the package.el
module\n(built-in since Emacs 24.1) you can simply use =M-x
package-install=\nand then put the following snippet in your ~/. [...]
+ "* About\n* Installation\n** DONE via package.el\n** TODO Manual\n"))
(defun toc-org-hrefify-gh (str &optional hash)
"Given a heading, transform it into a href using the GitHub
@@ -199,6 +207,10 @@ rules."
(should (equal (toc-org-hrefify-gh "About") "#about"))
(should (equal (toc-org-hrefify-gh "!h@#$%^&*(){}|][:;\"'/?.>,<`~") "#h"))
(should (equal (toc-org-hrefify-gh "!h@#$% ^&*(S){}|][:;\"'/?.>,<`~")
"#h-s"))
+ (should (equal (toc-org-hrefify-gh "[60%] Context Extraction Service [60%]
[3/5]") "#60-context-extraction-service-60-35"))
+ (should (equal (toc-org-hrefify-gh "Context Extraction Service [60%] [3/5]")
"#context-extraction-service-60-35"))
+ (should (equal (toc-org-hrefify-gh "Context Extraction Service [3/5]")
"#context-extraction-service-35"))
+ (should (equal (toc-org-hrefify-gh "Context Extraction Service [60%]")
"#context-extraction-service-60"))
(let ((hash (make-hash-table :test 'equal)))
(should (equal (toc-org-hrefify-gh "About" hash) "#about"))
@@ -221,6 +233,14 @@ rules."
(buffer-substring-no-properties
(point-min) (point-max))))
+(ert-deftest test-toc-org-format-visible-link ()
+ "Test the `toc-org-format-visible-link' function"
+ (should (equal (toc-org-format-visible-link "About") "About"))
+ (should (equal (toc-org-format-visible-link "[60%] Context Extraction
Service [60%] [3/5]") "Context Extraction Service"))
+ (should (equal (toc-org-format-visible-link "Context Extraction Service
[60%] [3/5]") "Context Extraction Service"))
+ (should (equal (toc-org-format-visible-link "Context Extraction Service
[3/5]") "Context Extraction Service"))
+ (should (equal (toc-org-format-visible-link "Context Extraction Service
[60%]") "Context Extraction Service")))
+
(defun toc-org-hrefify-org (str &optional hash)
"Given a heading, transform it into a href using the org-mode
rules."
- [nongnu] elpa/toc-org a0e8ca05e8 066/128: Merge pull request #33 from iqbalansari/master, (continued)
- [nongnu] elpa/toc-org a0e8ca05e8 066/128: Merge pull request #33 from iqbalansari/master, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 39fbbda8df 081/128: handle custom keywords specified in the files, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 8dbb3df422 125/128: Fix byte-compiler warning in Emacs 28, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org a3d953a5fa 076/128: Update and clarify primary docstring to explain :noexport:, etc., ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 5a2d7e58dd 028/128: add org-toc-2 alias, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org da99c5d801 023/128: require ert, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 63a0144afa 031/128: fix documentation, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org cfb309e8ab 035/128: fix typo, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 1a213baa8a 048/128: don't alter the type and path if we don't recognize it as a TOC entry, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org d23140d604 056/128: Merge pull request #21 from snosov1/fix-properties-handling, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 17c6cf1d1a 060/128: add tests,
ELPA Syncer <=
- [nongnu] elpa/toc-org 01cb78ead6 063/128: Use `delete-region` instead of kill-line while creating the TOC, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org d3d3503b34 062/128: Delete trailing whitespaces from links, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 4d076d1e9d 118/128: Respect the file-local value of org-list-indent-offset., ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org f3218fdaf1 123/128: Add license and copyright header to toc-org-test.el, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 501f36db68 021/128: Merge pull request #5 from ardumont/wrap-tests-definition, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 658c03111b 017/128: add some more tests and fix wording, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org d3677cd8c8 022/128: make compile-command run the tests, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 0dee7197c8 026/128: fix byte-compilation check, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 242eecba19 034/128: add a note about previous name, ELPA Syncer, 2022/01/02
- [nongnu] elpa/toc-org 90894242a6 046/128: treat org-list-indent-offset properly, ELPA Syncer, 2022/01/02