Skip to content

Commit

Permalink
Add: End-to-End Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Musa Al-hassy committed Dec 22, 2024
1 parent 9f674dd commit 8a52cb8
Show file tree
Hide file tree
Showing 22 changed files with 1,495 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
/ltximg/
**/.DS_Store

/tests/indent.log
/indent.log
13 changes: 11 additions & 2 deletions org-special-block-extras.el
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ Example declaration, with all possible features shown:
(org-defblock remark
(editor \"Editor Remark\" :face angry-red) (color \"red\" signoff \"\")
\"Top level (HTML & LaTeX)O-RESPECT-NEWLINES? editorial remarks; in Emacs they're angry red.\"
\"Top level (HTML & LaTeX) editorial remarks; in Emacs they're angry red.\"
(format (if (equal backend 'html)
\"<strong style=\\\"color: %s;\\\">⟦%s: %s%s⟧</strong>\"
\"{\\color{%s}\\bfseries %s: %s%s}\")
Expand Down Expand Up @@ -1791,7 +1791,7 @@ this command gives a searchable way to insert doc links."
'variable-documentation))
(-let [it (shell-command-to-string
(format "wn %s -over -synsn" label))]
(if (s-blank-p it)
(if (and (s-blank-p it) (not org-export-with-broken-links))
(error "Error: No documentation-glossary entry for “%s”!" label)
it)))))

Expand Down Expand Up @@ -2184,6 +2184,15 @@ what is required by MathJaX."
(s-join "\\\\")
(format "$$\\begin{align*} & %s \n\\end{align*}$$")))

(setq my/theorem-counter 0)

(org-defblock theorem (title)
"Show block contents prefixed with “Theorem 𝒏”, where the 𝒏umbering automatically increments."
(format "<div class=\"theorem\"><b>Theorem %s%s.</b>&nbsp;%s</div>"
(cl-incf my/theorem-counter)
(if title (format " [“%s”]" title) "")
(org-parse raw-contents)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(provide 'org-special-block-extras)
Expand Down
5 changes: 3 additions & 2 deletions org-special-block-extras.org
Original file line number Diff line number Diff line change
Expand Up @@ -1759,7 +1759,7 @@ Example declaration, with all possible features shown:

(org-defblock remark
(editor \"Editor Remark\" :face angry-red) (color \"red\" signoff \"\")
\"Top level (HTML & LaTeX)O-RESPECT-NEWLINES? editorial remarks; in Emacs they're angry red.\"
\"Top level (HTML & LaTeX) editorial remarks; in Emacs they're angry red.\"
(format (if (equal backend 'html)
\"<strong style=\\\"color: %s;\\\">⟦%s: %s%s⟧</strong>\"
\"{\\color{%s}\\bfseries %s: %s%s}\")
Expand Down Expand Up @@ -2427,6 +2427,7 @@ We will make use of this block below when we get to guided problems ;-)
:CUSTOM_ID: Longer_Example_Demonstrating_Org-markup_with_org-demo
:END:


Sometimes, we want to show verbatim source and its resulting rendition ---which
is a major part of this article! So, let's make a block to mitigate such an
error-prone tedium.
Expand Down Expand Up @@ -7034,7 +7035,7 @@ doc:org-docs-load-libraries
'variable-documentation))
(-let [it (shell-command-to-string
(format "wn %s -over -synsn" label))]
(if (s-blank-p it)
(if (and (s-blank-p it) (not org-export-with-broken-links))
(error "Error: No documentation-glossary entry for “%s”!" label)
it)))))

Expand Down
24 changes: 12 additions & 12 deletions tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ a given matching pattern. Such arrows are popular in Term Rewriting Systems."

(should (org-html-export-to-html)))

;; [[file:org-special-block-extras.org::*Define links as you define functions: doc:org-deflink][Define links as you define functions: doc:org-deflink:4]]
;; [[file:org-special-block-extras.org::#NEW-org-deflink][Define links as you define functions: doc:org-deflink:4]]
(org-deflink shout
"Capitalise the link description, if any, otherwise capitalise the label.
Expand Down Expand Up @@ -235,7 +235,7 @@ post")
(* anything)
"<p>\npost"))

;; [[file:org-special-block-extras.org::*Folded Details ---As well as boxed text and subtle colours][Folded Details ---As well as boxed text and subtle colours:4]]
;; [[file:org-special-block-extras.org::#Folded-Details][Folded Details ---As well as boxed text and subtle colours:3]]
(deftest "The result is a <details> tag containing the user's title & text."
[details]
(⇝ (⟰ "#+begin_details TITLE-RIGHT-HERE
Expand All @@ -248,7 +248,7 @@ post")
"My aside"
(* anything)
"</details>"))
;; Folded Details ---As well as boxed text and subtle colours:4 ends here
;; Folded Details ---As well as boxed text and subtle colours:3 ends here

(deftest "We have an HTML box enclosing the user's title (in <h3) and text"
[box]
Expand All @@ -262,7 +262,7 @@ post")
"This is the key insight"
(* anything)))

;; [[file:org-special-block-extras.org::*Parallel][Parallel:2]]
;; [[file:org-special-block-extras.org::#Parallel][Parallel:2]]
(deftest "Parallel blocks work as expected - Defaults"
[parallel block]
(⇝ (⟰ "#+begin_parallel
Expand Down Expand Up @@ -346,7 +346,7 @@ post")
"Z"))
;; Parallel:2 ends here

;; [[file:org-special-block-extras.org::*Editor Comments][Editor Comments:4]]
;; [[file:org-special-block-extras.org::#editor-comments][Editor Comments:4]]
(deftest "The user's remark is enclosed in the default delimiters"
[remark]
(⇝ (⟰ "#+begin_remark
Expand All @@ -360,7 +360,7 @@ post")
;; but this is not a pressing, nor interesting, concern.
;; Editor Comments:4 ends here

;; [[file:org-special-block-extras.org::*Colours][Colours:4]]
;; [[file:org-special-block-extras.org::#Colours][Colours:4]]
(deftest "It is an HTML span styled red that contains the user's text"
[color red block]
(⇝ (⟰ "#+begin_red
Expand All @@ -385,7 +385,7 @@ post")
"</span>"))
;; Colours:4 ends here

;; [[file:org-special-block-extras.org::*Nice Keystroke Renditions: kbd:C-h_h][Nice Keystroke Renditions: kbd:C-h_h:3]]
;; [[file:org-special-block-extras.org::#kbd:nice-keystroke-renditions][Nice Keystroke Renditions: kbd:C-h_h:3]]
(deftest "It becomes <kbd> tags, but final symbol non-ascii *may* be ignored"
[kbd direct-org-links]
(⇝ (⟰ "kbd:C-u_80_-∀") "<p>\n<kbd style=\"\">C-u 80</kbd>_-∀</p>"))
Expand Down Expand Up @@ -421,7 +421,7 @@ post")
"<kbd style=\"border-color: red\">M-s h .</kbd></abbr>")))
;; Nice Keystroke Renditions: kbd:C-h_h:3 ends here

;; [[file:org-special-block-extras.org::*  /“Link Here!”/ & OctoIcons][  /“Link Here!”/ & OctoIcons:3]]
;; [[file:org-special-block-extras.org::#Link-Here-OctoIcons][  /“Link Here!”/ & OctoIcons:3]]
(deftest "It works as expected: We have an anchor with the given ID, and the default SVG chain icon."
[link:here]
(⇝ (⟰ "link-here:example-location (Click the icon and see the URL has changed!)")
Expand All @@ -431,7 +431,7 @@ post")
(* anything)))
;;   /“Link Here!”/ & OctoIcons:3 ends here

;; [[file:org-special-block-extras.org::*Badge Links][Badge Links:2]]
;; [[file:org-special-block-extras.org::#Badge-Links][Badge Links:2]]
(deftest "It works when all 5 arguments are provided"
[badge]
(⇝ (⟰ "badge:Let_me_google_that|for_you!|orange|https://lmgtfy.app/?q=badge+shields.io&iie=1|Elixir")
Expand Down Expand Up @@ -491,7 +491,7 @@ post")
"<img src=\"https://img.shields.io/badge/--nil?logo=nil\">"))
;; Badge Links:2 ends here

;; [[file:org-special-block-extras.org::*Intro, motivating examples][Intro, motivating examples:4]]
;; [[file:org-special-block-extras.org::#COMMENT-Intro][Intro, motivating examples:4]]
(deftest "It gives a tooltip whose title is the Lisp docs of APPLY"
[doc]
(⇝ (⟰ "doc:apply")
Expand Down Expand Up @@ -530,7 +530,7 @@ post")
"\">Existential Angst</abbr>.</p> "))
;; Intro, motivating examples:4 ends here

;; [[file:org-special-block-extras.org::*Marginal, “one-off”, remarks][Marginal, “one-off”, remarks:2]]
;; [[file:org-special-block-extras.org::#Marginal-one-off-remarks][Marginal, “one-off”, remarks:2]]
(setq margin (⟰ "/Allah[[margin:][The God of Abraham; known as Elohim
in the Bible]] does not burden a soul beyond what it can bear./
--- Quran 2:286"))
Expand All @@ -553,7 +553,7 @@ post")
(⇝ margin "<abbr" (* anything) "°</abbr>"))
;; Marginal, “one-off”, remarks:2 ends here

;; [[file:org-special-block-extras.org::*Equational Proofs][Equational Proofs:4]]
;; [[file:org-special-block-extras.org::#Equational-Proofs][Equational Proofs:4]]
(setq calc (⟰ "#+begin_calc :hint-format \"\\\\left\\{ %s\\\\right.\"
+ x
+ y -- Explanation of why $x \\;=\\; y$
Expand Down
190 changes: 190 additions & 0 deletions tests/badge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
input: |-
1. It works when all 5 arguments are provided
badge:Let_me_google_that|for_you!|orange|https://lmgtfy.app/?q=badge+shields.io&iie=1|Elixir
2. It works when we use [ [ link ] ] syntax with generous spaces and newlines
[[badge: Let me google that | for you! | orange |
https://lmgtfy.app/?q=badge+shields.io&iie=1|Elixir]]
3. It works when only the first 2 arguments are provided;
asterisks are passed unaltered into the first argument
badge:Let_me_*not*_google_that|for_you
4. It works when all 5 arguments are provided - URL ‘here’ makes it a local link
badge:key|value|informational|here|Elixir
5. We can use spaces, commas, dashes, and percentage symbols in the first argument
badge:example_with_spaces,_-,_and_%|points_right_here|orange|here
6. It works when only first 2 arguments are given: Default colour & logo are green & no logo shown
badge:key|value
7. When only a key is provided, the value slot is shown as an empty green stub
badge:key
8. When only a value is provided, only the value is shown in a default green
---no stub for the missing key, yay
badge:|value
9. It's only a green stub when provided with an empty key and empty value
badge:||green
10. It's only a green stub when we use no options at all
[[badge:]]
expectations:
html: |-
<ol class="org-ol">
<li>
<p>It works when all 5 arguments are provided</p>
<p>
<a href="https://lmgtfy.app/?q=badge+shields.io&iie=1"
><img
src="https://img.shields.io/badge/Let_me_google_that-for_you%21-orange?logo=Elixir"
/></a>
</p>
</li>
<li>
<p>
It works when we use [ [ link ] ] syntax with generous spaces and newlines
</p>
<p>
<a href="https://lmgtfy.app/?q=badge+shields.io&iie=1"
><img
src="https://img.shields.io/badge/Let%20me%20google%20that-for%20you%21-orange?logo=Elixir"
/></a>
</p>
</li>
<li>
<p>
It works when only the first 2 arguments are provided; asterisks are
passed unaltered into the first argument
</p>
<p>
<img
src="https://img.shields.io/badge/Let_me_%2Anot%2A_google_that-for_you-nil?logo=nil"
/>
</p>
</li>
<li>
<p>
It works when all 5 arguments are provided - URL ‘here’ makes it a local
link
</p>
<p>
<a id="key" href="#key"
><img
src="https://img.shields.io/badge/key-value-informational?logo=Elixir"
/></a>
</p>
</li>
<li>
<p>
We can use spaces, commas, dashes, and percentage symbols in the first
argument
</p>
<p>
<a
id="example_with_spaces,_-,_and_%"
href="#example_with_spaces,_-,_and_%"
><img
src="https://img.shields.io/badge/example_with_spaces%2C_--%2C_and_%25-points_right_here-orange?logo=nil"
/></a>
</p>
</li>
<li>
<p>
It works when only first 2 arguments are given: Default colour &amp; logo
are green &amp; no logo shown
</p>
<p>
<img src="https://img.shields.io/badge/key-value-nil?logo=nil" />
</p>
</li>
<li>
<p>
When only a key is provided, the value slot is shown as an empty green
stub
</p>
<p>
<img src="https://img.shields.io/badge/key--nil?logo=nil" />
</p>
</li>
<li>
<p>
When only a value is provided, only the value is shown in a default green
&#x2014;no stub for the missing key, yay
</p>
<p>
<img src="https://img.shields.io/badge/-value-nil?logo=nil" />
</p>
</li>
<li>
<p>
It's only a green stub when provided with an empty key and empty value
</p>
<p>
<img src="https://img.shields.io/badge/--green?logo=nil" />
</p>
</li>
<li>
<p>It's only a green stub when we use no options at all</p>
<p>
<img src="https://img.shields.io/badge/--nil?logo=nil" />
</p>
</li>
</ol>
latex: |-
\begin{enumerate}
\item It works when all 5 arguments are provided
\item It works when we use [ [ link ] ] syntax with generous spaces and newlines
\item It works when only the first 2 arguments are provided;
asterisks are passed unaltered into the first argument
\item It works when all 5 arguments are provided - URL ‘here’ makes it a local link
\item We can use spaces, commas, dashes, and percentage symbols in the first argument
\item It works when only first 2 arguments are given: Default colour \& logo are green \& no logo shown
\item When only a key is provided, the value slot is shown as an empty green stub
\item When only a value is provided, only the value is shown in a default green
---no stub for the missing key, yay
\item It's only a green stub when provided with an empty key and empty value
\item It's only a green stub when we use no options at all
\end{enumerate}
28 changes: 28 additions & 0 deletions tests/box.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
input: |-
#+begin_box Pay Attention!
This is the key insight...
(We have an HTML box enclosing the user's title and text)
#+end_box
expectations:
html: |-
<div
style="
padding: 1em;
background-color: #ccffcc;
border-radius: 15px;
font-size: 0.9em;
"
>
<h3>Pay Attention!</h3>
<p>
This is the key insight&#x2026; (We have an HTML box enclosing the user's
title and text)
</p>
</div>
latex: |-
\begin{tcolorbox}[title={Pay Attention!},colback=red!5!white,colframe=red!75!black,colbacktitle=yellow!50!red,coltitle=red!25!black, fonttitle=\bfseries,subtitle style={boxrule=0.4pt, colback=yellow!50!red!25!white}]
This is the key insight\ldots{}
(We have an HTML box enclosing the user's title and text)
\end{tcolorbox}
Loading

0 comments on commit 8a52cb8

Please sign in to comment.