Move unit tests from ert to buttercup
Easier to organize and write. Now I can hopefully strive for better coverage!
This commit is contained in:
parent
98d2f1de3f
commit
eaca8c58fa
41 changed files with 1371 additions and 1101 deletions
|
@ -1,32 +0,0 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; lang/web/test/autoload-css.el
|
||||
|
||||
(def-test! toggle-inline-or-block
|
||||
(let ((css-indent-offset 2))
|
||||
(should-buffer!
|
||||
("body { color: red{0}; font-size: 2em; }")
|
||||
("body {"
|
||||
" color: red{|};"
|
||||
" font-size: 2em;"
|
||||
"}")
|
||||
(delay-mode-hooks (css-mode))
|
||||
(+css/toggle-inline-or-block))))
|
||||
|
||||
(def-test! comment-indent-new-line
|
||||
(should-buffer!
|
||||
("// test{0}"
|
||||
"body { color: red; font-size: 2em; }")
|
||||
("// test"
|
||||
"// {|}"
|
||||
"body { color: red; font-size: 2em; }")
|
||||
(delay-mode-hooks (scss-mode))
|
||||
(+css/comment-indent-new-line))
|
||||
(should-buffer!
|
||||
("// test{0}"
|
||||
"body { color: red; font-size: 2em; }")
|
||||
("// test"
|
||||
"// {|}"
|
||||
"body { color: red; font-size: 2em; }")
|
||||
(delay-mode-hooks (scss-mode))
|
||||
(+css/comment-indent-new-line)))
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; lang/web/test/autoload-html.el
|
||||
|
||||
(def-test! encode-entities
|
||||
(should (equal (+web-encode-entities "Hello world")
|
||||
"Hello world"))
|
||||
(should (equal (+web-encode-entities "H€llø wørld")
|
||||
"H€llø wørld")))
|
||||
|
||||
(def-test! decode-entities
|
||||
(should (equal (+web-decode-entities "Hello world")
|
||||
"Hello world"))
|
||||
(should (equal (+web-decode-entities "H€llø wørld")
|
||||
"H€llø wørld")))
|
93
modules/lang/web/test/test-web.el
Normal file
93
modules/lang/web/test/test-web.el
Normal file
|
@ -0,0 +1,93 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; lang/web/test/test-autoload-web.el
|
||||
|
||||
(describe "lang/web"
|
||||
(describe "+html"
|
||||
(before-all (load! "../autoload/html.el"))
|
||||
|
||||
(describe "encode entities"
|
||||
(it "encodes strings with html entities"
|
||||
(expect (+web-encode-entities "H€llø wørld")
|
||||
:to-equal "H€llø wørld"))
|
||||
(it "does nothing when html entities are absent"
|
||||
(expect (+web-encode-entities "Hello world")
|
||||
:to-equal "Hello world")))
|
||||
|
||||
(describe "decode entities"
|
||||
(it "decodes strings with html entities"
|
||||
(expect (+web-decode-entities "H€llø wørld")
|
||||
:to-equal "H€llø wørld"))
|
||||
(it "does nothing when html entities are absent"
|
||||
(expect (+web-decode-entities "Hello world")
|
||||
:to-equal "Hello world"))))
|
||||
|
||||
(describe "+css"
|
||||
:var (css-indent-offset)
|
||||
(before-all
|
||||
(load! "../autoload/css.el")
|
||||
(require 'smartparens)
|
||||
(smartparens-mode +1))
|
||||
(after-all
|
||||
(smartparens-mode -1)
|
||||
(unload-feature 'smartparens t))
|
||||
|
||||
(before-each
|
||||
(setq css-indent-offset 2)
|
||||
(set-buffer (get-buffer-create "css"))
|
||||
(delay-mode-hooks (css-mode)))
|
||||
(after-each
|
||||
(kill-buffer (get-buffer "css")))
|
||||
|
||||
(describe "toggle-inline-or-block"
|
||||
(after-each
|
||||
(+css/toggle-inline-or-block)
|
||||
(expect (string-trim (buffer-string)) :to-equal
|
||||
(string-join
|
||||
'("body {"
|
||||
" color: red;"
|
||||
" font-size: 2em;"
|
||||
"}")
|
||||
"\n")))
|
||||
|
||||
(describe "css-mode"
|
||||
(before-each )
|
||||
(it "converts inline statements into multiline blocks"
|
||||
(insert! "body { color: red{0}; font-size: 2em; }"))
|
||||
(it "works when cursor is on closing brace"
|
||||
(insert! "body { color: red; font-size: 2em; {0}}"))
|
||||
(it "works when cursor is on opening brace"
|
||||
(insert! "body {{0} color: red; font-size: 2em; }"))
|
||||
(it "works when cursor is on same line"
|
||||
(insert! "{0}body { color: red; font-size: 2em; }"))))
|
||||
|
||||
(describe "comment-indent-new-line"
|
||||
(before-each
|
||||
(delay-mode-hooks (scss-mode)))
|
||||
|
||||
(it "continues commented lines on newline"
|
||||
(insert! "// test{0}\n"
|
||||
"body { color: red; font-size: 2em; }")
|
||||
(+css/comment-indent-new-line)
|
||||
(expect (string-trim (buffer-string)) :to-equal
|
||||
(string-join
|
||||
'("// test"
|
||||
"// "
|
||||
"body { color: red; font-size: 2em; }")
|
||||
"\n"))
|
||||
(expect (eolp))
|
||||
(expect (line-number-at-pos) :to-be 2))
|
||||
(it "preserves indentation within continued comments"
|
||||
(insert! "// test{0}\n"
|
||||
"body { color: red; font-size: 2em; }")
|
||||
(+css/comment-indent-new-line)
|
||||
(expect (string-trim (buffer-string)) :to-equal
|
||||
(string-join
|
||||
'("// test"
|
||||
"// "
|
||||
"body { color: red; font-size: 2em; }")
|
||||
"\n"))
|
||||
(expect (eolp))
|
||||
(expect (line-number-at-pos) :to-be 2)))))
|
||||
|
||||
|
||||
;;
|
Loading…
Add table
Add a link
Reference in a new issue