blob: bb6ac96f21d20854bc131d675038fa42d0b7a7e7 (
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
|
;;; test-music-config--bar-string.el --- Tests for the block progress bar -*- coding: utf-8; lexical-binding: t; -*-
;;
;; Author: Craig Jennings <c@cjennings.net>
;;
;;; Commentary:
;; Unit tests for `cj/music--bar-string': render a WIDTH-cell block bar from a
;; filled-cell count (from `cj/music--bar-fill'), or an "on air" marker when the
;; fill is `indeterminate' (a live stream with no duration). Face-carrying
;; text; the tests assert the rendered length and content, not the faces.
;;
;;; Code:
(require 'ert)
(defvar-keymap cj/custom-keymap :doc "Stub keymap for testing")
(let ((emms-dir (car (file-expand-wildcards
(expand-file-name "elpa/emms-*" user-emacs-directory)))))
(when emms-dir (add-to-list 'load-path emms-dir)))
(require 'emms)
(require 'music-config)
(ert-deftest test-music-config--bar-string-normal-half ()
"Normal: 10 of 20 cells filled renders a 20-cell bar."
(let ((s (substring-no-properties (cj/music--bar-string 10 20))))
(should (= (length s) 20))
(should (= (cl-count ?█ s) 10))
(should (= (cl-count ?░ s) 10))))
(ert-deftest test-music-config--bar-string-boundary-empty ()
"Boundary: zero fill is all empty cells."
(let ((s (substring-no-properties (cj/music--bar-string 0 20))))
(should (= (cl-count ?█ s) 0))
(should (= (cl-count ?░ s) 20))))
(ert-deftest test-music-config--bar-string-boundary-full ()
"Boundary: full fill is all filled cells."
(let ((s (substring-no-properties (cj/music--bar-string 20 20))))
(should (= (cl-count ?█ s) 20))
(should (= (cl-count ?░ s) 0))))
(ert-deftest test-music-config--bar-string-indeterminate-on-air ()
"Error/indeterminate: a stream renders an on-air marker, not a bar."
(let ((s (substring-no-properties (cj/music--bar-string 'indeterminate 20))))
(should (string-match-p "on air" s))
(should (= (cl-count ?█ s) 0))))
(provide 'test-music-config--bar-string)
;;; test-music-config--bar-string.el ends here
|