aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorStig Brautaset <stig@brautaset.org>2016-10-26 08:23:48 +0100
committerGitHub <noreply@github.com>2016-10-26 08:23:48 +0100
commit05d9f80f6f4142cd95636b026dee692f9eb1423b (patch)
tree2bc12df2dc53d85eb6f80371d1513314fe6beba1 /test
parentc4b8fd30c3bc48621759c9d128644d2d386e591e (diff)
parent17aab9b4679000e28b4a6ca9e5ab0138ae174f19 (diff)
Merge pull request #25 from stig/de-orgify
Remove the org tangle step to make it easier to contribute
Diffstat (limited to 'test')
-rw-r--r--test/ox-jira-test.el315
-rw-r--r--test/ox-jira-test.org453
2 files changed, 315 insertions, 453 deletions
diff --git a/test/ox-jira-test.el b/test/ox-jira-test.el
new file mode 100644
index 0000000..efd72f2
--- /dev/null
+++ b/test/ox-jira-test.el
@@ -0,0 +1,315 @@
+;;; ox-jira-test.el --- tests for ox-jira.el
+
+;; Copyright (C) 2016 Stig Brautaset
+
+;; Author: Stig Brautaset <stig@brautaset.org>
+
+;; This file is NOT part of GNU Emacs.
+
+;; This program is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(require 'ert)
+(require 'ox)
+(require 'ox-jira)
+
+;; This is my first foray into testing in Emacs. Please be kind.
+
+;; Let's write the simplest possible test that actually invokes anything org
+;; export related.
+;;
+(ert-deftest ox-jira-test/hello-world ()
+ (should (equal "hello world\n" (org-export-string-as "hello world" 'jira))))
+
+;; Let's do some standalone tests of very simple markup for inline text
+;; effects.
+;;
+(ert-deftest ox-jira-test/text-effects ()
+ (should (equal "this is *strong* text\n" (org-export-string-as "this is *strong* text" 'jira)))
+ (should (equal "this is _emphasised_ text\n" (org-export-string-as "this is /emphasised/ text" 'jira)))
+ (should (equal "this is +underlined+ text\n" (org-export-string-as "this is _underlined_ text" 'jira)))
+ (should (equal "this is -deleted- text\n" (org-export-string-as "this is +deleted+ text" 'jira)))
+ (should (equal "this is {{inline code}}\n" (org-export-string-as "this is ~inline code~" 'jira)))
+ (should (equal "this is {{verbatim}} text\n" (org-export-string-as "this is =verbatim= text" 'jira))))
+
+;; Test that super^script and sub_script have empty anchor immediately
+;; preceeding, so they can be tacked at the end of words without whitespace
+;; immediately before it.
+;;
+(ert-deftest ox-jira-test/embeddable-text-effects ()
+ (should (equal "this is super{anchor}^scripted^ text\n" (org-export-string-as "this is super^scripted text" 'jira)))
+ (should (equal "this is sub{anchor}~scripted~ text\n" (org-export-string-as "this is sub_scripted text" 'jira))))
+
+;; Quotations are a bit more elaborate, so let's test those separately. They
+;; can have other text effects inside them too.
+;;
+(ert-deftest ox-jira-test/quotations ()
+ (should (equal "{quote}
+This is a quote.
+
+It can have multiple paragraphs.
+{quote}
+" (org-export-string-as "
+#+BEGIN_QUOTE
+This is a quote.
+
+It can have multiple paragraphs.
+#+END_QUOTE" 'jira)))
+
+ (should (equal "{quote}
+This is a quote with _emphasis_.
+{quote}
+" (org-export-string-as "
+#+begin_quote
+This is a quote with /emphasis/.
+#+end_quote" 'jira))))
+
+;; Headline numbering in org is *relative*, so we cannot test that they work
+;; one-by-one.
+;;
+(ert-deftest ox-jira-test/headlines ()
+ (should (equal "h1. top level
+h2. second level
+h3. third level
+" (org-export-string-as "* top level
+** second level
+*** third level" 'jira))))
+
+;; As far as I understand these are not useful in JIRA output, so let's just
+;; filter them out.
+;;
+(ert-deftest ox-jira-test/keywords()
+ (should (equal "" (org-export-string-as "#+TITLE: MyTitle
+#+DATE: 2016-02-26
+#+OPTIONS: f:t" 'jira))))
+
+(ert-deftest ox-jira-test/links ()
+ (should (equal "fi [http://jira.atlassian.com] fo\n"
+ (org-export-string-as "fi [[http://jira.atlassian.com]] fo" 'jira)))
+ (should (equal "fi [Jira|http://jira.atlassian.com] fo\n"
+ (org-export-string-as "fi [[http://jira.atlassian.com][Jira]] fo" 'jira))))
+
+;; Check that text in paragraphs does not have hard newlines.
+;;
+(ert-deftest ox-jira-test/paragraphs ()
+ (should (equal "fi fo fa fum\n" (org-export-string-as "fi
+fo
+fa
+fum" 'jira))))
+
+(ert-deftest ox-jira-test/unordered-lists()
+ (should (equal "* fi
+* fo
+* fa
+* fum
+" (org-export-string-as "- fi
+- fo
+- fa
+- fum" 'jira))))
+
+(ert-deftest ox-jira-test/ordered-lists()
+ (should (equal "# fi
+# fo
+# fa
+# fum
+" (org-export-string-as "1. fi
+2. fo
+3. fa
+3. fum" 'jira))))
+
+(ert-deftest ox-jira-test/nested-lists()
+ (should (equal "* fi
+** fo
+*** fa
+**** fum
+" (org-export-string-as "- fi
+ - fo
+ - fa
+ - fum" 'jira)))
+ (should (equal "* fi
+*# fo
+*#* fa
+*#*# fum
+" (org-export-string-as "- fi
+ 1. fo
+ - fa
+ 1. fum" 'jira))))
+
+(ert-deftest ox-jira-test/unordered-list-with-checkboxes()
+ (should (equal "* (x) fi
+* (/) fo
+" (org-export-string-as "- [ ] fi
+- [X] fo" 'jira))))
+
+(ert-deftest ox-jira-test/checkboxes-and-statistics()
+ (should (equal "* (i) Progress \\[50%]
+** (x) fi
+** (/) fo
+" (org-export-string-as "- [-] Progress [50%]
+ - [ ] fi
+ - [X] fo" 'jira))))
+
+(ert-deftest ox-jira-test/definition-lists()
+ (should (equal "* *fi*: fo
+* *fa*: fum
+" (org-export-string-as "- fi :: fo
+- fa :: fum" 'jira))))
+
+;; This is not really supported by JIRA, so we have to fake it.
+;;
+(ert-deftest ox-jira-test/multi-para-list-items()
+ (should (equal "# fi
+fo
+# fa
+" (org-export-string-as "1. fi
+
+ fo
+2. fa" 'jira)))
+
+ (should (equal "# fi
+#* fifi
+#* fofo
+# fa
+# fum
+" (org-export-string-as "1. fi
+
+ * fifi
+
+ * fofo
+
+2. fa
+
+3. fum" 'jira)))
+
+ (should (equal "# fi
+#* {code:sql}SELECT 1;
+{code}
+{code:sql}SELECT 2;
+{code}
+#* fofo
+# fa
+" (org-export-string-as "1. fi
+
+ *
+ #+begin_src sql
+ SELECT 1;
+ #+end_src
+
+ #+begin_src sql
+ SELECT 2;
+ #+end_src
+
+ * fofo
+
+2. fa
+" 'jira)))
+ )
+
+(ert-deftest ox-jira-test/plain-text ()
+ (should (equal "fi fo \\[fa] fum
+" (org-export-string-as "fi fo [fa] fum" 'jira))))
+
+(ert-deftest ox-jira-test/src-blocks ()
+ (should (equal "{code}echo hello
+# echo world
+{code}
+" (org-export-string-as "#+begin_src sh
+ echo hello
+ # echo world
+ #+end_src
+" 'jira)))
+ (should (equal "{code:sql}BEGIN;
+SELECT NOW();
+END;
+{code}
+" (org-export-string-as "#+begin_src sql
+ BEGIN;
+ SELECT NOW();
+ END;
+ #+end_src
+" 'jira))))
+
+;; The Holy Grail. Do me proud, Org mode!
+;;
+(ert-deftest ox-jira-test/tables ()
+ (should (equal "| a | b |
+| c | d |
+" (org-export-string-as "
+| a | b |
+| c | d |
+" 'jira)))
+
+ ;; This should really be
+ ;; : || a || b ||
+ ;; : | c | d |
+ ;;
+ ;; but I haven't figured out how to identify the header row yet. This test
+ ;; checks that we at least ignore the horizontal lines.
+ (should (equal "|| a || b ||
+| c | d |
+" (org-export-string-as "
+| a | b |
+|---+---|
+| c | d |
+" 'jira))))
+
+(ert-deftest ox-jira-test/example-blocks ()
+ (should (equal "{noformat}
+stuff that should
+ not be
+formatted
+{noformat}
+" (org-export-string-as "#+begin_example
+stuff that should
+ not be
+formatted
+#+end_example
+" 'jira))))
+
+(ert-deftest ox-jira-test/fixed-width-blocks ()
+ (should (equal "{noformat}
+stuff that should
+ not be
+formatted
+{noformat}
+" (org-export-string-as ": stuff that should
+: not be
+: formatted
+" 'jira))))
+
+(ert-deftest ox-jira-test/horizontal-rule ()
+ (should
+ (equal "----\n" (org-export-string-as "-----\n" 'jira)))
+ (should
+ (equal "----\n" (org-export-string-as "-------\n" 'jira))))
+
+(ert-deftest ox-jira-test/footnotes ()
+ (should (equal "fi fo{anchor:backfn1}[^1^|#fn1]. Another one{anchor:backfn2}[^2^|#fn2].
+
+h1. Footnotes
+{anchor:fn1}[^1^|#backfn1] fa fum.
+{anchor:fn2}[^2^|#backfn2] fut fut.
+" (org-export-string-as "fi fo[fn:1]. Another one[fn:2].
+
+* Footnotes
+
+[fn:1] fa fum.
+
+[fn:2] fut fut.
+" 'jira))))
+
+(provide 'ox-jira-test)
+
+;;; ox-jira.el-test.el ends here
diff --git a/test/ox-jira-test.org b/test/ox-jira-test.org
deleted file mode 100644
index aefb23a..0000000
--- a/test/ox-jira-test.org
+++ /dev/null
@@ -1,453 +0,0 @@
-#+TITLE: Tests for JIRA Backend Org Export Engine
-#+AUTHOR: Stig Brautaset
-#+PROPERTY: header-args:emacs-lisp :tangle yes :results silent
-* Introduction
-
- This is my first foray into testing in Emacs. Please be patient.
-
-* Conventional headers
-
- #+BEGIN_SRC emacs-lisp :padline no
- ;;; ox-jira-test.el --- tests for ox-jira.el
-
- ;; Copyright (C) 2016 Stig Brautaset
-
- ;; Author: Stig Brautaset <stig@brautaset.org>
-
- ;; This file is NOT part of GNU Emacs.
- #+END_SRC
-
- I prefer the MIT license because it is short enough to read without toilet
- or tea breaks, and I _think_ I can actually wrap my head around it. (And I
- feel it's important to understand the license of your choice.) However,
- given I've cribbed copiously from `ox-latex.el' I should probably stick
- with the GPL for this work.
-
- #+BEGIN_SRC emacs-lisp
- ;; This program is free software: you can redistribute it and/or modify
- ;; it under the terms of the GNU General Public License as published by
- ;; the Free Software Foundation, either version 3 of the License, or
- ;; (at your option) any later version.
-
- ;; This program is distributed in the hope that it will be useful,
- ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
- ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ;; GNU General Public License for more details.
-
- ;; You should have received a copy of the GNU General Public License
- ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
- #+END_SRC
-
- Lastly a special marker to denote that we're done with the header section
- and starting the actual code now.
-
- #+BEGIN_SRC emacs-lisp
- ;;; Code:
- #+END_SRC
-
-* Code
-
-** Require libraries
-
- The first thing our code needs to do is require the libraries we need. This
- is cargo-culted from [[https://github.com/NicolasPetton/seq.el/blob/master/test/seq.el-test.el][seq.el-test.el]].
-
- #+BEGIN_SRC emacs-lisp
- (require 'ert)
- (require 'ox)
- (require 'ox-jira)
- #+END_SRC
-
-** Hello World
-
- Let's write the simplest possible test that actually invokes anything org
- export related.
-
- #+BEGIN_SRC emacs-lisp
- (ert-deftest ox-jira-test/hello-world ()
- (should (equal "hello world\n" (org-export-string-as "hello world" 'jira))))
- #+END_SRC
-
-** Simple text effects
-
- Let's do some standalone tests of very simple markup for inline text effects.
-
- #+BEGIN_SRC emacs-lisp
- (ert-deftest ox-jira-test/text-effects ()
- (should (equal "this is *strong* text\n" (org-export-string-as "this is *strong* text" 'jira)))
- (should (equal "this is _emphasised_ text\n" (org-export-string-as "this is /emphasised/ text" 'jira)))
- (should (equal "this is +underlined+ text\n" (org-export-string-as "this is _underlined_ text" 'jira)))
- (should (equal "this is -deleted- text\n" (org-export-string-as "this is +deleted+ text" 'jira)))
- (should (equal "this is {{inline code}}\n" (org-export-string-as "this is ~inline code~" 'jira)))
- (should (equal "this is {{verbatim}} text\n" (org-export-string-as "this is =verbatim= text" 'jira))))
- #+END_SRC
-
- Test that super^script and sub_script have empty anchor immediately
- preceeding, so they can be tacked at the end of words without whitespace
- immediately before it.
-
- #+BEGIN_SRC emacs-lisp
- (ert-deftest ox-jira-test/embeddable-text-effects ()
- (should (equal "this is super{anchor}^scripted^ text\n" (org-export-string-as "this is super^scripted text" 'jira)))
- (should (equal "this is sub{anchor}~scripted~ text\n" (org-export-string-as "this is sub_scripted text" 'jira))))
- #+END_SRC
-
- Quotations are a bit more elaborate, so let's test those separately. They
- can have other text effects inside them too.
-
- #+BEGIN_SRC emacs-lisp
- (ert-deftest ox-jira-test/quotations ()
- (should (equal "{quote}
- This is a quote.
-
- It can have multiple paragraphs.
- {quote}
- " (org-export-string-as "
- ,#+BEGIN_QUOTE
- This is a quote.
-
- It can have multiple paragraphs.
- ,#+END_QUOTE" 'jira)))
-
- (should (equal "{quote}
- This is a quote with _emphasis_.
- {quote}
- " (org-export-string-as "
- ,#+begin_quote
- This is a quote with /emphasis/.
- ,#+end_quote" 'jira))))
- #+END_SRC
-
-** Headlines
-
- Headline numbering in org is _relative_, so we cannot test that they work one-by-one.
-
- #+BEGIN_SRC emacs-lisp
- (ert-deftest ox-jira-test/headlines ()
- (should (equal "h1. top level
- h2. second level
- h3. third level
- " (org-export-string-as "* top level
- ,** second level
- ,*** third level" 'jira))))
- #+END_SRC
-
-** Keywords
-
- As far as I understand these are not useful in JIRA output, so let's just
- filter them out.
-
- #+BEGIN_SRC emacs-lisp
- (ert-deftest ox-jira-test/keywords()
- (should (equal "" (org-export-string-as "#+TITLE: MyTitle
- ,#+DATE: 2016-02-26
- ,#+OPTIONS: f:t" 'jira))))
- #+END_SRC
-** Links
-
- JIRA supports many types of links. I don't expect we support them all.
-
- #+BEGIN_SRC emacs-lisp
- (ert-deftest ox-jira-test/links ()
- (should (equal "fi [http://jira.atlassian.com] fo\n"
- (org-export-string-as "fi [[http://jira.atlassian.com]] fo" 'jira)))
- (should (equal "fi [Jira|http://jira.atlassian.com] fo\n"
- (org-export-string-as "fi [[http://jira.atlassian.com][Jira]] fo" 'jira))))
- #+END_SRC
-
-** Paragraphs
-
- Check that text in paragraphs does not have hard newlines.
-
- #+BEGIN_SRC emacs-lisp
- (ert-deftest ox-jira-test/paragraphs ()
- (should (equal "fi fo fa fum\n" (org-export-string-as "fi
- fo
- fa
- fum" 'jira))))
- #+END_SRC
-
-** Plain lists
-
- I like to use lists, so check that we handle them!
-
- #+BEGIN_SRC emacs-lisp
- (ert-deftest ox-jira-test/unordered-lists()
- (should (equal "* fi
- ,* fo
- ,* fa
- ,* fum
- " (org-export-string-as "- fi
- - fo
- - fa
- - fum" 'jira))))
-
- (ert-deftest ox-jira-test/ordered-lists()
- (should (equal "# fi
- # fo
- # fa
- # fum
- " (org-export-string-as "1. fi
- 2. fo
- 3. fa
- 3. fum" 'jira))))
- #+END_SRC
-
- Ok, we handle flat lists. How about nested ones?
-
- #+BEGIN_SRC emacs-lisp
- (ert-deftest ox-jira-test/nested-lists()
- (should (equal "* fi
- ,** fo
- ,*** fa
- ,**** fum
- " (org-export-string-as "- fi
- - fo
- - fa
- - fum" 'jira)))
- (should (equal "* fi
- ,*# fo
- ,*#* fa
- ,*#*# fum
- " (org-export-string-as "- fi
- 1. fo
- - fa
- 1. fum" 'jira))))
- #+END_SRC
-
- Right! That was simple enough. Let's add some checkboxes.
-
- #+BEGIN_SRC emacs-lisp
- (ert-deftest ox-jira-test/unordered-list-with-checkboxes()
- (should (equal "* (x) fi
- ,* (/) fo
- " (org-export-string-as "- [ ] fi
- - [X] fo" 'jira))))
- #+END_SRC
-
- Ok, now add statistics cookies...
-
- #+BEGIN_SRC emacs-lisp
- (ert-deftest ox-jira-test/checkboxes-and-statistics()
- (should (equal "* (i) Progress \\[50%]
- ,** (x) fi
- ,** (/) fo
- " (org-export-string-as "- [-] Progress [50%]
- - [ ] fi
- - [X] fo" 'jira))))
- #+END_SRC
-
- Definition lists are not directly supported by JIRA markup, but let's fake
- it with a bullet list & some bold text.
-
- #+BEGIN_SRC emacs-lisp
- (ert-deftest ox-jira-test/definition-lists()
- (should (equal "* *fi*: fo
- ,* *fa*: fum
- " (org-export-string-as "- fi :: fo
- - fa :: fum" 'jira))))
- #+END_SRC
-
-** Multi-paragraph list items
-
- This is not really supported by JIRA, so we have to fake it.
-
- #+BEGIN_SRC emacs-lisp
- (ert-deftest ox-jira-test/multi-para-list-items()
- (should (equal "# fi
- fo
- # fa
- " (org-export-string-as "1. fi
-
- fo
- 2. fa" 'jira)))
-
- (should (equal "# fi
- #* fifi
- #* fofo
- # fa
- # fum
- " (org-export-string-as "1. fi
-
- ,* fifi
-
- ,* fofo
-
- 2. fa
-
- 3. fum" 'jira)))
-
- (should (equal "# fi
- #* {code:sql}SELECT 1;
- {code}
- {code:sql}SELECT 2;
- {code}
- #* fofo
- # fa
- " (org-export-string-as "1. fi
-
- ,*
- ,#+begin_src sql
- SELECT 1;
- ,#+end_src
-
- ,#+begin_src sql
- SELECT 2;
- ,#+end_src
-
- ,* fofo
-
- 2. fa
- " 'jira)))
- )
- #+END_SRC
-
-** Plain text
-
- Check that certain characters are escaped.
-
- #+BEGIN_SRC emacs-lisp
- (ert-deftest ox-jira-test/plain-text ()
- (should (equal "fi fo \\[fa] fum
- " (org-export-string-as "fi fo [fa] fum" 'jira))))
- #+END_SRC
-
-** Source code
-
- I use Org mode for literate programming, and executable lab notes, so we
- need to export source code.
-
- #+BEGIN_SRC emacs-lisp
- (ert-deftest ox-jira-test/src-blocks ()
- (should (equal "{code}echo hello
- # echo world
- {code}
- " (org-export-string-as "#+begin_src sh
- echo hello
- # echo world
- ,#+end_src
- " 'jira)))
- (should (equal "{code:sql}BEGIN;
- SELECT NOW();
- END;
- {code}
- " (org-export-string-as "#+begin_src sql
- BEGIN;
- SELECT NOW();
- END;
- ,#+end_src
- " 'jira))))
- #+END_SRC
-
-** Tables
-
- The holy grail. Do me proud, Orgmode!
-
- #+BEGIN_SRC emacs-lisp
- (ert-deftest ox-jira-test/tables ()
- (should (equal "| a | b |
- | c | d |
- " (org-export-string-as "
- | a | b |
- | c | d |
- " 'jira)))
-
- ;; This should really be
- ;; : || a || b ||
- ;; : | c | d |
- ;;
- ;; but I haven't figured out how to identify the header row yet. This test
- ;; checks that we at least ignore the horizontal lines.
- (should (equal "|| a || b ||
- | c | d |
- " (org-export-string-as "
- | a | b |
- |---+---|
- | c | d |
- " 'jira))))
- #+END_SRC
-
-** Examples
-
- I use example blocks for log & config file snippets, and output from
- programs.
-
- #+BEGIN_SRC emacs-lisp
- (ert-deftest ox-jira-test/example-blocks ()
- (should (equal "{noformat}
- stuff that should
- not be
- formatted
- {noformat}
- " (org-export-string-as "#+begin_example
- stuff that should
- not be
- formatted
- ,#+end_example
- " 'jira))))
- #+END_SRC
-
-** Fixed-width
-
- Fixed-width text is used for short log snippets etc.
-
- #+BEGIN_SRC emacs-lisp
- (ert-deftest ox-jira-test/fixed-width-blocks ()
- (should (equal "{noformat}
- stuff that should
- not be
- formatted
- {noformat}
- " (org-export-string-as ": stuff that should
- : not be
- : formatted
- " 'jira))))
- #+END_SRC
-
-** Horizontal Rule
-
- Horizontal rule is expressed at least five hyphens with newline in Org
-
- #+BEGIN_SRC emacs-lisp
- (ert-deftest ox-jira-test/horizontal-rule ()
- (should
- (equal "----\n" (org-export-string-as "-----\n" 'jira)))
- (should
- (equal "----\n" (org-export-string-as "-------\n" 'jira))))
- #+END_SRC
-
-** Footnotes
-
- #+BEGIN_SRC emacs-lisp
- (ert-deftest ox-jira-test/footnotes ()
- (should (equal "fi fo{anchor:backfn1}[^1^|#fn1]. Another one{anchor:backfn2}[^2^|#fn2].
-
- h1. Footnotes
- {anchor:fn1}[^1^|#backfn1] fa fum.
- {anchor:fn2}[^2^|#backfn2] fut fut.
- " (org-export-string-as "fi fo[fn:1]. Another one[fn:2].
-
- ,* Footnotes
-
- [fn:1] fa fum.
-
- [fn:2] fut fut.
- " 'jira))))
- #+END_SRC
-
-** Provide
-
- Announce that =ox-jira-test= is a feature of the current Emacs.
-
- #+BEGIN_SRC emacs-lisp
- (provide 'ox-jira-test)
- #+END_SRC
-
-* Footer
-
- All this does is help people figure out if a file has been truncated. If
- they see that comment, they know they don't have just half the file.
-
- #+BEGIN_SRC emacs-lisp
- ;;; ox-jira.el-test.el ends here
- #+END_SRC