-
Notifications
You must be signed in to change notification settings - Fork 17
/
buttercup-tests.el
95 lines (87 loc) · 3.53 KB
/
buttercup-tests.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
;; emacs --batch --load buttercup-tests.el
(setq lexical-binding t)
(require 'cli (concat (file-name-directory load-file-name) "org-export-cli.el"))
(cli-eval-file cli-config-file)
(cli-package-setup cli-package-dir cli-packages)
(require 'cl-lib)
(require 'buttercup)
(setq options-alist
`(("--infile" "Path to input .org file (required)")
("--outfile"
"Path to output .html file (use base name of infile by default)"
nil)
("--add-langs"
"Comma-delimited list of additional languages
to enable in code blocks"
nil)
("--evaluate" "Evaluate source code blocks" nil)
("--css" "Path or URL of css stylesheet" nil)
("--css-integrity"
"Optional value for css link integrity attribute" nil)
("--embed-css" "Include contents of css in a <style> block" nil)
("--bootstrap"
"Make Bootstrap-specific modifications to html output;
if selected, link to Bootstrap CDN by default"
nil)
("--package-dir"
"Directory containing elpa packages" ,cli-package-dir)
("--config"
"An elisp expression defining additional configuration" nil)
("--config-file"
"A file path providing additional configuration" nil)
))
(let* ((clargs '("--infile" "foo" "--evaluate" "--embed-css")))
(setq args (cli-parse-args options-alist "" clargs))
(describe "cli-parse-args with valid arguments"
(it "tests --evaluate"
(expect (gethash "evaluate" args) :to-be t))
(it "tests --embed-css"
(expect (gethash "embed-css" args) :to-be t))
(it "tests --infile"
(expect (gethash "infile" args) :to-equal "foo"))
(it "tests --outfile"
(expect (gethash "outfile" args) :to-be nil))
(it "tests --package-dir"
(expect (gethash "package-dir" args) :to-equal cli-package-dir))
))
(describe "cli-parse-args with invalid arguments"
(it "missing --infile"
(expect (cli-parse-args options-alist "" '("--evaluate")) :to-throw))
(it "multiple values for one argument"
(expect (cli-parse-args options-alist "" '("--infile" "foo" "bar")) :to-throw))
(it "invalid argument"
(expect (cli-parse-args options-alist "" '("--foo")) :to-throw))
)
(describe "various utility functions"
(it "cli-option-p is t"
(expect (cli-option-p "--infile") :to-be t))
(it "cli-option-p is nil"
(expect (cli-option-p "infile") :to-be nil))
(it "cli-option-p is nil given nil"
(expect (cli-option-p nil) :to-be nil))
(it "cli-opt-name"
(expect (cli-opt-name "--infile") :to-equal "infile"))
)
(describe "tests of cli-break-string"
(it "single word"
(expect (cli-break-string "word" 10) :to-equal '("word")))
(it "two words"
(expect (cli-break-string "two words" 10) :to-equal '("two words")))
(it "a longer phrase"
(expect (cli-break-string "this is a longer phrase" 15)
:to-equal '("this is a" "longer phrase")))
(it "a word exactly maxwidth"
(expect (cli-break-string "abcdefghij" 10) :to-equal '("abcdefghij")))
(it "a word maxwidth + 1"
(expect (cli-break-string "abcdefghijk" 10) :to-equal '("abcdefghijk")))
(it "two long words"
(expect (cli-break-string "abcdefghijk lmnopqrstuv" 10)
:to-equal '("abcdefghijk" "lmnopqrstuv")))
(it "three long words"
(expect (cli-break-string "abcdefghijk lmnopqrstuv 12345678910" 10)
:to-equal '("abcdefghijk" "lmnopqrstuv" "12345678910")))
(it "long short long"
(expect (cli-break-string "abcdefghijk lmnopq 12345678910" 10)
:to-equal '("abcdefghijk" "lmnopq" "12345678910")))
)
(buttercup-run)