@@ -79,6 +79,16 @@ const hkSuggestion = {
7979 score : 100 ,
8080} ;
8181
82+ const bseSuggestion = {
83+ canonicalCode : "920493.BJ" ,
84+ displayCode : "920493" ,
85+ nameZh : "示例北交所股票" ,
86+ market : "BSE" as const ,
87+ matchType : "exact" as const ,
88+ matchField : "code" as const ,
89+ score : 100 ,
90+ } ;
91+
8292describe ( 'StockAutocomplete' , ( ) => {
8393 const mockOnChange = vi . fn ( ) ;
8494 const mockOnSubmit = vi . fn ( ) ;
@@ -416,6 +426,40 @@ describe('StockAutocomplete', () => {
416426 expect ( mockOnChange ) . toHaveBeenCalledWith ( '00700' ) ;
417427 expect ( mockOnSubmit ) . toHaveBeenCalledWith ( '00700.HK' , '腾讯控股' , 'autocomplete' ) ;
418428 } ) ;
429+
430+ it ( 'submits the highlighted BSE suggestion using the canonical .BJ code' , ( ) => {
431+ autocompleteHookImpl = ( ) => ( {
432+ query : '' ,
433+ setQuery : vi . fn ( ) ,
434+ suggestions : [ bseSuggestion ] ,
435+ isOpen : true ,
436+ highlightedIndex : 0 ,
437+ setHighlightedIndex : vi . fn ( ) ,
438+ highlightPrevious : vi . fn ( ) ,
439+ highlightNext : vi . fn ( ) ,
440+ handleSelect : vi . fn ( ) ,
441+ close : vi . fn ( ) ,
442+ reset : vi . fn ( ) ,
443+ isComposing : false ,
444+ setIsComposing : vi . fn ( ) ,
445+ runtimeFallback : false ,
446+ error : null ,
447+ } ) ;
448+
449+ render (
450+ < StockAutocomplete
451+ value = "920493"
452+ onChange = { mockOnChange }
453+ onSubmit = { mockOnSubmit }
454+ />
455+ ) ;
456+
457+ const input = screen . getByDisplayValue ( '920493' ) ;
458+ fireEvent . keyDown ( input , { key : 'Enter' } ) ;
459+
460+ expect ( mockOnChange ) . toHaveBeenCalledWith ( '920493' ) ;
461+ expect ( mockOnSubmit ) . toHaveBeenCalledWith ( '920493.BJ' , '示例北交所股票' , 'autocomplete' ) ;
462+ } ) ;
419463 } ) ;
420464
421465 describe ( 'runtime boundary' , ( ) => {
0 commit comments