@@ -100,10 +100,11 @@ describe('uiStateRef', function() {
100
100
expect ( el . attr ( 'href' ) ) . toBe ( '#/contacts/3' ) ;
101
101
} ) ) ;
102
102
103
- it ( 'should transition states when left-clicked' , inject ( function ( $state , $stateParams , $document , $q ) {
103
+ it ( 'should transition states when left-clicked' , inject ( function ( $state , $stateParams , $document , $q , $timeout ) {
104
104
expect ( $state . $current . name ) . toEqual ( '' ) ;
105
105
106
106
triggerClick ( el ) ;
107
+ $timeout . flush ( ) ;
107
108
$q . flush ( ) ;
108
109
109
110
expect ( $state . current . name ) . toEqual ( 'contacts.item.detail' ) ;
@@ -181,37 +182,42 @@ describe('uiStateRef', function() {
181
182
scope . $digest ( ) ;
182
183
} ) ) ;
183
184
184
- it ( 'should work' , inject ( function ( $state , $stateParams , $q ) {
185
+ it ( 'should work' , inject ( function ( $state , $stateParams , $q , $timeout ) {
185
186
triggerClick ( el ) ;
187
+ $timeout . flush ( ) ;
186
188
$q . flush ( ) ;
187
189
188
190
expect ( $state . $current . name ) . toBe ( "contacts.item.detail" ) ;
189
191
expect ( $state . params ) . toEqual ( { id : '5' } ) ;
190
192
} ) ) ;
191
193
192
- it ( 'should resolve states from parent uiView' , inject ( function ( $state , $stateParams , $q ) {
194
+ it ( 'should resolve states from parent uiView' , inject ( function ( $state , $stateParams , $q , $timeout ) {
193
195
$state . transitionTo ( 'contacts' ) ;
194
196
$q . flush ( ) ;
195
197
196
198
var parentToChild = angular . element ( template [ 0 ] . querySelector ( 'a.item' ) ) ;
197
199
triggerClick ( parentToChild ) ;
200
+ $timeout . flush ( ) ;
198
201
$q . flush ( ) ;
199
202
200
203
var childToGrandchild = angular . element ( template [ 0 ] . querySelector ( 'a.item-detail' ) ) ;
201
204
var childToParent = angular . element ( template [ 0 ] . querySelector ( 'a.item-parent' ) ) ;
202
205
203
206
triggerClick ( childToGrandchild ) ;
207
+ $timeout . flush ( ) ;
204
208
$q . flush ( ) ;
205
209
206
210
var grandchildToParent = angular . element ( template [ 0 ] . querySelector ( 'a.item-parent2' ) ) ;
207
211
expect ( $state . $current . name ) . toBe ( "contacts.item.detail" )
208
212
209
213
triggerClick ( grandchildToParent ) ;
214
+ $timeout . flush ( ) ;
210
215
$q . flush ( ) ;
211
216
expect ( $state . $current . name ) . toBe ( "contacts.item" ) ;
212
217
213
218
$state . transitionTo ( "contacts.item.detail" , { id : 3 } ) ;
214
219
triggerClick ( childToParent ) ;
220
+ $timeout . flush ( ) ;
215
221
$q . flush ( ) ;
216
222
expect ( $state . $current . name ) . toBe ( "contacts" ) ;
217
223
} ) ) ;
0 commit comments