blob: d91a4e63cd2f9766ecdc6f596a5062bf452044e6 (
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
|
;;; test-gloss--stats-text.el --- Tests for gloss--stats-text -*- lexical-binding: t -*-
;; SPDX-License-Identifier: GPL-3.0-or-later
;;; Commentary:
;; Tests for the pure helper `gloss--stats-text' which formats a
;; multi-line stats summary. Drill-tagged count walks the org file via
;; the same primitives as `gloss-drill', so this also indirectly
;; exercises that integration.
;;; Code:
(require 'ert)
(require 'gloss)
(require 'testutil-gloss)
(ert-deftest test-gloss-stats-text-empty-glossary-reports-zero ()
"Boundary: empty glossary file reports zero terms."
(gloss-test--with-temp-glossary "#+TITLE: Glossary\n#+STARTUP: showall\n"
(let ((text (gloss--stats-text)))
(should (string-match-p "Total terms: +0" text))
(should (string-match-p "Drill-tagged: +0" text)))))
(ert-deftest test-gloss-stats-text-populated-glossary-counts-terms ()
"Normal: populated glossary reports total terms and source breakdown."
(gloss-test--with-temp-glossary gloss-test--sample-content
(let ((text (gloss--stats-text)))
(should (string-match-p "Total terms: +2" text))
(should (string-match-p "wiktionary=2" text))
(should (string-match-p "File size:" text))
(should (string-match-p "Cache mtime:" text)))))
(ert-deftest test-gloss-stats-text-missing-file-reports-zero ()
"Boundary: stats-text against a missing file creates it, reports zero terms."
(gloss-test--with-missing-glossary
(let ((text (gloss--stats-text)))
(should (string-match-p "Total terms: +0" text)))))
(provide 'test-gloss--stats-text)
;;; test-gloss--stats-text.el ends here
|