@@ -106,8 +106,53 @@ describe('neocrush.prompts', function()
106106 end )
107107
108108 describe (' execute' , function ()
109- -- Note: execute() calls terminal functions which we can't easily test
110- -- without mocking. Test the error case for unknown prompts.
109+ it (' should substitute prompt arguments' , function ()
110+ prompts .register {
111+ Review = ' review PR #%s' ,
112+ }
113+ local sent
114+ local original_send = prompts .send
115+ prompts .send = function (text )
116+ sent = text
117+ end
118+
119+ prompts .execute (' Review' , ' 12' )
120+
121+ prompts .send = original_send
122+ eq (' review PR #12' , sent )
123+ end )
124+
125+ it (' should substitute prompt arguments containing percent signs' , function ()
126+ prompts .register {
127+ Note = ' summarize %s' ,
128+ }
129+ local sent
130+ local original_send = prompts .send
131+ prompts .send = function (text )
132+ sent = text
133+ end
134+
135+ prompts .execute (' Note' , ' 50% done' )
136+
137+ prompts .send = original_send
138+ eq (' summarize 50% done' , sent )
139+ end )
140+
141+ it (' should append arguments when template has no placeholder' , function ()
142+ prompts .register {
143+ Simple = ' explain' ,
144+ }
145+ local sent
146+ local original_send = prompts .send
147+ prompts .send = function (text )
148+ sent = text
149+ end
150+
151+ prompts .execute (' Simple' , ' this code' )
152+
153+ prompts .send = original_send
154+ eq (' explain this code' , sent )
155+ end )
111156
112157 it (' should error for unknown prompt' , function ()
113158 local notified = false
0 commit comments