]> git.eshelyaron.com Git - emacs.git/commitdiff
Add tests for `css-current-defun-name'
authorSimen Heggestøyl <simenheg@gmail.com>
Thu, 28 Sep 2017 16:47:07 +0000 (18:47 +0200)
committerSimen Heggestøyl <simenheg@gmail.com>
Thu, 28 Sep 2017 16:55:06 +0000 (18:55 +0200)
* test/lisp/textmodes/css-mode-tests.el (css-test-current-defun-name)
(css-test-current-defun-name-nested)
(css-test-current-defun-name-complex): New tests for
`css-current-defun-name'.

test/lisp/textmodes/css-mode-tests.el

index f93fdbbc5afd8273377cccbd4e41623c9106f82d..47cf5f9244b49477fe6ca3ce9a379a3850bfdc46 100644 (file)
    (equal (seq-sort #'string-lessp (css--value-class-lookup 'position))
           '("bottom" "calc()" "center" "left" "right" "top"))))
 
+(ert-deftest css-test-current-defun-name ()
+  (with-temp-buffer
+    (insert "body { top: 0; }")
+    (goto-char 7)
+    (should (equal (css-current-defun-name) "body"))
+    (goto-char 18)
+    (should (equal (css-current-defun-name) "body"))))
+
+(ert-deftest css-test-current-defun-name-nested ()
+  (with-temp-buffer
+    (insert "body > .main a { top: 0; }")
+    (goto-char 20)
+    (should (equal (css-current-defun-name) "body > .main a"))))
+
+(ert-deftest css-test-current-defun-name-complex ()
+  (with-temp-buffer
+    (insert "input[type=submit]:hover { color: red; }")
+    (goto-char 30)
+    (should (equal (css-current-defun-name)
+                   "input[type=submit]:hover"))))
+
 ;;; Completion
 
 (defun css-mode-tests--completions ()