diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-24 13:44:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-24 13:44:34 -0500 |
| commit | b081d62276378b3168c92c06153fd59db0589535 (patch) | |
| tree | 9be7f7d22e0c9b4a73432fe744c09bb456c671a9 /tests/test-pearl-surface.el | |
| download | pearl-b081d62276378b3168c92c06153fd59db0589535.tar.gz pearl-b081d62276378b3168c92c06153fd59db0589535.zip | |
feat: pearl — manage Linear issues from org-mode
Pearl fetches Linear issues into an org file and syncs edits back. It covers list / custom views / saved queries, per-issue and bulk rendering with comments inline, conflict-aware sync of descriptions, titles, and comments, field commands for priority / state / assignee / labels, and a transient dispatch menu. The render folds to a scannable outline and nests issues under a sortable parent.
Based on and inspired by Gael Blanchemain's linear-emacs.
Diffstat (limited to 'tests/test-pearl-surface.el')
| -rw-r--r-- | tests/test-pearl-surface.el | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/tests/test-pearl-surface.el b/tests/test-pearl-surface.el new file mode 100644 index 0000000..4c2b7e5 --- /dev/null +++ b/tests/test-pearl-surface.el @@ -0,0 +1,81 @@ +;;; test-pearl-surface.el --- Tests for surfacing the active buffer -*- lexical-binding: t; -*- + +;; Copyright (C) 2026 Craig Jennings + +;; Author: Craig Jennings <c@cjennings.net> + +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <http://www.gnu.org/licenses/>. + +;;; Commentary: + +;; Tests for `pearl--surface-buffer': bring the active org buffer to a window +;; after a command updates it, gated on `pearl-surface-buffer', focus-following +;; gated on `pearl-surface-select-window', and skipped when the buffer is dead +;; or already visible. + +;;; Code: + +(require 'test-bootstrap (expand-file-name "test-bootstrap.el")) +(require 'cl-lib) + +(ert-deftest test-pearl-surface-buffer-disabled-is-noop () + "With `pearl-surface-buffer' nil, nothing is displayed." + (let ((pearl-surface-buffer nil) (shown nil)) + (cl-letf (((symbol-function 'display-buffer) (lambda (&rest _) (setq shown t))) + ((symbol-function 'pop-to-buffer) (lambda (&rest _) (setq shown t)))) + (with-temp-buffer + (pearl--surface-buffer (current-buffer)) + (should-not shown))))) + +(ert-deftest test-pearl-surface-buffer-shows-when-buried () + "A live, un-displayed buffer is shown via `display-buffer' by default." + (let ((pearl-surface-buffer t) (pearl-surface-select-window nil) (shown nil)) + (cl-letf (((symbol-function 'get-buffer-window) (lambda (&rest _) nil)) + ((symbol-function 'display-buffer) (lambda (b &rest _) (setq shown b))) + ((symbol-function 'pop-to-buffer) (lambda (&rest _) (setq shown 'pop)))) + (with-temp-buffer + (pearl--surface-buffer (current-buffer)) + (should (eq shown (current-buffer))))))) + +(ert-deftest test-pearl-surface-buffer-skips-when-already-shown () + "A buffer already visible in some window is left alone." + (let ((pearl-surface-buffer t) (shown nil)) + (cl-letf (((symbol-function 'get-buffer-window) (lambda (&rest _) 'a-window)) + ((symbol-function 'display-buffer) (lambda (&rest _) (setq shown t))) + ((symbol-function 'pop-to-buffer) (lambda (&rest _) (setq shown t)))) + (with-temp-buffer + (pearl--surface-buffer (current-buffer)) + (should-not shown))))) + +(ert-deftest test-pearl-surface-buffer-select-window-uses-pop-to-buffer () + "With `pearl-surface-select-window' non-nil, focus follows via `pop-to-buffer'." + (let ((pearl-surface-buffer t) (pearl-surface-select-window t) (how nil)) + (cl-letf (((symbol-function 'get-buffer-window) (lambda (&rest _) nil)) + ((symbol-function 'display-buffer) (lambda (&rest _) (setq how 'display))) + ((symbol-function 'pop-to-buffer) (lambda (&rest _) (setq how 'pop)))) + (with-temp-buffer + (pearl--surface-buffer (current-buffer)) + (should (eq how 'pop)))))) + +(ert-deftest test-pearl-surface-buffer-dead-buffer-is-noop () + "A killed buffer is never surfaced." + (let ((pearl-surface-buffer t) (shown nil) (buf (generate-new-buffer "x"))) + (kill-buffer buf) + (cl-letf (((symbol-function 'display-buffer) (lambda (&rest _) (setq shown t))) + ((symbol-function 'pop-to-buffer) (lambda (&rest _) (setq shown t)))) + (pearl--surface-buffer buf) + (should-not shown)))) + +(provide 'test-pearl-surface) +;;; test-pearl-surface.el ends here |
