@@ -48,6 +48,7 @@ describe('UNIT: Transition', function () {
4848 c . called = true
4949 assert . ok ( el . classList . contains ( enterClass ) )
5050 } ) ,
51+ compiler = mockCompiler ( ) ,
5152 code ,
5253 cbCalled = false
5354 el . vue_trans_cb = function ( ) {
@@ -56,7 +57,7 @@ describe('UNIT: Transition', function () {
5657 el . addEventListener ( endEvent , el . vue_trans_cb )
5758
5859 it ( 'should add the class before calling changeState()' , function ( ) {
59- code = transition ( el , 1 , c . change , { } )
60+ code = transition ( el , 1 , c . change , compiler )
6061 assert . ok ( c . called )
6162 } )
6263
@@ -75,13 +76,18 @@ describe('UNIT: Transition', function () {
7576 assert . strictEqual ( code , codes . CSS_E )
7677 } )
7778
79+ it ( 'should have called enteredView hook' , function ( ) {
80+ assert . ok ( compiler . enteredView )
81+ } )
82+
7883 } )
7984
8085 describe ( 'leave' , function ( ) {
8186
8287 var el = mockEl ( 'css' ) ,
8388 c = mockChange ( ) ,
84- code = transition ( el , - 1 , c . change , { } )
89+ compiler = mockCompiler ( ) ,
90+ code = transition ( el , - 1 , c . change , compiler )
8591
8692 it ( 'should attach an ontransitionend listener' , function ( ) {
8793 assert . ok ( typeof el . vue_trans_cb === 'function' )
@@ -112,6 +118,10 @@ describe('UNIT: Transition', function () {
112118 assert . strictEqual ( code , codes . CSS_L )
113119 } )
114120
121+ it ( 'should have called leftView hook' , function ( ) {
122+ assert . ok ( compiler . leftView )
123+ } )
124+
115125 } )
116126
117127 } )
@@ -120,29 +130,19 @@ describe('UNIT: Transition', function () {
120130
121131 it ( 'should skip if correspinding option is not defined' , function ( ) {
122132 var c = mockChange ( ) ,
123- code = transition ( mockEl ( 'js' ) , 1 , c . change , {
124- getOption : function ( ) { }
125- } )
133+ code = transition ( mockEl ( 'js' ) , 1 , c . change , mockCompiler ( ) )
126134 assert . ok ( c . called )
127135 assert . strictEqual ( code , codes . JS_SKIP )
128136 } )
129137
130138 it ( 'should skip if the option is given but the enter/leave func is not defined' , function ( ) {
131139 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 ( { } ) )
137141 assert . ok ( c . called )
138142 assert . strictEqual ( code , codes . JS_SKIP_E )
139143
140144 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 ( { } ) )
146146 assert . ok ( c . called )
147147 assert . strictEqual ( code , codes . JS_SKIP_L )
148148 } )
@@ -157,21 +157,22 @@ describe('UNIT: Transition', function () {
157157 assert . strictEqual ( el , element )
158158 change ( )
159159 }
160- }
160+ } ,
161+ compiler = mockCompiler ( def )
161162
162163 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 )
168165 assert . ok ( c . called )
169166 } )
170167
171168 it ( 'should return correct code' , function ( ) {
172169 assert . strictEqual ( code , codes . JS_E )
173170 } )
174171
172+ it ( 'should have called enteredView hook' , function ( ) {
173+ assert . ok ( compiler . enteredView )
174+ } )
175+
175176 } )
176177
177178 describe ( 'leave' , function ( ) {
@@ -184,21 +185,22 @@ describe('UNIT: Transition', function () {
184185 assert . strictEqual ( el , element )
185186 change ( )
186187 }
187- }
188+ } ,
189+ compiler = mockCompiler ( def )
188190
189191 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 )
195193 assert . ok ( c . called )
196194 } )
197195
198196 it ( 'should return correct code' , function ( ) {
199197 assert . strictEqual ( code , codes . JS_L )
200198 } )
201199
200+ it ( 'should have called leftView hook' , function ( ) {
201+ assert . ok ( compiler . leftView )
202+ } )
203+
202204 } )
203205
204206 } )
@@ -225,6 +227,17 @@ describe('UNIT: Transition', function () {
225227 return el
226228 }
227229
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+
228241 function sniffTransitionEndEvent ( ) {
229242 var el = document . createElement ( 'vue' ) ,
230243 defaultEvent = 'transitionend' ,
0 commit comments