@@ -251,6 +251,53 @@ def test_generic_autocomplete_emojis(self, write_box, text,
251
251
typeahead_string = write_box .generic_autocomplete (text , state )
252
252
assert typeahead_string == required_typeahead
253
253
254
+ @pytest .mark .parametrize (['text' , 'state' , 'to_pin' , 'matching_streams' ], [
255
+ ('' , 1 , [], ['Secret stream' , 'Some general stream' ,
256
+ 'Stream 1' , 'Stream 2' ]),
257
+ ('' , 1 , [['Stream 2' ]], ['Stream 2' , 'Secret stream' ,
258
+ 'Some general stream' , 'Stream 1' ]),
259
+ ('St' , 1 , [], ['Stream 1' , 'Stream 2' , 'Secret stream' ,
260
+ 'Some general stream' ]),
261
+ ('St' , 1 , [['Stream 2' ]], ['Stream 2' , 'Stream 1' ,
262
+ 'Secret stream' , 'Some general stream' ]),
263
+ ], ids = [
264
+ 'no_search_text' ,
265
+ 'no_search_text_with_pinned_stream' ,
266
+ 'single_word_search_text' ,
267
+ 'single_word_search_text_with_pinned_stream' ,
268
+ ])
269
+ def test__stream_box_autocomplete (self , mocker , write_box , text , state ,
270
+ to_pin , matching_streams ):
271
+ for stream in to_pin :
272
+ write_box .view .unpinned_streams .remove (stream )
273
+ write_box .view .pinned_streams = to_pin
274
+ _process_typeaheads = mocker .patch (BOXES
275
+ + '.WriteBox._process_typeaheads' )
276
+
277
+ write_box ._stream_box_autocomplete (text , state )
278
+
279
+ _process_typeaheads .assert_called_once_with (matching_streams , state ,
280
+ matching_streams )
281
+
282
+ @pytest .mark .parametrize ('text, expected_text' , [
283
+ ('Som' , 'Some general stream' ),
284
+ pytest .param ('Some gen' , 'Some general stream' ,
285
+ marks = pytest .mark .xfail (
286
+ reason = "Lacking urwid-readline support" )),
287
+ ])
288
+ def test__stream_box_autocomplete_with_spaces (self , mocker , write_box ,
289
+ text , expected_text ):
290
+ write_box .stream_box_view (1000 )
291
+ write_box .contents [0 ][0 ][0 ].set_edit_text (text )
292
+ write_box .contents [0 ][0 ][0 ].set_edit_pos (len (text ))
293
+ write_box .focus_position = 0
294
+ write_box .contents [0 ][0 ].focus_col = 0
295
+ size = (20 ,)
296
+
297
+ write_box .keypress (size , keys_for_command ('AUTOCOMPLETE' ).pop ())
298
+
299
+ assert write_box .contents [0 ][0 ][0 ].edit_text == expected_text
300
+
254
301
@pytest .mark .parametrize (['suggestions' , 'state' , 'expected_state' ,
255
302
'expected_typeahead' , 'is_truncated' ], [
256
303
(['zero' , 'one' , 'two' ], 1 , 1 , '*one*' , False ),
0 commit comments