@@ -30,125 +30,128 @@ describe('Notification.placement', () => {
30
30
open ( ) ;
31
31
}
32
32
33
- it ( 'change notification placement by `open` method' , async ( ) => {
34
- const defaultTop = '24px' ;
35
- const defaultBottom = '24px' ;
36
- let style ;
33
+ describe ( 'placement' , ( ) => {
34
+ it ( 'change notification placement by `open` method' , async ( ) => {
35
+ const defaultTop = '24px' ;
36
+ const defaultBottom = '24px' ;
37
+ let style ;
37
38
38
- // topLeft
39
- open ( {
40
- placement : 'topLeft' ,
39
+ // topLeft
40
+ open ( {
41
+ placement : 'topLeft' ,
42
+ } ) ;
43
+ await asyncExpect ( ( ) => {
44
+ style = getStyle ( $$ ( '.ant-notification-topLeft' ) [ 0 ] ) ;
45
+ expect ( style . top ) . toBe ( defaultTop ) ;
46
+ expect ( style . left ) . toBe ( '0px' ) ;
47
+ expect ( style . bottom ) . toBe ( '' ) ;
48
+ } ) ;
49
+ open ( {
50
+ placement : 'topLeft' ,
51
+ } ) ;
52
+ await asyncExpect ( ( ) => {
53
+ expect ( $$ ( '.ant-notification-topLeft' ) . length ) . toBe ( 1 ) ;
54
+ } ) ;
55
+ // topRight
56
+ open ( {
57
+ placement : 'topRight' ,
58
+ } ) ;
59
+ await asyncExpect ( ( ) => {
60
+ style = getStyle ( $$ ( '.ant-notification-topRight' ) [ 0 ] ) ;
61
+ expect ( style . top ) . toBe ( defaultTop ) ;
62
+ expect ( style . right ) . toBe ( '0px' ) ;
63
+ expect ( style . bottom ) . toBe ( '' ) ;
64
+ } ) ;
65
+ open ( {
66
+ placement : 'topRight' ,
67
+ } ) ;
68
+ await asyncExpect ( ( ) => {
69
+ expect ( $$ ( '.ant-notification-topRight' ) . length ) . toBe ( 1 ) ;
70
+ } ) ;
71
+ // bottomRight
72
+ open ( {
73
+ placement : 'bottomRight' ,
74
+ bottom : '100px' ,
75
+ } ) ;
76
+ await asyncExpect ( ( ) => {
77
+ style = getStyle ( $$ ( '.ant-notification-bottomRight' ) [ 0 ] ) ;
78
+ expect ( style . top ) . toBe ( '' ) ;
79
+ expect ( style . right ) . toBe ( '0px' ) ;
80
+ expect ( style . bottom ) . toBe ( '100px' ) ;
81
+ } ) ;
82
+ open ( {
83
+ placement : 'bottomRight' ,
84
+ } ) ;
85
+ await asyncExpect ( ( ) => {
86
+ expect ( $$ ( '.ant-notification-bottomRight' ) . length ) . toBe ( 1 ) ;
87
+ } ) ;
88
+ // bottomLeft
89
+ open ( {
90
+ placement : 'bottomLeft' ,
91
+ } ) ;
92
+ await asyncExpect ( ( ) => {
93
+ style = getStyle ( $$ ( '.ant-notification-bottomLeft' ) [ 0 ] ) ;
94
+ expect ( style . top ) . toBe ( '' ) ;
95
+ expect ( style . left ) . toBe ( '0px' ) ;
96
+ expect ( style . bottom ) . toBe ( defaultBottom ) ;
97
+ } ) ;
98
+ open ( {
99
+ placement : 'bottomLeft' ,
100
+ } ) ;
101
+ await asyncExpect ( ( ) => {
102
+ expect ( $$ ( '.ant-notification-bottomLeft' ) . length ) . toBe ( 1 ) ;
103
+ } ) ;
104
+ await asyncExpect ( ( ) => { } ) ;
105
+ await asyncExpect ( ( ) => { } ) ;
41
106
} ) ;
42
- await asyncExpect ( ( ) => {
107
+
108
+ it ( 'change notification placement by `config` method' , ( ) => {
109
+ let style ;
110
+
111
+ // topLeft
112
+ config ( {
113
+ placement : 'topLeft' ,
114
+ top : '50px' ,
115
+ bottom : '50px' ,
116
+ } ) ;
43
117
style = getStyle ( $$ ( '.ant-notification-topLeft' ) [ 0 ] ) ;
44
- expect ( style . top ) . toBe ( defaultTop ) ;
118
+ expect ( style . top ) . toBe ( '50px' ) ;
45
119
expect ( style . left ) . toBe ( '0px' ) ;
46
120
expect ( style . bottom ) . toBe ( '' ) ;
47
- } ) ;
48
- open ( {
49
- placement : 'topLeft' ,
50
- } ) ;
51
- await asyncExpect ( ( ) => {
52
- expect ( $$ ( '.ant-notification-topLeft' ) . length ) . toBe ( 1 ) ;
53
- } ) ;
54
- // topRight
55
- open ( {
56
- placement : 'topRight' ,
57
- } ) ;
58
- await asyncExpect ( ( ) => {
121
+
122
+ // topRight
123
+ config ( {
124
+ placement : 'topRight' ,
125
+ top : '100px' ,
126
+ bottom : '50px' ,
127
+ } ) ;
59
128
style = getStyle ( $$ ( '.ant-notification-topRight' ) [ 0 ] ) ;
60
- expect ( style . top ) . toBe ( defaultTop ) ;
129
+ expect ( style . top ) . toBe ( '100px' ) ;
61
130
expect ( style . right ) . toBe ( '0px' ) ;
62
131
expect ( style . bottom ) . toBe ( '' ) ;
63
- } ) ;
64
- open ( {
65
- placement : 'topRight' ,
66
- } ) ;
67
- await asyncExpect ( ( ) => {
68
- expect ( $$ ( '.ant-notification-topRight' ) . length ) . toBe ( 1 ) ;
69
- } ) ;
70
- // bottomRight
71
- open ( {
72
- placement : 'bottomRight' ,
73
- } ) ;
74
- await asyncExpect ( ( ) => {
132
+
133
+ // bottomRight
134
+ config ( {
135
+ placement : 'bottomRight' ,
136
+ top : '50px' ,
137
+ bottom : '100px' ,
138
+ } ) ;
75
139
style = getStyle ( $$ ( '.ant-notification-bottomRight' ) [ 0 ] ) ;
76
140
expect ( style . top ) . toBe ( '' ) ;
77
141
expect ( style . right ) . toBe ( '0px' ) ;
78
- expect ( style . bottom ) . toBe ( defaultBottom ) ;
79
- } ) ;
80
- open ( {
81
- placement : 'bottomRight' ,
82
- } ) ;
83
- await asyncExpect ( ( ) => {
84
- expect ( $$ ( '.ant-notification-bottomRight' ) . length ) . toBe ( 1 ) ;
85
- } ) ;
86
- // bottomLeft
87
- open ( {
88
- placement : 'bottomLeft' ,
89
- } ) ;
90
- await asyncExpect ( ( ) => {
142
+ expect ( style . bottom ) . toBe ( '100px' ) ;
143
+
144
+ // bottomLeft
145
+ config ( {
146
+ placement : 'bottomLeft' ,
147
+ top : 100 ,
148
+ bottom : 50 ,
149
+ } ) ;
91
150
style = getStyle ( $$ ( '.ant-notification-bottomLeft' ) [ 0 ] ) ;
92
151
expect ( style . top ) . toBe ( '' ) ;
93
152
expect ( style . left ) . toBe ( '0px' ) ;
94
- expect ( style . bottom ) . toBe ( defaultBottom ) ;
95
- } ) ;
96
- open ( {
97
- placement : 'bottomLeft' ,
98
- } ) ;
99
- await asyncExpect ( ( ) => {
100
- expect ( $$ ( '.ant-notification-bottomLeft' ) . length ) . toBe ( 1 ) ;
101
- } ) ;
102
- await asyncExpect ( ( ) => { } ) ;
103
- await asyncExpect ( ( ) => { } ) ;
104
- } ) ;
105
-
106
- it ( 'change notification placement by `config` method' , ( ) => {
107
- let style ;
108
-
109
- // topLeft
110
- config ( {
111
- placement : 'topLeft' ,
112
- top : '50px' ,
113
- bottom : '50px' ,
114
- } ) ;
115
- style = getStyle ( $$ ( '.ant-notification-topLeft' ) [ 0 ] ) ;
116
- expect ( style . top ) . toBe ( '50px' ) ;
117
- expect ( style . left ) . toBe ( '0px' ) ;
118
- expect ( style . bottom ) . toBe ( '' ) ;
119
-
120
- // topRight
121
- config ( {
122
- placement : 'topRight' ,
123
- top : '100px' ,
124
- bottom : '50px' ,
125
- } ) ;
126
- style = getStyle ( $$ ( '.ant-notification-topRight' ) [ 0 ] ) ;
127
- expect ( style . top ) . toBe ( '100px' ) ;
128
- expect ( style . right ) . toBe ( '0px' ) ;
129
- expect ( style . bottom ) . toBe ( '' ) ;
130
-
131
- // bottomRight
132
- config ( {
133
- placement : 'bottomRight' ,
134
- top : '50px' ,
135
- bottom : '100px' ,
136
- } ) ;
137
- style = getStyle ( $$ ( '.ant-notification-bottomRight' ) [ 0 ] ) ;
138
- expect ( style . top ) . toBe ( '' ) ;
139
- expect ( style . right ) . toBe ( '0px' ) ;
140
- expect ( style . bottom ) . toBe ( '100px' ) ;
141
-
142
- // bottomLeft
143
- config ( {
144
- placement : 'bottomLeft' ,
145
- top : 100 ,
146
- bottom : 50 ,
153
+ expect ( style . bottom ) . toBe ( '50px' ) ;
147
154
} ) ;
148
- style = getStyle ( $$ ( '.ant-notification-bottomLeft' ) [ 0 ] ) ;
149
- expect ( style . top ) . toBe ( '' ) ;
150
- expect ( style . left ) . toBe ( '0px' ) ;
151
- expect ( style . bottom ) . toBe ( '50px' ) ;
152
155
} ) ;
153
156
it ( 'change notification mountNode by `config` method' , ( ) => {
154
157
const $container = document . createElement ( 'div' ) ;
0 commit comments