Factor out new function rmc--add-key-description
* lisp/emacs-lisp/rmc.el (rmc--add-key-description): Factor out new function from... (read-multiple-choice): ...here. * test/lisp/emacs-lisp/rmc-tests.el (test-rmc--add-key-description) (test-rmc--add-key-description/with-attributes) (test-rmc--add-key-description/non-graphical-display): New tests.
This commit is contained in:
parent
978987f7ad
commit
68f15e815e
2 changed files with 52 additions and 32 deletions
|
@ -28,8 +28,30 @@
|
|||
|
||||
(require 'ert)
|
||||
(require 'rmc)
|
||||
(require 'cl-lib)
|
||||
(eval-when-compile (require 'cl-lib))
|
||||
|
||||
(ert-deftest test-rmc--add-key-description ()
|
||||
(cl-letf (((symbol-function 'display-supports-face-attributes-p) (lambda (_ _) t)))
|
||||
(should (equal (rmc--add-key-description '(?y "yes"))
|
||||
'(?y . "yes")))
|
||||
(should (equal (rmc--add-key-description '(?n "foo"))
|
||||
'(?n . "[n] foo")))))
|
||||
|
||||
(ert-deftest test-rmc--add-key-description/with-attributes ()
|
||||
(cl-letf (((symbol-function 'display-supports-face-attributes-p) (lambda (_ _) t)))
|
||||
(should (equal-including-properties
|
||||
(rmc--add-key-description '(?y "yes"))
|
||||
`(?y . ,(concat (propertize "y" 'face 'read-multiple-choice-face) "es"))))
|
||||
(should (equal-including-properties
|
||||
(rmc--add-key-description '(?n "foo"))
|
||||
'(?n . "[n] foo")))))
|
||||
|
||||
(ert-deftest test-rmc--add-key-description/non-graphical-display ()
|
||||
(cl-letf (((symbol-function 'display-supports-face-attributes-p) (lambda (_ _) nil)))
|
||||
(should (equal-including-properties
|
||||
(rmc--add-key-description '(?y "yes"))
|
||||
'(?y . "[Y]es")))))
|
||||
|
||||
(ert-deftest test-read-multiple-choice ()
|
||||
(dolist (char '(?y ?n))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue