emacs-elpa-diffs
[Top][All Lists]
Advanced

[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."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]