summaryrefslogtreecommitdiff
path: root/tests/test-transcription-counter.el
blob: fae353ba732888fbecf5196d01faf9bdd3584e51 (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
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
;;; test-transcription-counter.el --- Tests for active transcription counting -*- lexical-binding: t; -*-

;;; Commentary:
;; Tests for cj/--count-active-transcriptions and modeline integration
;; Categories: Normal cases, Boundary cases

;;; Code:

(require 'ert)
(require 'transcription-config)

;; ----------------------------- Normal Cases ----------------------------------

(ert-deftest test-cj/--count-active-transcriptions-empty ()
  "Test count when no transcriptions are active."
  (let ((cj/transcriptions-list '()))
    (should (= 0 (cj/--count-active-transcriptions)))))

(ert-deftest test-cj/--count-active-transcriptions-one-running ()
  "Test count with one running transcription."
  (let ((cj/transcriptions-list
         '((proc1 "file1.m4a" nil running))))
    (should (= 1 (cj/--count-active-transcriptions)))))

(ert-deftest test-cj/--count-active-transcriptions-multiple-running ()
  "Test count with multiple running transcriptions."
  (let ((cj/transcriptions-list
         '((proc1 "file1.m4a" nil running)
           (proc2 "file2.m4a" nil running)
           (proc3 "file3.m4a" nil running))))
    (should (= 3 (cj/--count-active-transcriptions)))))

(ert-deftest test-cj/--count-active-transcriptions-mixed-status ()
  "Test count excludes completed/errored transcriptions."
  (let ((cj/transcriptions-list
         '((proc1 "file1.m4a" nil running)
           (proc2 "file2.m4a" nil complete)
           (proc3 "file3.m4a" nil running)
           (proc4 "file4.m4a" nil error))))
    (should (= 2 (cj/--count-active-transcriptions)))))

;; ----------------------------- Boundary Cases --------------------------------

(ert-deftest test-cj/--count-active-transcriptions-only-complete ()
  "Test count when all transcriptions are complete."
  (let ((cj/transcriptions-list
         '((proc1 "file1.m4a" nil complete)
           (proc2 "file2.m4a" nil complete))))
    (should (= 0 (cj/--count-active-transcriptions)))))

(ert-deftest test-cj/--count-active-transcriptions-only-error ()
  "Test count when all transcriptions errored."
  (let ((cj/transcriptions-list
         '((proc1 "file1.m4a" nil error)
           (proc2 "file2.m4a" nil error))))
    (should (= 0 (cj/--count-active-transcriptions)))))

;; ----------------------------- Modeline Tests --------------------------------

(ert-deftest test-cj/--transcription-modeline-string-none-active ()
  "Test modeline string when no transcriptions active."
  (let ((cj/transcriptions-list '()))
    (should-not (cj/--transcription-modeline-string))))

(ert-deftest test-cj/--transcription-modeline-string-one-active ()
  "Test modeline string with one active transcription."
  (let ((cj/transcriptions-list
         '((proc1 "file1.m4a" nil running))))
    (let ((result (cj/--transcription-modeline-string)))
      (should result)
      (should (string-match-p "⏺1" result)))))

(ert-deftest test-cj/--transcription-modeline-string-multiple-active ()
  "Test modeline string with multiple active transcriptions."
  (let ((cj/transcriptions-list
         '((proc1 "file1.m4a" nil running)
           (proc2 "file2.m4a" nil running)
           (proc3 "file3.m4a" nil running))))
    (let ((result (cj/--transcription-modeline-string)))
      (should result)
      (should (string-match-p "⏺3" result)))))

(ert-deftest test-cj/--transcription-modeline-string-has-help-echo ()
  "Test that modeline string has help-echo property."
  (let ((cj/transcriptions-list
         '((proc1 "file1.m4a" nil running))))
    (let ((result (cj/--transcription-modeline-string)))
      (should (get-text-property 0 'help-echo result)))))

(ert-deftest test-cj/--transcription-modeline-string-has-face ()
  "Test that modeline string has warning face."
  (let ((cj/transcriptions-list
         '((proc1 "file1.m4a" nil running))))
    (let ((result (cj/--transcription-modeline-string)))
      (should (eq 'warning (get-text-property 0 'face result))))))

(provide 'test-transcription-counter)
;;; test-transcription-counter.el ends here