@@ -1431,6 +1431,45 @@ describe('Combo', () => {
14311431 } ) ;
14321432 } ) ;
14331433
1434+ describe ( 'Form integration with delayed data' , ( ) => {
1435+ const spec = createFormAssociatedTestBed < IgcComboComponent < City > > ( html `
1436+ < igc-combo name ="combo " value-key ="id " display-key ="name "> </ igc-combo >
1437+ ` ) ;
1438+
1439+ function initDataDefaultValue ( single = false ) {
1440+ spec . element . singleSelect = single ;
1441+ // assign data after init to simulate async data
1442+ spec . element . data = cities ;
1443+ spec . element . defaultValue = value ;
1444+ }
1445+
1446+ beforeEach ( async ( ) => {
1447+ await spec . setup ( IgcComboComponent . tagName ) ;
1448+ } ) ;
1449+
1450+ it ( 'correct initial state (single)' , ( ) => {
1451+ initDataDefaultValue ( true ) ;
1452+ spec . assertIsPristine ( ) ;
1453+ expect ( spec . element . value ) . to . eql ( [ first ( value ) ] ) ;
1454+ } ) ;
1455+
1456+ it ( 'correct initial state (multiple)' , ( ) => {
1457+ initDataDefaultValue ( ) ;
1458+ spec . assertIsPristine ( ) ;
1459+ expect ( spec . element . value ) . to . eql ( value ) ;
1460+ } ) ;
1461+
1462+ it ( 'is correctly submitted (single)' , ( ) => {
1463+ initDataDefaultValue ( true ) ;
1464+ spec . assertSubmitHasValue ( first ( value ) ) ;
1465+ } ) ;
1466+
1467+ it ( 'is correctly submitted (multiple)' , ( ) => {
1468+ initDataDefaultValue ( ) ;
1469+ spec . assertSubmitHasValues ( value ) ;
1470+ } ) ;
1471+ } ) ;
1472+
14341473 describe ( 'Validation' , ( ) => {
14351474 const spec = createFormAssociatedTestBed < IgcComboComponent < City > > ( html `
14361475 < igc-combo
0 commit comments