1 ;;; css-mode-tests.el --- Test suite for CSS mode -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2016 Free Software Foundation, Inc.
5 ;; Author: Simen Heggestøyl <simenheg@gmail.com>
8 ;; This file is part of GNU Emacs.
10 ;; This program is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; This program is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
31 (ert-deftest css-test-property-values ()
32 ;; The `float' property has a flat value list.
34 (equal (sort (css--property-values "float") #'string-lessp)
35 '("left" "none" "right")))
37 ;; The `list-style' property refers to several other properties.
39 (equal (sort (css--property-values "list-style") #'string-lessp)
41 (append (css--property-values "list-style-type")
42 (css--property-values "list-style-position")
43 (css--property-values "list-style-image")))
46 ;; The `position' property is tricky because it's also the name of a
49 (equal (sort (css--property-values "position") #'string-lessp)
50 '("absolute" "fixed" "relative" "static")))
52 ;; The `background-position' property should refer to the `position'
53 ;; value class, not the property of the same name.
55 (equal (css--property-values "background-position")
56 (css--value-class-lookup 'position)))
58 ;; Check that the `color' property doesn't cause infinite recursion
59 ;; because it refers to the value class of the same name.
60 (should (= (length (css--property-values "color")) 18)))
62 (ert-deftest css-test-property-value-cache ()
63 "Test that `css--property-value-cache' is in use."
64 (should-not (gethash "word-wrap" css--property-value-cache))
65 (let ((word-wrap-values (css--property-values "word-wrap")))
66 (should (equal (gethash "word-wrap" css--property-value-cache)
69 (ert-deftest css-test-property-values-no-duplicates ()
70 "Test that `css--property-values' returns no duplicates."
71 ;; The `flex' property is prone to duplicate values; if they aren't
72 ;; removed, it'll contain at least two instances of `auto'.
74 (equal (sort (css--property-values "flex") #'string-lessp)
75 '("auto" "content" "none"))))
77 (ert-deftest css-test-value-class-lookup ()
79 (equal (sort (css--value-class-lookup 'position) #'string-lessp)
80 '("bottom" "center" "left" "right" "top"))))
82 (provide 'css-mode-tests)
83 ;;; css-mode-tests.el ends here