@@ -559,15 +559,54 @@ describe('my app', function() {
559559 } ) ;
560560
561561 describe ( "Combo" , function ( ) {
562+ var scope = 'angular.element("#combo1").scope()' ,
563+ combo = '$("#combo1")' ,
564+ combo2 = '$("#combo2")' ;
565+
562566 it ( "should be initialized" , function ( ) {
563567 util . resetNorthwindScope ( ) ;
564568 util . isInitialized ( 'combo1' , 'igCombo' ) ;
565569 util . isInitialized ( 'combo2' , 'igCombo' ) ;
566570 } ) ;
567571
568- it ( "should update its view when model is changed" , function ( ) {
572+ it ( "should be initialized with a value from the scope" , function ( ) {
573+ expect ( util . getResult ( combo + '.igCombo("value")' ) ) . toBe ( 20 ) ;
574+ expect ( util . getResult ( combo2 + '.igCombo("value").length' ) ) . toBe ( 0 ) ;
575+ } ) ;
576+
577+ it ( "should update its value when model is changed" , function ( ) {
578+ util . executeScript ( scope + '.combo.value1 = 2;' ) ;
579+ util . executeScript ( scope + '.$apply();' ) ;
580+ expect ( util . getResult ( combo + '.igCombo("value")' ) ) . toBe ( 2 ) ;
581+ expect ( util . getResult ( '$("#combo1").val()' ) ) . toBe ( "Chang" ) ;
569582 util . executeScript ( '$("input[ng-model=\'combo.value1\']:eq(0)").val("5").trigger("input");' ) ;
570583 expect ( util . getResult ( '$("#combo1").val()' ) ) . toBe ( "Chef Anton's Gumbo Mix" ) ;
584+
585+ util . executeScript ( scope + '.combo.value2 = [1];' ) ;
586+ util . executeScript ( scope + '.$apply();' ) ;
587+ expect ( util . getResult ( combo2 + '.igCombo("value")[0]' ) ) . toBe ( 1 ) ;
588+ expect ( util . getResult ( '$("#combo2").val()' ) ) . toBe ( 'Chai' ) ;
589+ } ) ;
590+
591+ it ( "should set model on clear" , function ( ) {
592+ util . executeScript ( combo2 + ".igCombo('comboWrapper').find('.ui-igcombo-clear').click();" ) ;
593+ expect ( util . getResult ( scope + '.combo.value2.length' ) ) . toBe ( 0 ) ;
594+ } ) ;
595+
596+ it ( "should update model on change with multi selection" , function ( ) {
597+ util . executeScript ( combo2 + ".igCombo('comboWrapper').find('.ui-igcombo-button').click();" ) ;
598+ util . executeScript ( combo2 + ".igCombo('dropDown').find('li').not('.ui-helper-hidden').eq(0).trigger($.Event('mousedown', { which: 1 })).trigger($.Event('mouseup', { which: 1 }));" ) ;
599+ util . executeScript ( combo2 + ".igCombo('dropDown').find('li').not('.ui-helper-hidden').eq(1).trigger($.Event('mousedown', { which: 1 })).trigger($.Event('mouseup', { which: 1 }));" ) ;
600+ expect ( util . getResult ( scope + '.combo.value2.toString()' ) ) . toBe ( '1,2' ) ;
601+ } ) ;
602+
603+ it ( "should update model on change of combo input" , function ( ) {
604+ util . executeScript ( combo + ".focus();" ) ;
605+ //check scope value remains unchanged during search entry
606+ expect ( util . getResult ( 'typeInInputWrap("Chang", ' + combo + ', "combo.value1");' ) ) . toBe ( false ) ;
607+ // wait for sleep resolve:
608+ expect ( browser . driver . sleep ( 250 ) ) . toBe ( undefined ) ; //util.getResult(combo + '.igCombo("option", "delayInputChangeProcessing");')
609+ expect ( util . getResult ( scope + '.combo.value1' ) ) . toBe ( 2 ) ;
571610 } ) ;
572611 } ) ;
573612
0 commit comments