@@ -11,8 +11,7 @@ import {
11
11
IgxToastModule ,
12
12
} from './toast.component' ;
13
13
import { configureTestSuite } from '../test-utils/configure-suite' ;
14
- import { useAnimation } from '@angular/animations' ;
15
- import { HorizontalAlignment , PositionSettings , slideInLeft , slideInRight , VerticalAlignment } from 'igniteui-angular' ;
14
+ import { HorizontalAlignment , PositionSettings , VerticalAlignment } from 'igniteui-angular' ;
16
15
17
16
describe ( 'IgxToast' , ( ) => {
18
17
configureTestSuite ( ) ;
@@ -46,26 +45,49 @@ describe('IgxToast', () => {
46
45
expect ( domToast . id ) . toBe ( 'customToast' ) ;
47
46
} ) ;
48
47
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 ;
48
+ it ( 'should properly change verical position' , ( ) => {
49
+ expect ( toast . position ) . toBe ( 'bottom' ) ;
50
+ expect ( toast . positionSettings . verticalDirection ) . toBe ( 0 ) ;
51
+
52
+ toast . position = 'top' ;
53
+ fixture . detectChanges ( ) ;
54
+ expect ( toast . positionSettings . verticalDirection ) . toBe ( - 1 ) ;
55
+ } ) ;
56
+ } ) ;
57
+
58
+ describe ( 'IgxToast with positionSettings' , ( ) => {
59
+ configureTestSuite ( ) ;
60
+ beforeAll ( waitForAsync ( ( ) => {
61
+ TestBed . configureTestingModule ( {
62
+ declarations : [ ToastPositionSettingsTestComponent ] ,
63
+ imports : [ NoopAnimationsModule , IgxToastModule ]
64
+ } ) . compileComponents ( ) ;
65
+ } ) ) ;
66
+
67
+ let fixture : ComponentFixture < ToastPositionSettingsTestComponent > ;
68
+ let toast : IgxToastComponent ;
69
+
70
+ beforeEach ( ( ) => {
71
+ fixture = TestBed . createComponent ( ToastPositionSettingsTestComponent ) ;
72
+ toast = fixture . componentInstance . toast ;
73
+ fixture . detectChanges ( ) ;
74
+ } ) ;
75
+
76
+ it ( 'should be able to change positionSettings' , ( ) => {
77
+ expect ( toast . positionSettings . horizontalDirection ) . toBe ( - 1 ) ;
78
+ expect ( toast . positionSettings . verticalDirection ) . toBe ( - 0.5 ) ;
79
+ toast . positionSettings = fixture . componentInstance . secondPositionSettings ;
80
+ fixture . detectChanges ( ) ;
81
+ expect ( toast . positionSettings . horizontalDirection ) . toBe ( - 0.5 ) ;
82
+ expect ( toast . positionSettings . verticalDirection ) . toBe ( - 0.5 ) ;
83
+ } ) ;
84
+
85
+ it ( 'positionSettings passed in the open method should be applied' , ( ) => {
86
+ const positions = fixture . componentInstance . secondPositionSettings ;
87
+ toast . open ( undefined , positions ) ;
63
88
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 } ) ;
89
+ expect ( toast . positionSettings . horizontalDirection ) . toBe ( - 0.5 ) ;
90
+ expect ( toast . positionSettings . verticalDirection ) . toBe ( - 0.5 ) ;
69
91
} ) ;
70
92
} ) ;
71
93
@@ -77,3 +99,23 @@ class ToastInitializeTestComponent {
77
99
public toast : IgxToastComponent ;
78
100
}
79
101
102
+ @Component ( {
103
+ template : `<igx-toast #toast [positionSettings]="firstPositionSettings"></igx-toast>` ,
104
+ } )
105
+ class ToastPositionSettingsTestComponent {
106
+ @ViewChild ( IgxToastComponent , { static : true } )
107
+ public toast : IgxToastComponent ;
108
+ public firstPositionSettings : PositionSettings = {
109
+ horizontalDirection : HorizontalAlignment . Left ,
110
+ verticalDirection : VerticalAlignment . Middle ,
111
+ horizontalStartPoint : HorizontalAlignment . Left ,
112
+ verticalStartPoint : VerticalAlignment . Middle
113
+ } ;
114
+ public secondPositionSettings : PositionSettings = {
115
+ horizontalDirection : HorizontalAlignment . Center ,
116
+ verticalDirection : VerticalAlignment . Middle ,
117
+ horizontalStartPoint : HorizontalAlignment . Center ,
118
+ verticalStartPoint : VerticalAlignment . Middle
119
+ } ;
120
+ }
121
+
0 commit comments