@@ -1688,14 +1688,33 @@ describe('PoComboComponent - with service:', () => {
1688
1688
expect ( component . controlComboVisibility ) . toHaveBeenCalledWith ( false ) ;
1689
1689
} ) ;
1690
1690
1691
- it ( 'shouldn`t call updateOptionByFilteredValue if not exists selectedValue ' , ( ) => {
1691
+ it ( 'should call updateOptionByFilteredValue if selectedValue is different of value parameter ' , ( ) => {
1692
1692
component . service = getFakeService ( [ { label : 'label' , value : 1 } ] ) ;
1693
1693
component . selectedValue = 'po' ;
1694
1694
1695
1695
spyOn ( component , 'updateOptionByFilteredValue' ) ;
1696
-
1697
1696
component . getObjectByValue ( 'value' ) ;
1698
1697
1698
+ expect ( component . updateOptionByFilteredValue ) . toHaveBeenCalled ( ) ;
1699
+ } ) ;
1700
+
1701
+ it ( 'shouldn`t call updateOptionByFilteredValue if selectedValue exists and is equal to the value' , ( ) => {
1702
+ component . service = getFakeService ( [ { label : 'label' , value : 1 } ] ) ;
1703
+ component . selectedValue = 1 ;
1704
+
1705
+ spyOn ( component , 'updateOptionByFilteredValue' ) ;
1706
+
1707
+ component . getObjectByValue ( 1 ) ;
1708
+ expect ( component . updateOptionByFilteredValue ) . not . toHaveBeenCalled ( ) ;
1709
+ } ) ;
1710
+
1711
+ it ( 'should not call updateOptionByFilteredValue if the selectedOption label exists and is equal to the value' , ( ) => {
1712
+ component . service = getFakeService ( [ { label : 'label' , value : 1 } ] ) ;
1713
+ component . selectedValue = 1 ;
1714
+ component . selectedOption = { label : 'label' , value : 1 } ;
1715
+
1716
+ spyOn ( component , 'updateOptionByFilteredValue' ) ;
1717
+ component . getObjectByValue ( 'label' ) ;
1699
1718
expect ( component . updateOptionByFilteredValue ) . not . toHaveBeenCalled ( ) ;
1700
1719
} ) ;
1701
1720
@@ -1789,22 +1808,6 @@ describe('PoComboComponent - with service:', () => {
1789
1808
expect ( fakeThis . service . getObjectByValue ) . toHaveBeenCalledWith ( param , filterParams ) ;
1790
1809
} ) ;
1791
1810
1792
- it ( 'getObjectByValue: should not call PoComboFilterService.getObjectByValue() if selectedValue is valid' , ( ) => {
1793
- const param = 'value' ;
1794
- const fakeThis = {
1795
- service : {
1796
- getObjectByValue : ( ) => { }
1797
- } ,
1798
- selectedValue : 'valid'
1799
- } ;
1800
-
1801
- spyOn ( fakeThis . service , 'getObjectByValue' ) ;
1802
-
1803
- component . getObjectByValue . apply ( fakeThis , [ param ] ) ;
1804
-
1805
- expect ( fakeThis . service . getObjectByValue ) . not . toHaveBeenCalled ( ) ;
1806
- } ) ;
1807
-
1808
1811
it ( 'ngAfterViewInit: should call `focus` if `autoFocus` is true.' , ( ) => {
1809
1812
component . autoFocus = true ;
1810
1813
0 commit comments