/
beginend-dired-test.el
108 lines (81 loc) · 3.59 KB
/
beginend-dired-test.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
;;; beginend-test.el --- Tests from beginend -*- lexical-binding: t; -*-
;; Copyright (C) 2017 Damien Cassou
;; Author: Damien Cassou <damien@cassou.me>
;; 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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;;; Code:
(load "test/test-helper")
(require 'assess)
(require 'buttercup)
(require 'beginend)
(require 'dired)
(require 'dired-x)
(defun beginend-create-dired-buffer ()
"Create and return a buffer ressembling a dired one."
(assess-with-filesystem '("dir1/" "dir2/")
(dired default-directory)
(current-buffer)))
(defun beginend-dired-test (begin-p omit hide-details hide-info-lines)
"Test going to BEGIN-P in dired depending on OMIT and HIDE-DETAILS.
Set `dired-hide-details-hide-information-lines' to HIDE-INFO-LINES."
(let ((dired-hide-details-hide-information-lines hide-info-lines)
(dired-omit-verbose nil))
(with-current-buffer (beginend-create-dired-buffer)
(goto-char 2) ;; any position
(when omit
(dired-omit-mode))
(when hide-details
(dired-hide-details-mode))
(if begin-p
(progn
(beginend-dired-mode-goto-beginning)
(expect (looking-at "dir1") :to-be-truthy))
(beginend-dired-mode-goto-end)
(expect (looking-back "dir2" 4) :to-be-truthy))
(kill-buffer))))
(describe "buttercup in a dired buffer"
(describe "without dired-hide-details-mode"
(describe "without dired-omit-mode"
(it "offers a command to go to first file"
(beginend-dired-test t nil nil t))
(it "offers a command to go to last file"
(beginend-dired-test nil nil nil t)))
(describe "with dired-omit-mode"
(it "offers a command to go to first file"
(beginend-dired-test t t nil t))
(it "offers a command to go to last file with dired-omit-mode"
(beginend-dired-test nil t nil t))))
(describe "with-dired-hide-details-mode (also hides information lines)"
(describe "without dired-omit-mode"
(it "offers a command to go to first file"
(beginend-dired-test t nil t t))
(it "offers a command to go to last file with dired-omit-mode"
(beginend-dired-test nil nil t t)))
(describe "with dired-omit-mode"
(it "offers a command to go to first file"
(beginend-dired-test t t t t))
(it "offers a command to go to last file with dired-omit-mode"
(beginend-dired-test nil t t t))))
(describe "with-dired-hide-details-mode (does not hide information lines)"
(describe "without dired-omit-mode"
(it "offers a command to go to first file"
(beginend-dired-test t nil t nil))
(it "offers a command to go to last file with dired-omit-mode"
(beginend-dired-test nil nil t nil)))
(describe "with dired-omit-mode"
(it "offers a command to go to first file"
(beginend-dired-test t t t nil))
(it "offers a command to go to last file with dired-omit-mode"
(beginend-dired-test nil t t nil)))))
(provide 'beginend-dired-test)
;;; beginend-dired-test.el ends here