@@ -46,26 +46,49 @@ describe('IgxToast', () => {
46
46
expect ( domToast . id ) . toBe ( 'customToast' ) ;
47
47
} ) ;
48
48
49
- it ( 'should be able to set custom positionSettings' , ( ) => {
50
- const defaultPositionSettings = toast . positionSettings ;
51
- expect ( defaultPositionSettings . horizontalDirection ) . toBe ( - 0.5 ) ;
52
- expect ( defaultPositionSettings . verticalDirection ) . toBe ( 0 ) ;
53
- const newPositionSettings : PositionSettings = {
54
- openAnimation : useAnimation ( slideInLeft , { params : { duration : '1000ms' } } ) ,
55
- closeAnimation : useAnimation ( slideInRight , { params : { duration : '1000ms' } } ) ,
56
- horizontalDirection : HorizontalAlignment . Center ,
57
- verticalDirection : VerticalAlignment . Middle ,
58
- horizontalStartPoint : HorizontalAlignment . Center ,
59
- verticalStartPoint : VerticalAlignment . Middle ,
60
- minSize : { height : 100 , width : 100 }
61
- } ;
62
- toast . positionSettings = newPositionSettings ;
49
+ it ( 'should properly change verical position' , ( ) => {
50
+ expect ( toast . position ) . toBe ( 'bottom' ) ;
51
+ expect ( toast . positionSettings . verticalDirection ) . toBe ( 0 ) ;
52
+
53
+ toast . position = 'top' ;
54
+ fixture . detectChanges ( ) ;
55
+ expect ( toast . positionSettings . verticalDirection ) . toBe ( - 1 ) ;
56
+ } ) ;
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
+ } ) ;
85
+
86
+ it ( 'positionSettings passed in the open method should be applied' , ( ) => {
87
+ const positions = fixture . componentInstance . secondPositionSettings ;
88
+ toast . open ( undefined , positions ) ;
63
89
fixture . detectChanges ( ) ;
64
- const customPositionSettings = toast . positionSettings ;
65
- expect ( customPositionSettings . horizontalDirection ) . toBe ( - 0.5 ) ;
66
- expect ( customPositionSettings . verticalDirection ) . toBe ( - 0.5 ) ;
67
- expect ( customPositionSettings . openAnimation . options . params ) . toEqual ( { duration : '1000ms' } ) ;
68
- expect ( customPositionSettings . minSize ) . toEqual ( { height : 100 , width : 100 } ) ;
90
+ expect ( toast . positionSettings . horizontalDirection ) . toBe ( - 0.5 ) ;
91
+ expect ( toast . positionSettings . verticalDirection ) . toBe ( - 0.5 ) ;
69
92
} ) ;
70
93
} ) ;
71
94
@@ -77,3 +100,23 @@ class ToastInitializeTestComponent {
77
100
public toast : IgxToastComponent ;
78
101
}
79
102
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