@@ -113,6 +113,97 @@ describe('CSSTransition', () => {
113
113
} ) ;
114
114
} ) ;
115
115
116
+ describe ( 'appearing' , ( ) => {
117
+ it ( 'should apply appear classes at each transition state' , done => {
118
+ let count = 0 ;
119
+ mount (
120
+ < CSSTransition
121
+ timeout = { 10 }
122
+ classNames = 'appear-test'
123
+ in = { true }
124
+ appear = { true }
125
+ onEnter = { ( node , isAppearing ) => {
126
+ count ++ ;
127
+ expect ( isAppearing ) . toEqual ( true ) ;
128
+ expect ( node . className ) . toEqual ( 'appear-test-appear' ) ;
129
+ } }
130
+ onEntering = { ( node , isAppearing ) => {
131
+ count ++ ;
132
+ expect ( isAppearing ) . toEqual ( true ) ;
133
+ expect ( node . className ) . toEqual ( 'appear-test-appear appear-test-appear-active' ) ;
134
+ } }
135
+
136
+ onEntered = { ( node , isAppearing ) => {
137
+ expect ( isAppearing ) . toEqual ( true ) ;
138
+ expect ( node . className ) . toEqual ( 'appear-test-enter-done' ) ;
139
+ expect ( count ) . toEqual ( 2 ) ;
140
+ done ( ) ;
141
+ } }
142
+ >
143
+ < div />
144
+ </ CSSTransition >
145
+ ) ;
146
+ } ) ;
147
+
148
+ it ( 'should not be appearing in normal enter mode' , done => {
149
+ let count = 0 ;
150
+ mount (
151
+ < CSSTransition
152
+ timeout = { 10 }
153
+ classNames = 'not-appear-test'
154
+ appear = { true }
155
+ >
156
+ < div />
157
+ </ CSSTransition >
158
+ ) . setProps ( {
159
+ in : true ,
160
+
161
+ onEnter ( node , isAppearing ) {
162
+ count ++ ;
163
+ expect ( isAppearing ) . toEqual ( false ) ;
164
+ expect ( node . className ) . toEqual ( 'not-appear-test-enter' ) ;
165
+ } ,
166
+
167
+ onEntering ( node , isAppearing ) {
168
+ count ++ ;
169
+ expect ( isAppearing ) . toEqual ( false ) ;
170
+ expect ( node . className ) . toEqual ( 'not-appear-test-enter not-appear-test-enter-active' ) ;
171
+ } ,
172
+
173
+ onEntered ( node , isAppearing ) {
174
+ expect ( isAppearing ) . toEqual ( false ) ;
175
+ expect ( node . className ) . toEqual ( 'not-appear-test-enter-done' ) ;
176
+ expect ( count ) . toEqual ( 2 ) ;
177
+ done ( ) ;
178
+ }
179
+ } ) ;
180
+ } ) ;
181
+
182
+ it ( 'should not enter the transition states when appear=false' , ( ) => {
183
+ mount (
184
+ < CSSTransition
185
+ timeout = { 10 }
186
+ classNames = 'appear-fail-test'
187
+ in = { true }
188
+ appear = { false }
189
+ onEnter = { ( ) => {
190
+ throw Error ( 'Enter called!' )
191
+ } }
192
+ onEntering = { ( ) => {
193
+ throw Error ( 'Entring called!' )
194
+ } }
195
+ onEntered = { ( ) => {
196
+ throw Error ( 'Entred called!' )
197
+ } }
198
+ >
199
+ < div />
200
+ </ CSSTransition >
201
+ ) ;
202
+ } ) ;
203
+
204
+
205
+ } ) ;
206
+
116
207
describe ( 'exiting' , ( ) => {
117
208
let instance ;
118
209
0 commit comments