File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
packages/controls/test/src Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -89,4 +89,31 @@ describe('ComboboxView', function () {
89
89
expect ( el . getAttribute ( 'value' ) ) . to . equal ( input [ i ] ) ;
90
90
}
91
91
} ) ;
92
+
93
+ it ( 'updates datalist children when options are updated' , function ( ) {
94
+ this . model . set ( {
95
+ value : 'ABC' ,
96
+ options : [ 'option1' , 'option2' , 'option3' ] ,
97
+ ensure_option : true ,
98
+ } ) ;
99
+ const options = { model : this . model } ;
100
+ const view = new widgets . ComboboxView ( options ) ;
101
+ view . render ( ) ;
102
+ expect ( view . datalist ! . children . length ) . to . equal ( 3 ) ;
103
+ for ( let i = 0 ; i < view . datalist ! . children . length ; ++ i ) {
104
+ const el = view . datalist ! . children [ i ] ;
105
+ expect ( el . tagName . toLowerCase ( ) ) . to . equal ( 'option' ) ;
106
+ expect ( el . getAttributeNames ( ) ) . to . eqls ( [ 'value' ] ) ;
107
+ expect ( el . getAttribute ( 'value' ) ) . to . equal ( `option${ i + 1 } ` ) ;
108
+ }
109
+
110
+ this . model . set ( { options : [ 'option4' , 'option5' ] } ) ;
111
+ expect ( view . datalist ! . children . length ) . to . equal ( 2 ) ;
112
+ for ( let i = 0 ; i < view . datalist ! . children . length ; ++ i ) {
113
+ const el = view . datalist ! . children [ i ] ;
114
+ expect ( el . tagName . toLowerCase ( ) ) . to . equal ( 'option' ) ;
115
+ expect ( el . getAttributeNames ( ) ) . to . eqls ( [ 'value' ] ) ;
116
+ expect ( el . getAttribute ( 'value' ) ) . to . equal ( `option${ i + 4 } ` ) ;
117
+ }
118
+ } ) ;
92
119
} ) ;
You can’t perform that action at this time.
0 commit comments