@@ -48,6 +48,7 @@ describe('UNIT: Transition', function () {
48
48
c . called = true
49
49
assert . ok ( el . classList . contains ( enterClass ) )
50
50
} ) ,
51
+ compiler = mockCompiler ( ) ,
51
52
code ,
52
53
cbCalled = false
53
54
el . vue_trans_cb = function ( ) {
@@ -56,7 +57,7 @@ describe('UNIT: Transition', function () {
56
57
el . addEventListener ( endEvent , el . vue_trans_cb )
57
58
58
59
it ( 'should add the class before calling changeState()' , function ( ) {
59
- code = transition ( el , 1 , c . change , { } )
60
+ code = transition ( el , 1 , c . change , compiler )
60
61
assert . ok ( c . called )
61
62
} )
62
63
@@ -75,13 +76,18 @@ describe('UNIT: Transition', function () {
75
76
assert . strictEqual ( code , codes . CSS_E )
76
77
} )
77
78
79
+ it ( 'should have called enteredView hook' , function ( ) {
80
+ assert . ok ( compiler . enteredView )
81
+ } )
82
+
78
83
} )
79
84
80
85
describe ( 'leave' , function ( ) {
81
86
82
87
var el = mockEl ( 'css' ) ,
83
88
c = mockChange ( ) ,
84
- code = transition ( el , - 1 , c . change , { } )
89
+ compiler = mockCompiler ( ) ,
90
+ code = transition ( el , - 1 , c . change , compiler )
85
91
86
92
it ( 'should attach an ontransitionend listener' , function ( ) {
87
93
assert . ok ( typeof el . vue_trans_cb === 'function' )
@@ -112,6 +118,10 @@ describe('UNIT: Transition', function () {
112
118
assert . strictEqual ( code , codes . CSS_L )
113
119
} )
114
120
121
+ it ( 'should have called leftView hook' , function ( ) {
122
+ assert . ok ( compiler . leftView )
123
+ } )
124
+
115
125
} )
116
126
117
127
} )
@@ -120,29 +130,19 @@ describe('UNIT: Transition', function () {
120
130
121
131
it ( 'should skip if correspinding option is not defined' , function ( ) {
122
132
var c = mockChange ( ) ,
123
- code = transition ( mockEl ( 'js' ) , 1 , c . change , {
124
- getOption : function ( ) { }
125
- } )
133
+ code = transition ( mockEl ( 'js' ) , 1 , c . change , mockCompiler ( ) )
126
134
assert . ok ( c . called )
127
135
assert . strictEqual ( code , codes . JS_SKIP )
128
136
} )
129
137
130
138
it ( 'should skip if the option is given but the enter/leave func is not defined' , function ( ) {
131
139
var c = mockChange ( ) ,
132
- code = transition ( mockEl ( 'js' ) , 1 , c . change , {
133
- getOption : function ( ) {
134
- return { }
135
- }
136
- } )
140
+ code = transition ( mockEl ( 'js' ) , 1 , c . change , mockCompiler ( { } ) )
137
141
assert . ok ( c . called )
138
142
assert . strictEqual ( code , codes . JS_SKIP_E )
139
143
140
144
c = mockChange ( )
141
- code = transition ( mockEl ( 'js' ) , - 1 , c . change , {
142
- getOption : function ( ) {
143
- return { }
144
- }
145
- } )
145
+ code = transition ( mockEl ( 'js' ) , - 1 , c . change , mockCompiler ( { } ) )
146
146
assert . ok ( c . called )
147
147
assert . strictEqual ( code , codes . JS_SKIP_L )
148
148
} )
@@ -157,21 +157,22 @@ describe('UNIT: Transition', function () {
157
157
assert . strictEqual ( el , element )
158
158
change ( )
159
159
}
160
- }
160
+ } ,
161
+ compiler = mockCompiler ( def )
161
162
162
163
it ( 'should call the enter function' , function ( ) {
163
- code = transition ( el , 1 , c . change , {
164
- getOption : function ( ) {
165
- return def
166
- }
167
- } )
164
+ code = transition ( el , 1 , c . change , compiler )
168
165
assert . ok ( c . called )
169
166
} )
170
167
171
168
it ( 'should return correct code' , function ( ) {
172
169
assert . strictEqual ( code , codes . JS_E )
173
170
} )
174
171
172
+ it ( 'should have called enteredView hook' , function ( ) {
173
+ assert . ok ( compiler . enteredView )
174
+ } )
175
+
175
176
} )
176
177
177
178
describe ( 'leave' , function ( ) {
@@ -184,21 +185,22 @@ describe('UNIT: Transition', function () {
184
185
assert . strictEqual ( el , element )
185
186
change ( )
186
187
}
187
- }
188
+ } ,
189
+ compiler = mockCompiler ( def )
188
190
189
191
it ( 'should call the leave function' , function ( ) {
190
- code = transition ( el , - 1 , c . change , {
191
- getOption : function ( ) {
192
- return def
193
- }
194
- } )
192
+ code = transition ( el , - 1 , c . change , compiler )
195
193
assert . ok ( c . called )
196
194
} )
197
195
198
196
it ( 'should return correct code' , function ( ) {
199
197
assert . strictEqual ( code , codes . JS_L )
200
198
} )
201
199
200
+ it ( 'should have called leftView hook' , function ( ) {
201
+ assert . ok ( compiler . leftView )
202
+ } )
203
+
202
204
} )
203
205
204
206
} )
@@ -225,6 +227,17 @@ describe('UNIT: Transition', function () {
225
227
return el
226
228
}
227
229
230
+ function mockCompiler ( opt ) {
231
+ return {
232
+ getOption : function ( ) {
233
+ return opt
234
+ } ,
235
+ execHook : function ( hook ) {
236
+ this [ hook ] = true
237
+ }
238
+ }
239
+ }
240
+
228
241
function sniffTransitionEndEvent ( ) {
229
242
var el = document . createElement ( 'vue' ) ,
230
243
defaultEvent = 'transitionend' ,
0 commit comments