From 0f9a78e7700ab3eed370c2f616d7932d953dd100 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Simen=20Heggest=C3=B8yl?= Date: Thu, 28 Sep 2017 18:47:07 +0200 Subject: [PATCH] Add tests for `css-current-defun-name' * 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 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/lisp/textmodes/css-mode-tests.el b/test/lisp/textmodes/css-mode-tests.el index f93fdbbc5af..47cf5f9244b 100644 --- a/test/lisp/textmodes/css-mode-tests.el +++ b/test/lisp/textmodes/css-mode-tests.el @@ -80,6 +80,27 @@ (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 () -- 2.39.5