mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-23 19:19:50 +00:00
70 lines
2.6 KiB
EmacsLisp
70 lines
2.6 KiB
EmacsLisp
;;; doom-modeline-test.el --- Unit tests for doom-modeline -*- lexical-binding: t; -*-
|
|
|
|
;; Copyright (C) 2018 Vincent Zhang
|
|
|
|
;; Author: Vincent Zhang <seagle0128@gmail.com>
|
|
;; Homepage: https://github.com/seagle0128/doom-modeline
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
;; This program is free software; you can redistribute it and/or
|
|
;; modify it under the terms of the GNU General Public License as
|
|
;; published by the Free Software Foundation; either version 2, or
|
|
;; (at your option) any later version.
|
|
;;
|
|
;; This program is distributed in the hope that it will be useful,
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
;; General Public License for more details.
|
|
;;
|
|
;; You should have received a copy of the GNU General Public License
|
|
;; along with this program; see the file COPYING. If not, write to
|
|
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
|
;; Floor, Boston, MA 02110-1301, USA.
|
|
;;
|
|
|
|
;;; Commentary:
|
|
;;
|
|
;; Unit tests for doom-modeline.
|
|
;;
|
|
|
|
;;; Code:
|
|
|
|
(ert-deftest doom-modeline--buffer-file-name/truncate-upto-project ()
|
|
(let ((default-directory "/home/user/project/")
|
|
(file-path "/home/user/project/relative/test.txt")
|
|
(true-file-path nil))
|
|
(should
|
|
(string= (strip-text-properties
|
|
(doom-modeline--buffer-file-name file-path true-file-path 'shrink))
|
|
"/h/u/project/relative/test.txt"))))
|
|
|
|
(ert-deftest doom-modeline--buffer-file-name/truncate-from-project ()
|
|
(let ((default-directory "/home/user/project/")
|
|
(file-path "/home/user/project/relative/test.txt")
|
|
(true-file-path nil))
|
|
(should
|
|
(string= (strip-text-properties
|
|
(doom-modeline--buffer-file-name file-path true-file-path nil 'shrink))
|
|
"/home/user/project/r/test.txt"))))
|
|
|
|
(ert-deftest doom-modeline--buffer-file-name/truncate-with-project ()
|
|
(let ((default-directory "/home/user/project/")
|
|
(file-path "/home/user/project/relative/test.txt")
|
|
(true-file-path nil))
|
|
(should
|
|
(string= (strip-text-properties
|
|
(doom-modeline--buffer-file-name file-path true-file-path 'shrink 'shrink 'hide))
|
|
"project/r/test.txt"))))
|
|
|
|
(ert-deftest doom-modeline--buffer-file-name/truncate-except-project ()
|
|
(let ((default-directory "/home/user/project/")
|
|
(file-path "/home/user/project/relative/test.txt")
|
|
(true-file-path nil))
|
|
(should
|
|
(string= (strip-text-properties
|
|
(doom-modeline--buffer-file-name file-path true-file-path 'shrink 'shrink))
|
|
"/h/u/project/r/test.txt"))))
|
|
|
|
;;; doom-modeline-test.el ends here
|