@@ -18,6 +18,7 @@ import { DisplayDensity } from '../core/density';
1818import { IgxSelectionAPIService } from '../core/selection' ;
1919import { IgxButtonDirective } from '../directives/button/button.directive' ;
2020import { NgFor } from '@angular/common' ;
21+ import { ConnectedPositioningStrategy , HorizontalAlignment , OverlaySettings , VerticalAlignment } from '../services/public_api' ;
2122
2223const CSS_CLASS_DROP_DOWN_BASE = 'igx-drop-down' ;
2324const CSS_CLASS_LIST = 'igx-drop-down__list' ;
@@ -242,6 +243,57 @@ describe('IgxDropDown ', () => {
242243 expect ( dropdown . opening . emit ) . toHaveBeenCalledTimes ( 1 ) ;
243244 expect ( dropdown . opened . emit ) . toHaveBeenCalledTimes ( 1 ) ;
244245 } ) ) ;
246+ it ( 'should use default overlay settings if none are provided' , ( ) => {
247+ const toggle : IgxToggleDirective = ( dropdown as any ) . toggleDirective ;
248+
249+ spyOn ( toggle , 'open' ) . and . callThrough ( ) ;
250+
251+ dropdown . open ( ) ;
252+ fixture . detectChanges ( ) ;
253+ expect ( toggle . open ) . toHaveBeenCalledTimes ( 1 ) ;
254+
255+ const appliedSettings = ( toggle . open as jasmine . Spy ) . calls . mostRecent ( ) . args [ 0 ] ;
256+ expect ( appliedSettings . closeOnOutsideClick ) . toBe ( true ) ;
257+ expect ( appliedSettings . modal ) . toBe ( false ) ;
258+ expect ( appliedSettings . positionStrategy instanceof ConnectedPositioningStrategy ) . toBe ( true ) ;
259+
260+ const positionStrategy = appliedSettings . positionStrategy as ConnectedPositioningStrategy ;
261+ expect ( positionStrategy . settings . horizontalStartPoint ) . toBe ( HorizontalAlignment . Left ) ;
262+ expect ( positionStrategy . settings . verticalStartPoint ) . toBe ( VerticalAlignment . Bottom ) ;
263+ expect ( positionStrategy . settings . horizontalDirection ) . toBe ( HorizontalAlignment . Right ) ;
264+ expect ( positionStrategy . settings . verticalDirection ) . toBe ( VerticalAlignment . Bottom ) ;
265+ } ) ;
266+
267+ it ( 'should apply custom overlay settings if provided' , ( ) => {
268+ const toggle : IgxToggleDirective = ( dropdown as any ) . toggleDirective ;
269+ const customOverlaySettings : OverlaySettings = {
270+ closeOnOutsideClick : false ,
271+ modal : true ,
272+ positionStrategy : new ConnectedPositioningStrategy ( {
273+ horizontalStartPoint : HorizontalAlignment . Right ,
274+ verticalStartPoint : VerticalAlignment . Top ,
275+ horizontalDirection : HorizontalAlignment . Left ,
276+ verticalDirection : VerticalAlignment . Top
277+ } )
278+ } ;
279+
280+ spyOn ( toggle , 'open' ) . and . callThrough ( ) ;
281+
282+ dropdown . open ( customOverlaySettings ) ;
283+ fixture . detectChanges ( ) ;
284+ expect ( toggle . open ) . toHaveBeenCalledTimes ( 1 ) ;
285+
286+ const appliedSettings = ( toggle . open as jasmine . Spy ) . calls . mostRecent ( ) . args [ 0 ] ;
287+ expect ( appliedSettings . closeOnOutsideClick ) . toBe ( customOverlaySettings . closeOnOutsideClick ) ;
288+ expect ( appliedSettings . modal ) . toBe ( customOverlaySettings . modal ) ;
289+ expect ( appliedSettings . positionStrategy instanceof ConnectedPositioningStrategy ) . toBe ( true ) ;
290+
291+ const positionStrategy = appliedSettings . positionStrategy as ConnectedPositioningStrategy ;
292+ expect ( positionStrategy . settings . horizontalStartPoint ) . toBe ( HorizontalAlignment . Right ) ;
293+ expect ( positionStrategy . settings . verticalStartPoint ) . toBe ( VerticalAlignment . Top ) ;
294+ expect ( positionStrategy . settings . horizontalDirection ) . toBe ( HorizontalAlignment . Left ) ;
295+ expect ( positionStrategy . settings . verticalDirection ) . toBe ( VerticalAlignment . Top ) ;
296+ } ) ;
245297 it ( '#2798 - should allow canceling of open/close through opening/closing events' , fakeAsync ( ( ) => {
246298 const toggle : IgxToggleDirective = ( dropdown as any ) . toggleDirective ;
247299 const onOpeningSpy = spyOn ( dropdown . opening , 'emit' ) . and . callThrough ( ) ;
0 commit comments