diff options
| author | Nacho Barrientos <nacho.barrientos@cern.ch> | 2023-03-31 09:10:44 +0200 |
|---|---|---|
| committer | Jonas Bernoulli <jonas@bernoul.li> | 2023-04-02 11:58:34 +0200 |
| commit | a77734c6cd912554d36cbd51c559fbb5e8fb417a (patch) | |
| tree | 32dbfcd29c33fee18f7a8355164eec32851fa29d /test | |
| parent | dd2e870b134bd292e470c830a42ce59a4396cdb7 (diff) | |
Consolidate ellipsis customisation
This patch centralises the generation of ellipses by extending the
functionality provided by `magit-ellipsis`, allowing end users to
customise for instance the ellipsis used in `magit-log` buffers.
See [0] for more background and extra information.
[0] https://github.com/magit/magit/discussions/4907
Diffstat (limited to 'test')
| -rw-r--r-- | test/magit-tests.el | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/magit-tests.el b/test/magit-tests.el index 7def6ab..89dc61f 100644 --- a/test/magit-tests.el +++ b/test/magit-tests.el @@ -446,6 +446,45 @@ Enter passphrase for key '/home/user/.ssh/id_rsa': " (should (equal (get-text-property 0 'font-lock-face str) '(bold highlight))) (should (equal (get-text-property 2 'font-lock-face str) '(bold))))) +(ert-deftest magit-base:ellipsis-default-values () + (cl-letf (((symbol-function 'char-displayable-p) (lambda (_) t))) + (should (equal "…" (magit--ellipsis 'margin))) + (should (equal "…" (magit--ellipsis)))) + (cl-letf (((symbol-function 'char-displayable-p) (lambda (_) nil))) + (should (equal ">" (magit--ellipsis 'margin))) + (should (equal "..." (magit--ellipsis))))) + +(ert-deftest magit-base:ellipsis-customisations-are-respected () + (let ((magit-ellipsis '((margin (?· . "!")) (t (?. . ">"))))) + (cl-letf (((symbol-function 'char-displayable-p) (lambda (_) t))) + (should (equal "·" (magit--ellipsis 'margin))) + (should (equal "." (magit--ellipsis)))) + (cl-letf (((symbol-function 'char-displayable-p) (lambda (_) nil))) + (should (equal "!" (magit--ellipsis 'margin))) + (should (equal ">" (magit--ellipsis)))))) + +(ert-deftest magit-base:ellipsis-fancy-nil-defaults-to-universal () + (let ((magit-ellipsis '((margin (nil . "...")) (t (nil . "^^^"))))) + (should (equal "..." (magit--ellipsis 'margin))) + (should (equal "^^^" (magit--ellipsis))))) + +(ert-deftest magit-base:ellipsis-legacy-type-allowed () + (let ((magit-ellipsis "⋮")) + (should (equal "⋮" (magit--ellipsis 'margin))) + (should (equal "⋮" (magit--ellipsis))))) + +(ert-deftest magit-base:ellipsis-malformed-customisation-no-default () + (let ((magit-ellipsis '((margin (?· . "!"))))) + (should-error (magit--ellipsis) + :type 'user-error))) + +(ert-deftest magit-base:ellipsis-unknown-use-case-defaults-to-default () + (let ((magit-ellipsis '((margin (?· . "!")) (t (?. . ">"))))) + (cl-letf (((symbol-function 'char-displayable-p) (lambda (_) t))) + (should (equal (magit--ellipsis 'foo) (magit--ellipsis)))) + (cl-letf (((symbol-function 'char-displayable-p) (lambda (_) nil))) + (should (equal (magit--ellipsis 'foo) (magit--ellipsis)))))) + ;;; magit-tests.el ends soon (provide 'magit-tests) ;; Local Variables: |
