blob: a2d1afa4edce05b2cff8620d22d0a182ab413a35 (
plain)
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
|
;;; test-dev-fkeys--f4-candidates.el --- Tests for cj/--f4-candidates -*- lexical-binding: t -*-
;;; Commentary:
;; Tests for the candidate-menu builder. Returns an alist of
;; (LABEL . ACTION) for the F4 completing-read prompt. The first entry
;; is the default (selected on RET).
;;; Code:
(require 'ert)
(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory))
(require 'dev-fkeys)
;;; Normal Cases
(ert-deftest test-dev-fkeys-f4-candidates-compiled-has-four-entries ()
"Normal: compiled project gets all four candidates."
(let ((cands (cj/--f4-candidates 'compiled)))
(should (= (length cands) 4))))
(ert-deftest test-dev-fkeys-f4-candidates-compiled-default-is-compile-and-run ()
"Normal: first candidate for compiled is Compile + Run (the default)."
(let ((cands (cj/--f4-candidates 'compiled)))
(should (equal (caar cands) "Compile + Run"))
(should (eq (cdar cands) 'compile-and-run))))
(ert-deftest test-dev-fkeys-f4-candidates-compiled-includes-all-actions ()
"Normal: compiled menu maps each label to its action symbol."
(let ((cands (cj/--f4-candidates 'compiled)))
(should (eq (cdr (assoc "Compile + Run" cands)) 'compile-and-run))
(should (eq (cdr (assoc "Compile" cands)) 'compile-only))
(should (eq (cdr (assoc "Run" cands)) 'run-only))
(should (eq (cdr (assoc "Clean + Rebuild" cands)) 'clean-rebuild))))
(ert-deftest test-dev-fkeys-f4-candidates-interpreted-is-run-only ()
"Normal: interpreted project gets a single Run candidate."
(let ((cands (cj/--f4-candidates 'interpreted)))
(should (= (length cands) 1))
(should (equal (caar cands) "Run"))
(should (eq (cdar cands) 'run-only))))
(ert-deftest test-dev-fkeys-f4-candidates-unknown-is-compile-plain ()
"Normal: unknown project gets a single Compile candidate that calls plain compile."
(let ((cands (cj/--f4-candidates 'unknown)))
(should (= (length cands) 1))
(should (equal (caar cands) "Compile"))
(should (eq (cdar cands) 'compile-plain))))
;;; Boundary Cases
(ert-deftest test-dev-fkeys-f4-candidates-bogus-symbol-falls-back-to-unknown ()
"Boundary: an unrecognized project-type symbol falls through to the unknown branch."
(let ((cands (cj/--f4-candidates 'fictional-type)))
(should (= (length cands) 1))
(should (eq (cdar cands) 'compile-plain))))
;;; Error Cases
(ert-deftest test-dev-fkeys-f4-candidates-nil-falls-back-to-unknown ()
"Error: nil project-type falls through to the unknown branch."
(let ((cands (cj/--f4-candidates nil)))
(should (= (length cands) 1))
(should (eq (cdar cands) 'compile-plain))))
(provide 'test-dev-fkeys--f4-candidates)
;;; test-dev-fkeys--f4-candidates.el ends here
|