@@ -54,27 +54,41 @@ describe('IgxToast', () => {
5454 fixture . detectChanges ( ) ;
5555 expect ( toast . positionSettings . verticalDirection ) . toBe ( - 1 ) ;
5656 } ) ;
57+ } ) ;
58+
59+ describe ( 'IgxToast with positionSettings' , ( ) => {
60+ configureTestSuite ( ) ;
61+ beforeAll ( waitForAsync ( ( ) => {
62+ TestBed . configureTestingModule ( {
63+ declarations : [ ToastPositionSettingsTestComponent ] ,
64+ imports : [ NoopAnimationsModule , IgxToastModule ]
65+ } ) . compileComponents ( ) ;
66+ } ) ) ;
67+
68+ let fixture : ComponentFixture < ToastPositionSettingsTestComponent > ;
69+ let toast : IgxToastComponent ;
70+
71+ beforeEach ( ( ) => {
72+ fixture = TestBed . createComponent ( ToastPositionSettingsTestComponent ) ;
73+ toast = fixture . componentInstance . toast ;
74+ fixture . detectChanges ( ) ;
75+ } ) ;
76+
77+ it ( 'should be able to change positionSettings' , ( ) => {
78+ expect ( toast . positionSettings . horizontalDirection ) . toBe ( - 1 ) ;
79+ expect ( toast . positionSettings . verticalDirection ) . toBe ( - 0.5 ) ;
80+ toast . positionSettings = fixture . componentInstance . secondPositionSettings ;
81+ fixture . detectChanges ( ) ;
82+ expect ( toast . positionSettings . horizontalDirection ) . toBe ( - 0.5 ) ;
83+ expect ( toast . positionSettings . verticalDirection ) . toBe ( - 0.5 ) ;
84+ } ) ;
5785
58- it ( 'should be able to set custom positionSettings' , ( ) => {
59- const defaultPositionSettings = toast . positionSettings ;
60- expect ( defaultPositionSettings . horizontalDirection ) . toBe ( - 0.5 ) ;
61- expect ( defaultPositionSettings . verticalDirection ) . toBe ( 0 ) ;
62- const newPositionSettings : PositionSettings = {
63- openAnimation : useAnimation ( slideInLeft , { params : { duration : '1000ms' } } ) ,
64- closeAnimation : useAnimation ( slideInRight , { params : { duration : '1000ms' } } ) ,
65- horizontalDirection : HorizontalAlignment . Center ,
66- verticalDirection : VerticalAlignment . Middle ,
67- horizontalStartPoint : HorizontalAlignment . Center ,
68- verticalStartPoint : VerticalAlignment . Middle ,
69- minSize : { height : 100 , width : 100 }
70- } ;
71- toast . positionSettings = newPositionSettings ;
86+ it ( 'positionSettings passed in the open method should be applied' , ( ) => {
87+ const positions = fixture . componentInstance . secondPositionSettings ;
88+ toast . open ( undefined , positions ) ;
7289 fixture . detectChanges ( ) ;
73- const customPositionSettings = toast . positionSettings ;
74- expect ( customPositionSettings . horizontalDirection ) . toBe ( - 0.5 ) ;
75- expect ( customPositionSettings . verticalDirection ) . toBe ( - 0.5 ) ;
76- expect ( customPositionSettings . openAnimation . options . params ) . toEqual ( { duration : '1000ms' } ) ;
77- expect ( customPositionSettings . minSize ) . toEqual ( { height : 100 , width : 100 } ) ;
90+ expect ( toast . positionSettings . horizontalDirection ) . toBe ( - 0.5 ) ;
91+ expect ( toast . positionSettings . verticalDirection ) . toBe ( - 0.5 ) ;
7892 } ) ;
7993} ) ;
8094
@@ -86,3 +100,23 @@ class ToastInitializeTestComponent {
86100 public toast : IgxToastComponent ;
87101}
88102
103+ @Component ( {
104+ template : `<igx-toast #toast [positionSettings]="firstPositionSettings"></igx-toast>` ,
105+ } )
106+ class ToastPositionSettingsTestComponent {
107+ @ViewChild ( IgxToastComponent , { static : true } )
108+ public toast : IgxToastComponent ;
109+ public firstPositionSettings : PositionSettings = {
110+ horizontalDirection : HorizontalAlignment . Left ,
111+ verticalDirection : VerticalAlignment . Middle ,
112+ horizontalStartPoint : HorizontalAlignment . Left ,
113+ verticalStartPoint : VerticalAlignment . Middle
114+ } ;
115+ public secondPositionSettings : PositionSettings = {
116+ horizontalDirection : HorizontalAlignment . Center ,
117+ verticalDirection : VerticalAlignment . Middle ,
118+ horizontalStartPoint : HorizontalAlignment . Center ,
119+ verticalStartPoint : VerticalAlignment . Middle
120+ } ;
121+ }
122+
0 commit comments