@@ -90,29 +90,29 @@ export function main() {
9090 } ) ;
9191 } ) ;
9292
93- it ( 'should be updated correctly if the ngModel value is cleared.' , ( done ) => {
94- var template = '<div><ig-combo [(widgetId)]="comboID" [(options)]="options" [(ngModel)]="combo.value1" [dataSource]="northwind"></ig-combo></div>' ;
95- TestBed . overrideComponent ( TestComponent , {
96- set : {
97- template : template
98- }
99- } ) ;
93+ it ( 'should be updated correctly if the ngModel value is cleared.' , ( done ) => {
94+ var template = '<div><ig-combo [(widgetId)]="comboID" [(options)]="options" [(ngModel)]="combo.value1" [dataSource]="northwind"></ig-combo></div>' ;
95+ TestBed . overrideComponent ( TestComponent , {
96+ set : {
97+ template : template
98+ }
99+ } ) ;
100100 TestBed . compileComponents ( ) . then ( ( ) => {
101101 let fixture = TestBed . createComponent ( TestComponent ) ;
102102 fixture . detectChanges ( ) ;
103- fixture . componentInstance . combo . value1 = 1 ;
104- fixture . detectChanges ( ) ;
103+ fixture . componentInstance . combo . value1 = 1 ;
104+ fixture . detectChanges ( ) ;
105105 setTimeout ( function ( ) {
106- //clear
107- $ ( "#combo1" ) . parents ( "ig-combo" ) . find ( ".ui-igcombo-clearicon" ) . click ( ) ;
108- fixture . detectChanges ( ) ;
109- setTimeout ( function ( ) {
110- expect ( fixture . componentInstance . combo . value1 ) . toBeNull ( ) ;
111- done ( ) ;
112- } , 10 ) ;
106+ //clear
107+ $ ( "#combo1" ) . parents ( "ig-combo" ) . find ( ".ui-igcombo-clearicon" ) . click ( ) ;
108+ fixture . detectChanges ( ) ;
109+ setTimeout ( function ( ) {
110+ expect ( fixture . componentInstance . combo . value1 ) . toBeNull ( ) ;
111+ done ( ) ;
112+ } , 10 ) ;
113113 } , 10 ) ;
114114 } ) ;
115- } ) ;
115+ } ) ;
116116
117117 it ( 'should be updated correctly if the ngModel value is cleared when multiple selection.' , ( done ) => {
118118 var template = '<div><ig-combo [(widgetId)]="comboID" [(options)]="optionsMultipleSelection" [(ngModel)]="combo.value1" [dataSource]="northwind"></ig-combo></div>' ;
@@ -122,21 +122,40 @@ export function main() {
122122 }
123123 } ) ;
124124 TestBed . compileComponents ( ) . then ( ( ) => {
125- let fixture = TestBed . createComponent ( TestComponent ) ;
126- fixture . detectChanges ( ) ;
127- fixture . componentInstance . combo . value1 = 1 ;
128- fixture . detectChanges ( ) ;
129- setTimeout ( function ( ) {
130- //clear
131- $ ( "#combo1" ) . parents ( "ig-combo" ) . find ( ".ui-igcombo-clearicon" ) . click ( ) ;
125+ let fixture = TestBed . createComponent ( TestComponent ) ;
132126 fixture . detectChanges ( ) ;
133- setTimeout ( function ( ) {
134- expect ( fixture . componentInstance . combo . value1 instanceof Array && fixture . componentInstance . combo . value1 . length === 0 ) . toBeTruthy ( ) ;
135- done ( ) ;
127+ fixture . componentInstance . combo . value1 = 1 ;
128+ fixture . detectChanges ( ) ;
129+ setTimeout ( function ( ) {
130+ //clear
131+ $ ( "#combo1" ) . parents ( "ig-combo" ) . find ( ".ui-igcombo-clearicon" ) . click ( ) ;
132+ fixture . detectChanges ( ) ;
133+ setTimeout ( function ( ) {
134+ expect ( fixture . componentInstance . combo . value1 instanceof Array && fixture . componentInstance . combo . value1 . length === 0 ) . toBeTruthy ( ) ;
135+ done ( ) ;
136+ } , 10 ) ;
136137 } , 10 ) ;
137- } , 10 ) ;
138+ } ) ;
139+ } ) ;
140+
141+ it ( 'should apply ngModel when multiple selection and no valueKey set.' , ( done ) => {
142+ var template = '<div><ig-combo [(widgetId)]="comboID" [options]="{multiSelection: {enabled: true, showCheckboxes: true}}" [(ngModel)]="val" [dataSource]="[\'foo\', \'bar\', \'bas\']"></ig-combo></div>' ;
143+ TestBed . overrideComponent ( TestComponent , {
144+ set : {
145+ template : template
146+ }
147+ } ) ;
148+ TestBed . compileComponents ( ) . then ( ( ) => {
149+ let fixture = TestBed . createComponent ( TestComponent ) ;
150+ fixture . detectChanges ( ) ;
151+ var elem = $ ( "#combo1" ) . igCombo ( "itemsFromIndex" , 0 ) [ "element" ] ;
152+ $ ( "#combo1" ) . igCombo ( "select" , elem , { } , true ) ;
153+ fixture . detectChanges ( ) ;
154+ expect ( fixture . componentInstance . val . length ) . toBe ( 1 ) ;
155+ expect ( fixture . componentInstance . val [ 0 ] ) . toBe ( "foo" ) ;
156+ done ( ) ;
157+ } ) ;
138158 } ) ;
139- } ) ;
140159
141160 it ( 'the ngModel should be updated correctly if the combo selection is updated' , ( done ) => {
142161 var template = '<div><ig-combo [(widgetId)]="comboID" [(options)]="options" [(ngModel)]="combo.value1" [dataSource]="northwind"></ig-combo></div>' ;
@@ -220,19 +239,19 @@ export function main() {
220239 fixture . detectChanges ( ) ;
221240 expect ( $ ( "#combo1" ) . igCombo ( "value" ) ) . toBe ( fixture . componentInstance . combo . value1 ) ;
222241 expect ( $ ( "#combo1" ) . val ( ) )
223- . toBe ( fixture . componentInstance . northwind [ fixture . componentInstance . combo . value1 - 1 ] . ProductName ) ;
242+ . toBe ( fixture . componentInstance . northwind [ fixture . componentInstance . combo . value1 - 1 ] . ProductName ) ;
224243 done ( ) ;
225244 } , 10 ) ;
226245 } ) ;
227246 } ) ;
228247
229248 it ( 'should initialize correctly when datasource is remote' , ( done ) => {
230249 $ [ 'mockjax' ] ( {
231- url : "myURL/Northwind" ,
232- contentType : 'application/json' ,
233- dataType : 'json' ,
234- responseText : '[{"ProductID": 1, "ProductName": "Chai"}]'
235- } ) ;
250+ url : "myURL/Northwind" ,
251+ contentType : 'application/json' ,
252+ dataType : 'json' ,
253+ responseText : '[{"ProductID": 1, "ProductName": "Chai"}]'
254+ } ) ;
236255 var template = '<div><ig-combo [(widgetId)]="comboID" [(options)]="options2" [(ngModel)]="combo.value1"></ig-combo></div>' ;
237256 TestBed . overrideComponent ( TestComponent , {
238257 set : {
@@ -262,6 +281,7 @@ class TestComponent {
262281 public combo : any ;
263282 private comboID : string
264283 public data : Array < any > = [ ] ;
284+ public val = [ ] ;
265285 @ViewChild ( Infragistics . IgComboComponent ) public viewChild : Infragistics . IgComboComponent ;
266286
267287 constructor ( ) {
0 commit comments