@@ -1653,9 +1653,9 @@ describe('MatAutocomplete', () => {
1653
1653
1654
1654
describe ( 'Fallback positions' , ( ) => {
1655
1655
it ( 'should use below positioning by default' , fakeAsync ( ( ) => {
1656
- let fixture = createComponent ( SimpleAutocomplete ) ;
1656
+ const fixture = createComponent ( SimpleAutocomplete ) ;
1657
1657
fixture . detectChanges ( ) ;
1658
- let inputReference =
1658
+ const inputReference =
1659
1659
fixture . debugElement . query ( By . css ( '.mat-form-field-flex' ) ) ! . nativeElement ;
1660
1660
1661
1661
fixture . componentInstance . trigger . openPanel ( ) ;
@@ -1673,16 +1673,16 @@ describe('MatAutocomplete', () => {
1673
1673
} ) ) ;
1674
1674
1675
1675
it ( 'should reposition the panel on scroll' , ( ) => {
1676
- let scrolledSubject = new Subject ( ) ;
1677
- let spacer = document . createElement ( 'div' ) ;
1678
- let fixture = createComponent ( SimpleAutocomplete , [ {
1676
+ const scrolledSubject = new Subject ( ) ;
1677
+ const spacer = document . createElement ( 'div' ) ;
1678
+ const fixture = createComponent ( SimpleAutocomplete , [ {
1679
1679
provide : ScrollDispatcher ,
1680
1680
useValue : { scrolled : ( ) => scrolledSubject }
1681
1681
} ] ) ;
1682
1682
1683
1683
fixture . detectChanges ( ) ;
1684
1684
1685
- let inputReference =
1685
+ const inputReference =
1686
1686
fixture . debugElement . query ( By . css ( '.mat-form-field-flex' ) ) ! . nativeElement ;
1687
1687
spacer . style . height = '1000px' ;
1688
1688
document . body . appendChild ( spacer ) ;
@@ -1706,9 +1706,9 @@ describe('MatAutocomplete', () => {
1706
1706
} ) ;
1707
1707
1708
1708
it ( 'should fall back to above position if panel cannot fit below' , fakeAsync ( ( ) => {
1709
- let fixture = createComponent ( SimpleAutocomplete ) ;
1709
+ const fixture = createComponent ( SimpleAutocomplete ) ;
1710
1710
fixture . detectChanges ( ) ;
1711
- let inputReference =
1711
+ const inputReference =
1712
1712
fixture . debugElement . query ( By . css ( '.mat-form-field-flex' ) ) ! . nativeElement ;
1713
1713
1714
1714
// Push the autocomplete trigger down so it won't have room to open "below"
@@ -1731,11 +1731,11 @@ describe('MatAutocomplete', () => {
1731
1731
} ) ) ;
1732
1732
1733
1733
it ( 'should allow the panel to expand when the number of results increases' , fakeAsync ( ( ) => {
1734
- let fixture = createComponent ( SimpleAutocomplete ) ;
1734
+ const fixture = createComponent ( SimpleAutocomplete ) ;
1735
1735
fixture . detectChanges ( ) ;
1736
1736
1737
- let inputEl = fixture . debugElement . query ( By . css ( 'input' ) ) ! . nativeElement ;
1738
- let inputReference =
1737
+ const inputEl = fixture . debugElement . query ( By . css ( 'input' ) ) ! . nativeElement ;
1738
+ const inputReference =
1739
1739
fixture . debugElement . query ( By . css ( '.mat-form-field-flex' ) ) ! . nativeElement ;
1740
1740
1741
1741
// Push the element down so it has a little bit of space, but not enough to render.
@@ -1752,7 +1752,7 @@ describe('MatAutocomplete', () => {
1752
1752
zone . simulateZoneExit ( ) ;
1753
1753
1754
1754
let panel = overlayContainerElement . querySelector ( '.cdk-overlay-pane' ) ! ;
1755
- let initialPanelHeight = panel . getBoundingClientRect ( ) . height ;
1755
+ const initialPanelHeight = panel . getBoundingClientRect ( ) . height ;
1756
1756
1757
1757
fixture . componentInstance . trigger . closePanel ( ) ;
1758
1758
fixture . detectChanges ( ) ;
@@ -1773,11 +1773,11 @@ describe('MatAutocomplete', () => {
1773
1773
} ) ) ;
1774
1774
1775
1775
it ( 'should align panel properly when filtering in "above" position' , fakeAsync ( ( ) => {
1776
- let fixture = createComponent ( SimpleAutocomplete ) ;
1776
+ const fixture = createComponent ( SimpleAutocomplete ) ;
1777
1777
fixture . detectChanges ( ) ;
1778
1778
1779
- let input = fixture . debugElement . query ( By . css ( 'input' ) ) ! . nativeElement ;
1780
- let inputReference =
1779
+ const input = fixture . debugElement . query ( By . css ( 'input' ) ) ! . nativeElement ;
1780
+ const inputReference =
1781
1781
fixture . debugElement . query ( By . css ( '.mat-form-field-flex' ) ) ! . nativeElement ;
1782
1782
1783
1783
// Push the autocomplete trigger down so it won't have room to open "below"
@@ -1802,13 +1802,13 @@ describe('MatAutocomplete', () => {
1802
1802
1803
1803
it ( 'should fall back to above position when requested if options are added while ' +
1804
1804
'the panel is open' , fakeAsync ( ( ) => {
1805
- let fixture = createComponent ( SimpleAutocomplete ) ;
1805
+ const fixture = createComponent ( SimpleAutocomplete ) ;
1806
1806
fixture . componentInstance . states = fixture . componentInstance . states . slice ( 0 , 1 ) ;
1807
1807
fixture . componentInstance . filteredStates = fixture . componentInstance . states . slice ( ) ;
1808
1808
fixture . detectChanges ( ) ;
1809
1809
1810
- let inputEl = fixture . debugElement . query ( By . css ( 'input' ) ) ! . nativeElement ;
1811
- let inputReference =
1810
+ const inputEl = fixture . debugElement . query ( By . css ( 'input' ) ) ! . nativeElement ;
1811
+ const inputReference =
1812
1812
fixture . debugElement . query ( By . css ( '.mat-form-field-flex' ) ) ! . nativeElement ;
1813
1813
1814
1814
// Push the element down so it has a little bit of space, but not enough to render.
@@ -1820,7 +1820,7 @@ describe('MatAutocomplete', () => {
1820
1820
zone . simulateZoneExit ( ) ;
1821
1821
fixture . detectChanges ( ) ;
1822
1822
1823
- let panel = overlayContainerElement . querySelector ( '.mat-autocomplete-panel' ) ! ;
1823
+ const panel = overlayContainerElement . querySelector ( '.mat-autocomplete-panel' ) ! ;
1824
1824
let inputRect = inputReference . getBoundingClientRect ( ) ;
1825
1825
let panelRect = panel . getBoundingClientRect ( ) ;
1826
1826
@@ -1846,17 +1846,17 @@ describe('MatAutocomplete', () => {
1846
1846
} ) ) ;
1847
1847
1848
1848
it ( 'should not throw if a panel reposition is requested while the panel is closed' , ( ) => {
1849
- let fixture = createComponent ( SimpleAutocomplete ) ;
1849
+ const fixture = createComponent ( SimpleAutocomplete ) ;
1850
1850
fixture . detectChanges ( ) ;
1851
1851
1852
1852
expect ( ( ) => fixture . componentInstance . trigger . updatePosition ( ) ) . not . toThrow ( ) ;
1853
1853
} ) ;
1854
1854
1855
1855
it ( 'should be able to force below position even if there is not enough space' , fakeAsync ( ( ) => {
1856
- let fixture = createComponent ( SimpleAutocomplete ) ;
1856
+ const fixture = createComponent ( SimpleAutocomplete ) ;
1857
1857
fixture . componentInstance . position = 'below' ;
1858
1858
fixture . detectChanges ( ) ;
1859
- let inputReference =
1859
+ const inputReference =
1860
1860
fixture . debugElement . query ( By . css ( '.mat-form-field-flex' ) ) ! . nativeElement ;
1861
1861
1862
1862
// Push the autocomplete trigger down so it won't have room to open below.
@@ -1879,10 +1879,10 @@ describe('MatAutocomplete', () => {
1879
1879
} ) ) ;
1880
1880
1881
1881
it ( 'should be able to force above position even if there is not enough space' , fakeAsync ( ( ) => {
1882
- let fixture = createComponent ( SimpleAutocomplete ) ;
1882
+ const fixture = createComponent ( SimpleAutocomplete ) ;
1883
1883
fixture . componentInstance . position = 'above' ;
1884
1884
fixture . detectChanges ( ) ;
1885
- let inputReference =
1885
+ const inputReference =
1886
1886
fixture . debugElement . query ( By . css ( '.mat-form-field-flex' ) ) ! . nativeElement ;
1887
1887
1888
1888
// Push the autocomplete trigger up so it won't have room to open above.
@@ -1905,11 +1905,11 @@ describe('MatAutocomplete', () => {
1905
1905
} ) ) ;
1906
1906
1907
1907
it ( 'should handle the position being changed after the first open' , fakeAsync ( ( ) => {
1908
- let fixture = createComponent ( SimpleAutocomplete ) ;
1908
+ const fixture = createComponent ( SimpleAutocomplete ) ;
1909
1909
fixture . detectChanges ( ) ;
1910
- let inputReference =
1910
+ const inputReference =
1911
1911
fixture . debugElement . query ( By . css ( '.mat-form-field-flex' ) ) ! . nativeElement ;
1912
- let openPanel = ( ) => {
1912
+ const openPanel = ( ) => {
1913
1913
fixture . componentInstance . trigger . openPanel ( ) ;
1914
1914
fixture . detectChanges ( ) ;
1915
1915
zone . simulateZoneExit ( ) ;
@@ -1966,7 +1966,7 @@ describe('MatAutocomplete', () => {
1966
1966
zone . simulateZoneExit ( ) ;
1967
1967
fixture . detectChanges ( ) ;
1968
1968
1969
- let componentOptions = fixture . componentInstance . options . toArray ( ) ;
1969
+ const componentOptions = fixture . componentInstance . options . toArray ( ) ;
1970
1970
expect ( componentOptions [ 0 ] . selected )
1971
1971
. toBe ( true , `Clicked option should be selected.` ) ;
1972
1972
@@ -1992,7 +1992,7 @@ describe('MatAutocomplete', () => {
1992
1992
zone . simulateZoneExit ( ) ;
1993
1993
fixture . detectChanges ( ) ;
1994
1994
1995
- let componentOptions = fixture . componentInstance . options . toArray ( ) ;
1995
+ const componentOptions = fixture . componentInstance . options . toArray ( ) ;
1996
1996
componentOptions . forEach ( option => spyOn ( option , 'deselect' ) ) ;
1997
1997
1998
1998
expect ( componentOptions [ 0 ] . selected )
@@ -2079,7 +2079,7 @@ describe('MatAutocomplete', () => {
2079
2079
fixture . destroy ( ) ;
2080
2080
fixture = TestBed . createComponent ( SimpleAutocomplete ) ;
2081
2081
2082
- let spy = jasmine . createSpy ( 'option selection spy' ) ;
2082
+ const spy = jasmine . createSpy ( 'option selection spy' ) ;
2083
2083
let subscription : Subscription ;
2084
2084
2085
2085
expect ( fixture . componentInstance . trigger . autocomplete ) . toBeFalsy ( ) ;
@@ -2103,9 +2103,9 @@ describe('MatAutocomplete', () => {
2103
2103
} ) ) ;
2104
2104
2105
2105
it ( 'should reposition the panel when the amount of options changes' , fakeAsync ( ( ) => {
2106
- let formField = fixture . debugElement . query ( By . css ( '.mat-form-field' ) ) ! . nativeElement ;
2107
- let inputReference = formField . querySelector ( '.mat-form-field-flex' ) ;
2108
- let input = inputReference . querySelector ( 'input' ) ;
2106
+ const formField = fixture . debugElement . query ( By . css ( '.mat-form-field' ) ) ! . nativeElement ;
2107
+ const inputReference = formField . querySelector ( '.mat-form-field-flex' ) ;
2108
+ const input = inputReference . querySelector ( 'input' ) ;
2109
2109
2110
2110
formField . style . bottom = '100px' ;
2111
2111
formField . style . position = 'fixed' ;
@@ -2607,7 +2607,7 @@ describe('MatAutocomplete', () => {
2607
2607
2608
2608
it ( 'should show the panel when the options are initialized later within a component with ' +
2609
2609
'OnPush change detection' , fakeAsync ( ( ) => {
2610
- let fixture = createComponent ( AutocompleteWithOnPushDelay ) ;
2610
+ const fixture = createComponent ( AutocompleteWithOnPushDelay ) ;
2611
2611
2612
2612
fixture . detectChanges ( ) ;
2613
2613
dispatchFakeEvent ( fixture . debugElement . query ( By . css ( 'input' ) ) ! . nativeElement , 'focusin' ) ;
@@ -2617,39 +2617,41 @@ describe('MatAutocomplete', () => {
2617
2617
tick ( ) ;
2618
2618
2619
2619
Promise . resolve ( ) . then ( ( ) => {
2620
- let panel = overlayContainerElement . querySelector ( '.mat-autocomplete-panel' ) as HTMLElement ;
2621
- let visibleClass = 'mat-autocomplete-visible' ;
2620
+ const panel =
2621
+ overlayContainerElement . querySelector ( '.mat-autocomplete-panel' ) as HTMLElement ;
2622
+ const visibleClass = 'mat-autocomplete-visible' ;
2622
2623
2623
2624
fixture . detectChanges ( ) ;
2624
2625
expect ( panel . classList ) . toContain ( visibleClass , `Expected panel to be visible.` ) ;
2625
2626
} ) ;
2626
2627
} ) ) ;
2627
2628
2628
2629
it ( 'should emit an event when an option is selected' , fakeAsync ( ( ) => {
2629
- let fixture = createComponent ( AutocompleteWithSelectEvent ) ;
2630
+ const fixture = createComponent ( AutocompleteWithSelectEvent ) ;
2630
2631
2631
2632
fixture . detectChanges ( ) ;
2632
2633
fixture . componentInstance . trigger . openPanel ( ) ;
2633
2634
zone . simulateZoneExit ( ) ;
2634
2635
fixture . detectChanges ( ) ;
2635
2636
2636
- let options = overlayContainerElement . querySelectorAll ( 'mat-option' ) as NodeListOf < HTMLElement > ;
2637
- let spy = fixture . componentInstance . optionSelected ;
2637
+ const options =
2638
+ overlayContainerElement . querySelectorAll ( 'mat-option' ) as NodeListOf < HTMLElement > ;
2639
+ const spy = fixture . componentInstance . optionSelected ;
2638
2640
2639
2641
options [ 1 ] . click ( ) ;
2640
2642
tick ( ) ;
2641
2643
fixture . detectChanges ( ) ;
2642
2644
2643
2645
expect ( spy ) . toHaveBeenCalledTimes ( 1 ) ;
2644
2646
2645
- let event = spy . calls . mostRecent ( ) . args [ 0 ] as MatAutocompleteSelectedEvent ;
2647
+ const event = spy . calls . mostRecent ( ) . args [ 0 ] as MatAutocompleteSelectedEvent ;
2646
2648
2647
2649
expect ( event . source ) . toBe ( fixture . componentInstance . autocomplete ) ;
2648
2650
expect ( event . option . value ) . toBe ( 'Washington' ) ;
2649
2651
} ) ) ;
2650
2652
2651
2653
it ( 'should emit an event when a newly-added option is selected' , fakeAsync ( ( ) => {
2652
- let fixture = createComponent ( AutocompleteWithSelectEvent ) ;
2654
+ const fixture = createComponent ( AutocompleteWithSelectEvent ) ;
2653
2655
2654
2656
fixture . detectChanges ( ) ;
2655
2657
fixture . componentInstance . trigger . openPanel ( ) ;
@@ -2661,16 +2663,17 @@ describe('MatAutocomplete', () => {
2661
2663
tick ( ) ;
2662
2664
fixture . detectChanges ( ) ;
2663
2665
2664
- let options = overlayContainerElement . querySelectorAll ( 'mat-option' ) as NodeListOf < HTMLElement > ;
2665
- let spy = fixture . componentInstance . optionSelected ;
2666
+ const options =
2667
+ overlayContainerElement . querySelectorAll ( 'mat-option' ) as NodeListOf < HTMLElement > ;
2668
+ const spy = fixture . componentInstance . optionSelected ;
2666
2669
2667
2670
options [ 3 ] . click ( ) ;
2668
2671
tick ( ) ;
2669
2672
fixture . detectChanges ( ) ;
2670
2673
2671
2674
expect ( spy ) . toHaveBeenCalledTimes ( 1 ) ;
2672
2675
2673
- let event = spy . calls . mostRecent ( ) . args [ 0 ] as MatAutocompleteSelectedEvent ;
2676
+ const event = spy . calls . mostRecent ( ) . args [ 0 ] as MatAutocompleteSelectedEvent ;
2674
2677
2675
2678
expect ( event . source ) . toBe ( fixture . componentInstance . autocomplete ) ;
2676
2679
expect ( event . option . value ) . toBe ( 'Puerto Rico' ) ;
0 commit comments