@@ -33,6 +33,54 @@ public void MinMax_Ok()
3333 } ) ;
3434 }
3535
36+ [ Fact ]
37+ public async Task IsEditable_Ok ( )
38+ {
39+ var cut = Context . RenderComponent < MultiSelect < string > > ( pb =>
40+ {
41+ pb . Add ( a => a . Max , 2 ) ;
42+ pb . Add ( a => a . Items , new List < SelectedItem >
43+ {
44+ new ( "1" , "Test 1" ) ,
45+ new ( "2" , "Test 2" ) ,
46+ new ( "3" , "Test 3" ) ,
47+ new ( "4" , "Test 4" ) ,
48+ } ) ;
49+ } ) ;
50+ Assert . DoesNotContain ( "class=\" multi-select-input\" " , cut . Markup ) ;
51+
52+ cut . SetParametersAndRender ( pb =>
53+ {
54+ pb . Add ( a => a . IsEditable , true ) ;
55+ } ) ;
56+ Assert . Contains ( "class=\" multi-select-input\" " , cut . Markup ) ;
57+ Assert . DoesNotContain ( "data-bb-trigger-key" , cut . Markup ) ;
58+
59+ cut . SetParametersAndRender ( pb =>
60+ {
61+ pb . Add ( a => a . EditSubmitKey , EditSubmitKey . Space ) ;
62+ } ) ;
63+ Assert . Contains ( "data-bb-trigger-key=\" space\" " , cut . Markup ) ;
64+
65+ await cut . InvokeAsync ( ( ) => cut . Instance . TriggerEditTag ( "123" ) ) ;
66+ Assert . Equal ( "123" , cut . Instance . Value ) ;
67+
68+ await cut . InvokeAsync ( ( ) => cut . Instance . TriggerEditTag ( "123" ) ) ;
69+ Assert . Equal ( "123" , cut . Instance . Value ) ;
70+
71+ cut . SetParametersAndRender ( pb =>
72+ {
73+ pb . Add ( a => a . OnEditCallback , async v =>
74+ {
75+ await Task . Delay ( 10 ) ;
76+ return new SelectedItem ( "test" , "456" ) ;
77+ } ) ;
78+ } ) ;
79+ await cut . InvokeAsync ( ( ) => cut . Instance . TriggerEditTag ( "456" ) ) ;
80+ Assert . Equal ( "123,test" , cut . Instance . Value ) ;
81+ Assert . DoesNotContain ( "class=\" multi-select-input\" " , cut . Markup ) ;
82+ }
83+
3684 [ Fact ]
3785 public void IsFixedHeight_Ok ( )
3886 {
0 commit comments