@@ -51,6 +51,7 @@ const CLASS_OVERLAY_WRAPPER_MODAL = 'igx-overlay__wrapper--modal';
51
51
const CLASS_OVERLAY_WRAPPER_FLEX = 'igx-overlay__wrapper--flex' ;
52
52
const CLASS_OVERLAY_MAIN = 'igx-overlay' ;
53
53
const CLASS_SCROLLABLE_DIV = 'scrollableDiv' ;
54
+ const DEBOUNCE_TIME = 16 ;
54
55
55
56
// Utility function to get all applied to element css from all sources.
56
57
const css = ( element ) => {
@@ -258,19 +259,19 @@ describe('igxOverlay', () => {
258
259
mockFactoryResolver = {
259
260
resolveComponentFactory : ( ) => ( {
260
261
create : ( ) => ( {
261
- hostView : '' ,
262
- location : mockElementRef ,
263
- changeDetectorRef : { detectChanges : ( ) => { } } ,
264
- destroy : ( ) => { }
265
- } )
262
+ hostView : '' ,
263
+ location : mockElementRef ,
264
+ changeDetectorRef : { detectChanges : ( ) => { } } ,
265
+ destroy : ( ) => { }
266
266
} )
267
+ } )
267
268
} ;
268
269
mockApplicationRef = { attachView : ( ) => { } , detachView : ( ) => { } } ;
269
270
mockInjector = { } ;
270
271
mockAnimationBuilder = { } ;
271
272
mockDocument = {
272
273
body : mockElement ,
273
- listeners : { } ,
274
+ listeners : { } ,
274
275
defaultView : mockElement ,
275
276
// this is used be able to properly invoke rxjs `fromEvent` operator, which, turns out
276
277
// just adds an event listener to the element and emits accordingly
@@ -437,7 +438,7 @@ describe('igxOverlay', () => {
437
438
fixture . detectChanges ( ) ;
438
439
439
440
fixture . componentInstance . buttonElement . nativeElement . click ( ) ;
440
- tick ( ) ;
441
+ tick ( DEBOUNCE_TIME ) ;
441
442
442
443
const overlayElement = ( fixture . nativeElement as HTMLElement )
443
444
. parentElement . getElementsByClassName ( CLASS_OVERLAY_MAIN ) [ 0 ] as HTMLElement ;
@@ -634,8 +635,8 @@ describe('igxOverlay', () => {
634
635
const bottom = 200 ;
635
636
const mockElement = document . createElement ( 'div' ) ;
636
637
spyOn ( mockElement , 'getBoundingClientRect' ) . and . callFake ( ( ) => ( {
637
- left, top, width, height, right, bottom
638
- } as DOMRect ) ) ;
638
+ left, top, width, height, right, bottom
639
+ } as DOMRect ) ) ;
639
640
640
641
const mockItem = document . createElement ( 'div' ) ;
641
642
mockElement . append ( mockItem ) ;
@@ -833,7 +834,7 @@ describe('igxOverlay', () => {
833
834
SimpleDynamicComponent ,
834
835
{ positionStrategy : new ConnectedPositioningStrategy ( { target : buttonElement } ) } ) ;
835
836
overlayInstance . show ( id ) ;
836
- tick ( ) ;
837
+ tick ( DEBOUNCE_TIME ) ;
837
838
838
839
let contentElement = ( fixture . nativeElement as HTMLElement )
839
840
. parentElement . getElementsByClassName ( CLASS_OVERLAY_CONTENT_MODAL ) [ 0 ] as HTMLElement ;
@@ -849,7 +850,7 @@ describe('igxOverlay', () => {
849
850
getPointSpy . and . callThrough ( ) . and . returnValue ( rect ) ;
850
851
window . resizeBy ( 200 , 200 ) ;
851
852
window . dispatchEvent ( new Event ( 'resize' ) ) ;
852
- tick ( ) ;
853
+ tick ( DEBOUNCE_TIME ) ;
853
854
854
855
contentElement = ( fixture . nativeElement as HTMLElement )
855
856
. parentElement . getElementsByClassName ( CLASS_OVERLAY_CONTENT_MODAL ) [ 0 ] as HTMLElement ;
@@ -869,7 +870,7 @@ describe('igxOverlay', () => {
869
870
// remove SimpleRefComponent HTML element from the DOM tree
870
871
fixture . elementRef . nativeElement . parentElement . removeChild ( fixture . elementRef . nativeElement ) ;
871
872
overlay . show ( overlay . attach ( fixture . elementRef ) ) ;
872
- tick ( ) ;
873
+ tick ( DEBOUNCE_TIME ) ;
873
874
874
875
const componentElement = fixture . nativeElement as HTMLElement ;
875
876
expect ( componentElement ) . toBeDefined ( ) ;
@@ -1390,7 +1391,7 @@ describe('igxOverlay', () => {
1390
1391
fixture . detectChanges ( ) ;
1391
1392
1392
1393
fixture . componentInstance . buttonElement . nativeElement . click ( ) ;
1393
- tick ( ) ;
1394
+ tick ( DEBOUNCE_TIME ) ;
1394
1395
1395
1396
fixture . detectChanges ( ) ;
1396
1397
const wrapperElement = ( fixture . nativeElement as HTMLElement )
@@ -1488,7 +1489,7 @@ describe('igxOverlay', () => {
1488
1489
1489
1490
overlay . show ( overlay . attach ( SimpleDynamicComponent ) ) ;
1490
1491
overlay . show ( overlay . attach ( SimpleDynamicComponent ) ) ;
1491
- tick ( ) ;
1492
+ tick ( DEBOUNCE_TIME ) ;
1492
1493
const wrapperElements = ( fixture . nativeElement as HTMLElement )
1493
1494
. parentElement . getElementsByClassName ( CLASS_OVERLAY_WRAPPER_MODAL ) as HTMLCollectionOf < HTMLElement > ;
1494
1495
const wrapperElement1 = wrapperElements [ 0 ] ;
@@ -1532,7 +1533,7 @@ describe('igxOverlay', () => {
1532
1533
const overlay = fixture . componentInstance . overlay ;
1533
1534
1534
1535
overlay . show ( overlay . attach ( SimpleDynamicComponent ) ) ;
1535
- tick ( ) ;
1536
+ tick ( DEBOUNCE_TIME ) ;
1536
1537
fixture . detectChanges ( ) ;
1537
1538
1538
1539
// overlay container IS NOT a child of the debugElement (attached to body, not app-root)
@@ -1660,67 +1661,71 @@ describe('igxOverlay', () => {
1660
1661
} ) ;
1661
1662
1662
1663
// adding more than one component to show in igx-overlay:
1663
- it ( 'Should render the component exactly on top of the previous one when adding a new instance with default settings.' , ( ) => {
1664
- const fixture = TestBed . createComponent ( TopLeftOffsetComponent ) ;
1665
- const overlay = fixture . componentInstance . overlay ;
1666
- const overlaySettings : OverlaySettings = {
1667
- positionStrategy : new ConnectedPositioningStrategy ( )
1668
- } ;
1669
- overlay . show ( overlay . attach ( SimpleDynamicComponent , overlaySettings ) ) ;
1670
- overlay . show ( overlay . attach ( SimpleDynamicComponent , overlaySettings ) ) ;
1671
- fixture . detectChanges ( ) ;
1664
+ it ( 'Should render the component exactly on top of the previous one when adding a new instance with default settings.' ,
1665
+ fakeAsync ( ( ) => {
1666
+ const fixture = TestBed . createComponent ( TopLeftOffsetComponent ) ;
1667
+ const overlay = fixture . componentInstance . overlay ;
1668
+ const overlaySettings : OverlaySettings = {
1669
+ positionStrategy : new ConnectedPositioningStrategy ( )
1670
+ } ;
1671
+ overlay . show ( overlay . attach ( SimpleDynamicComponent , overlaySettings ) ) ;
1672
+ overlay . show ( overlay . attach ( SimpleDynamicComponent , overlaySettings ) ) ;
1673
+ tick ( DEBOUNCE_TIME ) ;
1674
+ fixture . detectChanges ( ) ;
1672
1675
1673
- const wrapperElements = ( fixture . nativeElement as HTMLElement )
1674
- . parentElement . getElementsByClassName ( CLASS_OVERLAY_WRAPPER_MODAL ) as HTMLCollectionOf < HTMLElement > ;
1675
- const wrapperElement1 = wrapperElements [ 0 ] ;
1676
- const wrapperElement2 = wrapperElements [ 1 ] ;
1677
- const componentElement1 = wrapperElement1 . getElementsByTagName ( 'component' ) [ 0 ] as HTMLElement ;
1678
- const componentElement2 = wrapperElement2 . getElementsByTagName ( 'component' ) [ 0 ] as HTMLElement ;
1679
- const componentRect1 = componentElement1 . getBoundingClientRect ( ) ;
1680
- const componentRect2 = componentElement2 . getBoundingClientRect ( ) ;
1681
- expect ( componentRect1 . left ) . toEqual ( 0 ) ;
1682
- expect ( componentRect1 . left ) . toEqual ( componentRect2 . left ) ;
1683
- expect ( componentRect1 . top ) . toEqual ( 0 ) ;
1684
- expect ( componentRect1 . top ) . toEqual ( componentRect2 . top ) ;
1685
- expect ( componentRect1 . width ) . toEqual ( componentRect2 . width ) ;
1686
- expect ( componentRect1 . height ) . toEqual ( componentRect2 . height ) ;
1687
- } ) ;
1676
+ const wrapperElements = ( fixture . nativeElement as HTMLElement )
1677
+ . parentElement . getElementsByClassName ( CLASS_OVERLAY_WRAPPER_MODAL ) as HTMLCollectionOf < HTMLElement > ;
1678
+ const wrapperElement1 = wrapperElements [ 0 ] ;
1679
+ const wrapperElement2 = wrapperElements [ 1 ] ;
1680
+ const componentElement1 = wrapperElement1 . getElementsByTagName ( 'component' ) [ 0 ] as HTMLElement ;
1681
+ const componentElement2 = wrapperElement2 . getElementsByTagName ( 'component' ) [ 0 ] as HTMLElement ;
1682
+ const componentRect1 = componentElement1 . getBoundingClientRect ( ) ;
1683
+ const componentRect2 = componentElement2 . getBoundingClientRect ( ) ;
1684
+ expect ( componentRect1 . left ) . toEqual ( 0 ) ;
1685
+ expect ( componentRect1 . left ) . toEqual ( componentRect2 . left ) ;
1686
+ expect ( componentRect1 . top ) . toEqual ( 0 ) ;
1687
+ expect ( componentRect1 . top ) . toEqual ( componentRect2 . top ) ;
1688
+ expect ( componentRect1 . width ) . toEqual ( componentRect2 . width ) ;
1689
+ expect ( componentRect1 . height ) . toEqual ( componentRect2 . height ) ;
1690
+ } ) ) ;
1688
1691
1689
- it ( 'Should render the component exactly on top of the previous one when adding a new instance with the same options.' , ( ) => {
1690
- const fixture = TestBed . createComponent ( TopLeftOffsetComponent ) ;
1691
- const x = 200 ;
1692
- const y = 300 ;
1692
+ it ( 'Should render the component exactly on top of the previous one when adding a new instance with the same options.' ,
1693
+ fakeAsync ( ( ) => {
1694
+ const fixture = TestBed . createComponent ( TopLeftOffsetComponent ) ;
1695
+ const x = 200 ;
1696
+ const y = 300 ;
1693
1697
1694
- const overlay = fixture . componentInstance . overlay ;
1695
- const positionSettings : PositionSettings = {
1696
- horizontalDirection : HorizontalAlignment . Left ,
1697
- verticalDirection : VerticalAlignment . Top ,
1698
- horizontalStartPoint : HorizontalAlignment . Left ,
1699
- verticalStartPoint : VerticalAlignment . Bottom ,
1700
- } ;
1701
- const overlaySettings : OverlaySettings = {
1702
- target : new Point ( x , y ) ,
1703
- positionStrategy : new ConnectedPositioningStrategy ( positionSettings )
1704
- } ;
1705
- overlay . show ( overlay . attach ( SimpleDynamicComponent , overlaySettings ) ) ;
1706
- overlay . show ( overlay . attach ( SimpleDynamicComponent , overlaySettings ) ) ;
1707
- fixture . detectChanges ( ) ;
1698
+ const overlay = fixture . componentInstance . overlay ;
1699
+ const positionSettings : PositionSettings = {
1700
+ horizontalDirection : HorizontalAlignment . Left ,
1701
+ verticalDirection : VerticalAlignment . Top ,
1702
+ horizontalStartPoint : HorizontalAlignment . Left ,
1703
+ verticalStartPoint : VerticalAlignment . Bottom ,
1704
+ } ;
1705
+ const overlaySettings : OverlaySettings = {
1706
+ target : new Point ( x , y ) ,
1707
+ positionStrategy : new ConnectedPositioningStrategy ( positionSettings )
1708
+ } ;
1709
+ overlay . show ( overlay . attach ( SimpleDynamicComponent , overlaySettings ) ) ;
1710
+ overlay . show ( overlay . attach ( SimpleDynamicComponent , overlaySettings ) ) ;
1711
+ tick ( DEBOUNCE_TIME ) ;
1712
+ fixture . detectChanges ( ) ;
1708
1713
1709
- const wrapperElements = ( fixture . nativeElement as HTMLElement )
1710
- . parentElement . getElementsByClassName ( CLASS_OVERLAY_WRAPPER_MODAL ) as HTMLCollectionOf < HTMLElement > ;
1711
- const wrapperElement1 = wrapperElements [ 0 ] ;
1712
- const wrapperElement2 = wrapperElements [ 1 ] ;
1713
- const componentElement1 = wrapperElement1 . getElementsByTagName ( 'component' ) [ 0 ] as HTMLElement ;
1714
- const componentElement2 = wrapperElement2 . getElementsByTagName ( 'component' ) [ 0 ] as HTMLElement ;
1715
- const componentRect1 = componentElement1 . getBoundingClientRect ( ) ;
1716
- const componentRect2 = componentElement2 . getBoundingClientRect ( ) ;
1717
- expect ( componentRect1 . left ) . toEqual ( x - componentRect1 . width ) ;
1718
- expect ( componentRect1 . left ) . toEqual ( componentRect2 . left ) ;
1719
- expect ( componentRect1 . top ) . toEqual ( y - componentRect1 . height ) ;
1720
- expect ( componentRect1 . top ) . toEqual ( componentRect2 . top ) ;
1721
- expect ( componentRect1 . width ) . toEqual ( componentRect2 . width ) ;
1722
- expect ( componentRect1 . height ) . toEqual ( componentRect2 . height ) ;
1723
- } ) ;
1714
+ const wrapperElements = ( fixture . nativeElement as HTMLElement )
1715
+ . parentElement . getElementsByClassName ( CLASS_OVERLAY_WRAPPER_MODAL ) as HTMLCollectionOf < HTMLElement > ;
1716
+ const wrapperElement1 = wrapperElements [ 0 ] ;
1717
+ const wrapperElement2 = wrapperElements [ 1 ] ;
1718
+ const componentElement1 = wrapperElement1 . getElementsByTagName ( 'component' ) [ 0 ] as HTMLElement ;
1719
+ const componentElement2 = wrapperElement2 . getElementsByTagName ( 'component' ) [ 0 ] as HTMLElement ;
1720
+ const componentRect1 = componentElement1 . getBoundingClientRect ( ) ;
1721
+ const componentRect2 = componentElement2 . getBoundingClientRect ( ) ;
1722
+ expect ( componentRect1 . left ) . toEqual ( x - componentRect1 . width ) ;
1723
+ expect ( componentRect1 . left ) . toEqual ( componentRect2 . left ) ;
1724
+ expect ( componentRect1 . top ) . toEqual ( y - componentRect1 . height ) ;
1725
+ expect ( componentRect1 . top ) . toEqual ( componentRect2 . top ) ;
1726
+ expect ( componentRect1 . width ) . toEqual ( componentRect2 . width ) ;
1727
+ expect ( componentRect1 . height ) . toEqual ( componentRect2 . height ) ;
1728
+ } ) ) ;
1724
1729
1725
1730
it ( `Should change the state of the component to closed when reaching threshold and closing scroll strategy is used.` ,
1726
1731
fakeAsync ( ( ) => {
@@ -3010,7 +3015,7 @@ describe('igxOverlay', () => {
3010
3015
} ;
3011
3016
3012
3017
overlay . show ( overlay . attach ( SimpleDynamicComponent , overlaySettings ) ) ;
3013
- tick ( ) ;
3018
+ tick ( DEBOUNCE_TIME ) ;
3014
3019
3015
3020
let wrapperElement = ( fixture . nativeElement as HTMLElement )
3016
3021
. parentElement . getElementsByClassName ( CLASS_OVERLAY_WRAPPER_MODAL ) [ 0 ] as HTMLElement ;
@@ -3020,7 +3025,7 @@ describe('igxOverlay', () => {
3020
3025
tick ( ) ;
3021
3026
3022
3027
wrapperElement = ( fixture . nativeElement as HTMLElement )
3023
- . parentElement . getElementsByClassName ( CLASS_OVERLAY_WRAPPER_MODAL ) [ 0 ] as HTMLElement ;
3028
+ . parentElement . getElementsByClassName ( CLASS_OVERLAY_WRAPPER ) [ 0 ] as HTMLElement ;
3024
3029
expect ( wrapperElement . style . visibility ) . toEqual ( 'hidden' ) ;
3025
3030
} ) ) ;
3026
3031
@@ -3032,14 +3037,14 @@ describe('igxOverlay', () => {
3032
3037
} ;
3033
3038
3034
3039
overlay . show ( overlay . attach ( SimpleDynamicComponent , overlaySettings ) ) ;
3035
- tick ( ) ;
3040
+ tick ( DEBOUNCE_TIME ) ;
3036
3041
3037
3042
let wrapperElement = ( fixture . nativeElement as HTMLElement )
3038
3043
. parentElement . getElementsByClassName ( CLASS_OVERLAY_WRAPPER_MODAL ) [ 0 ] as HTMLElement ;
3039
3044
expect ( wrapperElement . style . visibility ) . toEqual ( '' ) ;
3040
3045
3041
3046
UIInteractions . triggerKeyDownEvtUponElem ( 'Escape' , document ) ;
3042
- tick ( ) ;
3047
+ tick ( DEBOUNCE_TIME ) ;
3043
3048
3044
3049
wrapperElement = ( fixture . nativeElement as HTMLElement )
3045
3050
. parentElement . getElementsByClassName ( CLASS_OVERLAY_WRAPPER_MODAL ) [ 0 ] as HTMLElement ;
@@ -3110,34 +3115,34 @@ describe('igxOverlay', () => {
3110
3115
} ;
3111
3116
3112
3117
overlay . show ( overlay . attach ( SimpleDynamicComponent , overlaySettings ) ) ;
3113
- tick ( ) ;
3118
+ tick ( DEBOUNCE_TIME ) ;
3114
3119
3115
3120
let wrapperElement = ( fixture . nativeElement as HTMLElement )
3116
3121
. parentElement . getElementsByClassName ( CLASS_OVERLAY_WRAPPER_MODAL ) [ 0 ] as HTMLElement ;
3117
3122
expect ( wrapperElement . style . visibility ) . toEqual ( '' ) ;
3118
3123
3119
3124
UIInteractions . triggerKeyDownEvtUponElem ( 'Enter' , document ) ;
3120
- tick ( ) ;
3125
+ tick ( DEBOUNCE_TIME ) ;
3121
3126
wrapperElement = ( fixture . nativeElement as HTMLElement )
3122
3127
. parentElement . getElementsByClassName ( CLASS_OVERLAY_WRAPPER_MODAL ) [ 0 ] as HTMLElement ;
3123
3128
expect ( wrapperElement . style . visibility ) . toEqual ( '' ) ;
3124
3129
3125
3130
UIInteractions . triggerKeyDownEvtUponElem ( 'a' , document ) ;
3126
- tick ( ) ;
3131
+ tick ( DEBOUNCE_TIME ) ;
3127
3132
wrapperElement = ( fixture . nativeElement as HTMLElement )
3128
3133
. parentElement . getElementsByClassName ( CLASS_OVERLAY_WRAPPER_MODAL ) [ 0 ] as HTMLElement ;
3129
3134
expect ( wrapperElement . style . visibility ) . toEqual ( '' ) ;
3130
3135
3131
3136
UIInteractions . triggerKeyDownEvtUponElem ( 'ArrowUp' , document ) ;
3132
- tick ( ) ;
3137
+ tick ( DEBOUNCE_TIME ) ;
3133
3138
wrapperElement = ( fixture . nativeElement as HTMLElement )
3134
3139
. parentElement . getElementsByClassName ( CLASS_OVERLAY_WRAPPER_MODAL ) [ 0 ] as HTMLElement ;
3135
3140
expect ( wrapperElement . style . visibility ) . toEqual ( '' ) ;
3136
3141
3137
3142
UIInteractions . triggerKeyDownEvtUponElem ( 'Escape' , document ) ;
3138
3143
tick ( ) ;
3139
3144
wrapperElement = ( fixture . nativeElement as HTMLElement )
3140
- . parentElement . getElementsByClassName ( CLASS_OVERLAY_WRAPPER_MODAL ) [ 0 ] as HTMLElement ;
3145
+ . parentElement . getElementsByClassName ( CLASS_OVERLAY_WRAPPER ) [ 0 ] as HTMLElement ;
3141
3146
expect ( wrapperElement . style . visibility ) . toEqual ( 'hidden' ) ;
3142
3147
} ) ) ;
3143
3148
@@ -3206,7 +3211,7 @@ describe('igxOverlay', () => {
3206
3211
expect ( fixture . componentInstance . customComponent . nativeElement . getBoundingClientRect ( ) . height ) . toEqual ( 280 ) ;
3207
3212
fixture . componentInstance . buttonElement . nativeElement . click ( ) ;
3208
3213
tick ( ) ;
3209
- const componentElement = ( fixture . nativeElement as HTMLElement )
3214
+ const componentElement = ( fixture . nativeElement as HTMLElement )
3210
3215
. parentElement . getElementsByClassName ( 'customList' ) [ 0 ] as HTMLElement ;
3211
3216
expect ( componentElement ) . toBeDefined ( ) ;
3212
3217
expect ( componentElement . style . width ) . toEqual ( '100%' ) ;
@@ -4019,12 +4024,12 @@ describe('igxOverlay', () => {
4019
4024
expect ( overlay . closing . emit ) . toHaveBeenCalledTimes ( 1 ) ;
4020
4025
expect ( overlay . closed . emit ) . toHaveBeenCalledTimes ( 1 ) ;
4021
4026
expect ( overlay . closing . emit )
4022
- . toHaveBeenCalledWith ( {
4023
- id : callId ,
4024
- componentRef : jasmine . any ( ComponentRef ) as any ,
4025
- cancel : false ,
4026
- event : undefined
4027
- } ) ;
4027
+ . toHaveBeenCalledWith ( {
4028
+ id : callId ,
4029
+ componentRef : jasmine . any ( ComponentRef ) as any ,
4030
+ cancel : false ,
4031
+ event : undefined
4032
+ } ) ;
4028
4033
overlay . detachAll ( ) ;
4029
4034
4030
4035
overlaySettings . excludeFromOutsideClick = [ ] ;
@@ -4040,12 +4045,12 @@ describe('igxOverlay', () => {
4040
4045
expect ( overlay . closing . emit ) . toHaveBeenCalledTimes ( 2 ) ;
4041
4046
expect ( overlay . closed . emit ) . toHaveBeenCalledTimes ( 2 ) ;
4042
4047
expect ( overlay . closing . emit )
4043
- . toHaveBeenCalledWith ( {
4044
- id : callId ,
4045
- componentRef : jasmine . any ( ComponentRef ) as any ,
4046
- cancel : false ,
4047
- event : jasmine . any ( Event ) as any
4048
- } ) ;
4048
+ . toHaveBeenCalledWith ( {
4049
+ id : callId ,
4050
+ componentRef : jasmine . any ( ComponentRef ) as any ,
4051
+ cancel : false ,
4052
+ event : jasmine . any ( Event ) as any
4053
+ } ) ;
4049
4054
} ) ) ;
4050
4055
} ) ;
4051
4056
0 commit comments