@@ -44,15 +44,14 @@ describe('<md-autocomplete>', function () {
4444 // Using md-item-size would reduce this to a single flush, but given that
4545 // autocomplete allows for custom row templates, it's better to measure
4646 // rather than assuming a given size.
47- inject ( function ( $$rAF ) {
48- $$rAF . flush ( ) ;
49- element . scope ( ) . $apply ( ) ;
50- $$rAF . flush ( ) ;
47+ inject ( function ( $material , $timeout ) {
48+ $material . flushOutstandingAnimations ( ) ;
49+ $timeout . flush ( ) ;
5150 } ) ;
5251 }
5352
5453 describe ( 'basic functionality' , function ( ) {
55- it ( 'should update selected item and search text' , inject ( function ( $timeout , $mdConstant ) {
54+ it ( 'should update selected item and search text' , inject ( function ( $timeout , $mdConstant , $material ) {
5655 var scope = createScope ( ) ;
5756 var template = '\
5857 <md-autocomplete\
@@ -67,11 +66,12 @@ describe('<md-autocomplete>', function () {
6766 var ctrl = element . controller ( 'mdAutocomplete' ) ;
6867 var ul = element . find ( 'ul' ) ;
6968
69+ $material . flushInterimElement ( ) ;
70+
7071 expect ( scope . searchText ) . toBe ( '' ) ;
7172 expect ( scope . selectedItem ) . toBe ( null ) ;
7273
7374 element . scope ( ) . searchText = 'fo' ;
74- $timeout . flush ( ) ;
7575 waitForVirtualRepeat ( element ) ;
7676
7777 expect ( scope . searchText ) . toBe ( 'fo' ) ;
@@ -160,7 +160,7 @@ describe('<md-autocomplete>', function () {
160160 } ) ;
161161
162162 describe ( 'basic functionality with template' , function ( ) {
163- it ( 'should update selected item and search text' , inject ( function ( $timeout , $mdConstant ) {
163+ it ( 'should update selected item and search text' , inject ( function ( $timeout , $material , $ mdConstant) {
164164 var scope = createScope ( ) ;
165165 var template = '\
166166 <md-autocomplete\
@@ -180,8 +180,9 @@ describe('<md-autocomplete>', function () {
180180 expect ( scope . searchText ) . toBe ( '' ) ;
181181 expect ( scope . selectedItem ) . toBe ( null ) ;
182182
183+ $material . flushInterimElement ( ) ;
184+
183185 element . scope ( ) . searchText = 'fo' ;
184- $timeout . flush ( ) ;
185186 waitForVirtualRepeat ( element ) ;
186187
187188 expect ( scope . searchText ) . toBe ( 'fo' ) ;
@@ -190,6 +191,7 @@ describe('<md-autocomplete>', function () {
190191
191192 ctrl . keydown ( keydownEvent ( $mdConstant . KEY_CODE . DOWN_ARROW ) ) ;
192193 ctrl . keydown ( keydownEvent ( $mdConstant . KEY_CODE . ENTER ) ) ;
194+
193195 $timeout . flush ( ) ;
194196
195197 expect ( scope . searchText ) . toBe ( 'foo' ) ;
@@ -198,7 +200,7 @@ describe('<md-autocomplete>', function () {
198200 element . remove ( ) ;
199201 } ) ) ;
200202
201- it ( 'should compile the template against the parent scope' , inject ( function ( $timeout ) {
203+ it ( 'should compile the template against the parent scope' , inject ( function ( $timeout , $material ) {
202204 var scope = createScope ( null , { bang : 'boom' } ) ;
203205 var template = '\
204206 <md-autocomplete\
@@ -217,6 +219,8 @@ describe('<md-autocomplete>', function () {
217219 var ctrl = element . controller ( 'mdAutocomplete' ) ;
218220 var ul = element . find ( 'ul' ) ;
219221
222+ $material . flushOutstandingAnimations ( ) ;
223+
220224 expect ( scope . bang ) . toBe ( 'boom' ) ;
221225
222226 element . scope ( ) . searchText = 'fo' ;
@@ -242,7 +246,7 @@ describe('<md-autocomplete>', function () {
242246 } ) ;
243247
244248 describe ( 'xss prevention' , function ( ) {
245- it ( 'should not allow html to slip through' , inject ( function ( $timeout ) {
249+ it ( 'should not allow html to slip through' , inject ( function ( $timeout , $material ) {
246250 var html = 'foo <img src="img" onerror="alert(1)" />' ;
247251 var scope = createScope ( [ { display : html } ] ) ;
248252 var template = '\
@@ -258,6 +262,8 @@ describe('<md-autocomplete>', function () {
258262 var element = compile ( template , scope ) ;
259263 var ul = element . find ( 'ul' ) ;
260264
265+ $material . flushOutstandingAnimations ( ) ;
266+
261267 expect ( scope . searchText ) . toBe ( '' ) ;
262268 expect ( scope . selectedItem ) . toBe ( null ) ;
263269
0 commit comments