I am trying to write a test around a flow that uses transient. Here is the sample code:
;; -*- lexical-binding: t; coding: utf-8 -*-
(require 'transient)
(require 'buttercup)
(require 'with-simulated-input)
(defun ogt-print-a () (interactive) (insert "a"))
(defun ogt-print-b () (interactive) (insert "b"))
(transient-define-prefix ogt-transient ()
["X"
("f" "test f" ogt-print-a)
("g" "test g" ogt-print-b)])
(describe
"Transient"
(it "takes keys"
(with-temp-buffer
(with-simulated-input "f"
(ogt-transient)
(expect (buffer-string)
:to-match "a")))))
Now, I would expect the library "with-simulated-input" to press "f" when the transient comes up and to have that put "a" in the temp buffer, as that's what the function called should do.
However, it does not add anything, and the temp buffer remains empty.
I could use some help, I really would like to know for a fact that my package works.
I wondered if with-temp-buffer
could be the culprit but changing this to a set-buffer
call did not seem to help.