css-mode-tests.el 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. ;;; css-mode-tests.el --- Test suite for CSS mode -*- lexical-binding: t; -*-
  2. ;; Copyright (C) 2016 Free Software Foundation, Inc.
  3. ;; Author: Simen Heggestøyl <simenheg@gmail.com>
  4. ;; Keywords: internal
  5. ;; This file is part of GNU Emacs.
  6. ;; This program is free software; you can redistribute it and/or modify
  7. ;; it under the terms of the GNU General Public License as published by
  8. ;; the Free Software Foundation, either version 3 of the License, or
  9. ;; (at your option) any later version.
  10. ;; This program is distributed in the hope that it will be useful,
  11. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ;; GNU General Public License for more details.
  14. ;; You should have received a copy of the GNU General Public License
  15. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. ;;; Commentary:
  17. ;;; Code:
  18. (require 'ert)
  19. (require 'css-mode)
  20. (ert-deftest css-test-property-values ()
  21. ;; The `float' property has a flat value list.
  22. (should
  23. (equal (sort (css--property-values "float") #'string-lessp)
  24. '("left" "none" "right")))
  25. ;; The `list-style' property refers to several other properties.
  26. (should
  27. (equal (sort (css--property-values "list-style") #'string-lessp)
  28. (sort (append (css--property-values "list-style-type")
  29. (css--property-values "list-style-position")
  30. (css--property-values "list-style-image"))
  31. #'string-lessp)))
  32. ;; The `position' property is tricky because it's also the name of a
  33. ;; value class.
  34. (should
  35. (equal (sort (css--property-values "position") #'string-lessp)
  36. '("absolute" "fixed" "relative" "static")))
  37. ;; The `background-position' property should refer to the `position'
  38. ;; value class, not the property of the same name.
  39. (should
  40. (equal (css--property-values "background-position")
  41. (css--value-class-lookup 'position)))
  42. ;; Check that the `color' property doesn't cause infinite recursion
  43. ;; because it refers to the value class of the same name.
  44. (should (= (length (css--property-values "color")) 18)))
  45. (ert-deftest css-test-value-class-lookup ()
  46. (should
  47. (equal (sort (css--value-class-lookup 'position) #'string-lessp)
  48. '("bottom" "center" "left" "right" "top"))))
  49. (provide 'css-mode-tests)
  50. ;;; css-mode-tests.el ends here