-
Notifications
You must be signed in to change notification settings - Fork 14
/
youtube-tests.lisp
47 lines (39 loc) · 2.01 KB
/
youtube-tests.lisp
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
(fiasco:define-test-package #:3bmd-youtube-tests
(:use #:3bmd-youtube))
(in-package #:3bmd-youtube-tests)
(deftest parse-without-options ()
(let ((3bmd-youtube:*youtube-embeds* t))
(multiple-value-bind (production remaining-text parse-succeeded)
(esrap:parse '3bmd-grammar::%inline "!yt[nbY-meOL57I]")
(is (equalp production '(:youtube-embed "nbY-meOL57I")))
(is (not remaining-text))
(is parse-succeeded))))
(deftest parse-with-one-option ()
(let ((3bmd-youtube:*youtube-embeds* t))
(multiple-value-bind (production remaining-text parse-succeeded)
(esrap:parse '3bmd-grammar::%inline "!yt[nbY-meOL57I|width=600]")
(is (equalp production '(:youtube-embed "nbY-meOL57I" ("width" . "600"))))
(is (not remaining-text))
(is parse-succeeded))))
(deftest parse-with-options ()
(let ((3bmd-youtube:*youtube-embeds* t))
(multiple-value-bind (production remaining-text parse-succeeded)
(esrap:parse '3bmd-grammar::%inline "!yt[nbY-meOL57I|width=600,allowfullscreen]")
;; TODO: The test shouldn't depend on the order of options.
(is (equalp production '(:youtube-embed "nbY-meOL57I" ("width" . "600") ("allowfullscreen"))))
(is (not remaining-text))
(is parse-succeeded))))
(deftest expand-to-iframe-without-options ()
(let ((3bmd-youtube:*youtube-embeds* t))
(let ((output (with-output-to-string (s)
(3bmd:parse-string-and-print-to-stream "!yt[nbY-meOL57I]" s))))
(is (string= "<p><iframe src=\"https://www.youtube.com/embed/nbY-meOL57I\" frameborder=\"0\" ></iframe></p>
"
output)))))
(deftest expand-to-iframe-with-options ()
(let ((3bmd-youtube:*youtube-embeds* t))
(let ((output (with-output-to-string (s)
(3bmd:parse-string-and-print-to-stream "!yt[nbY-meOL57I|width=20,allowfullscreen]" s))))
(is (string= "<p><iframe src=\"https://www.youtube.com/embed/nbY-meOL57I\" frameborder=\"0\" width=\"20\" allowfullscreen></iframe></p>
"
output)))))