From d313c37f14511564849c70c564c14ca51bd4ae7c Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Thu, 30 Apr 2026 01:07:44 -0500 Subject: test: add gloss secondary commands test suite (red phase) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Six test files for the remaining stub commands. All 14 tests fail at this commit because the implementations are stubs. `gloss--add-finish-internal' (the pure save side of `gloss-add') gets N/B/E coverage on validation and the persistence side effect. `gloss--stats-text' (the pure stats string formatter) covers empty, populated, and missing-file cases. The interactive commands (`gloss-edit', `gloss-list-terms', `gloss-reload', `gloss-drill-export') get smoke tests only — the design treats them as mode-glue with 70% coverage targets, since prompts and `switch-to-buffer' are framework behaviour Emacs already tests. Two error-path tests assert the message contains a specific substring, not just that `user-error' was raised. The stubs raise `user-error' too, so a bare `should-error' would pass for the wrong reason. The substring check anchors red against the real error path. --- tests/test-gloss--list-terms-smoke.el | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/test-gloss--list-terms-smoke.el (limited to 'tests/test-gloss--list-terms-smoke.el') diff --git a/tests/test-gloss--list-terms-smoke.el b/tests/test-gloss--list-terms-smoke.el new file mode 100644 index 0000000..0e331b6 --- /dev/null +++ b/tests/test-gloss--list-terms-smoke.el @@ -0,0 +1,35 @@ +;;; test-gloss--list-terms-smoke.el --- Smoke tests for gloss-list-terms -*- lexical-binding: t -*- + +;; SPDX-License-Identifier: GPL-3.0-or-later + +;;; Commentary: +;; Smoke tests for `gloss-list-terms'. Uses `completing-read' on the +;; cached term list and dispatches to the lookup flow with the chosen +;; term. + +;;; Code: + +(require 'ert) +(require 'cl-lib) +(require 'gloss) +(require 'testutil-gloss) + +(ert-deftest test-gloss-list-terms-empty-glossary-raises () + "Error: list-terms on an empty glossary raises `user-error' mentioning empty." + (gloss-test--with-temp-glossary "#+TITLE: Glossary\n" + (let ((err (should-error (gloss-list-terms) :type 'user-error))) + (should (string-match-p "empty" (error-message-string err)))))) + +(ert-deftest test-gloss-list-terms-dispatches-chosen-to-lookup () + "Smoke: list-terms passes the chosen term to `gloss--lookup-flow'." + (gloss-test--with-temp-glossary gloss-test--sample-content + (let (looked-up) + (cl-letf (((symbol-function 'completing-read) + (lambda (&rest _) "anaphora")) + ((symbol-function 'gloss--lookup-flow) + (lambda (term &optional _) (setq looked-up term) :show))) + (gloss-list-terms) + (should (equal looked-up "anaphora")))))) + +(provide 'test-gloss--list-terms-smoke) +;;; test-gloss--list-terms-smoke.el ends here -- cgit v1.2.3