11import {
2- it ,
3- beforeEach ,
42 beforeEachProviders ,
53 inject ,
64 async ,
@@ -19,7 +17,6 @@ import {TestComponentBuilder, ComponentFixture} from '@angular/compiler/testing'
1917import { Component , DebugElement } from '@angular/core' ;
2018import { By } from '@angular/platform-browser' ;
2119import { MdCheckbox , MdCheckboxChange } from './checkbox' ;
22- import { PromiseCompleter } from '@angular2-material/core/async/promise-completer' ;
2320
2421
2522
@@ -215,21 +212,14 @@ describe('MdCheckbox', () => {
215212 expect ( testComponent . onCheckboxClick ) . toHaveBeenCalledTimes ( 1 ) ;
216213 } ) ;
217214
218- it ( 'should emit a change event when the `checked` value changes' , ( ) => {
219- // TODO(jelbourn): this *should* work with async(), but fixture.whenStable currently doesn't
220- // know to look at pending macro tasks.
221- // See https://github.com/angular/angular/issues/8389
222- // As a short-term solution, use a promise (which jasmine knows how to understand).
223- let promiseCompleter = new PromiseCompleter ( ) ;
224- checkboxInstance . change . subscribe ( ( ) => {
225- promiseCompleter . resolve ( ) ;
226- } ) ;
227-
215+ it ( 'should emit a change event when the `checked` value changes' , async ( ( ) => {
228216 testComponent . isChecked = true ;
229217 fixture . detectChanges ( ) ;
230218
231- return promiseCompleter . promise ;
232- } ) ;
219+ fixture . whenStable ( ) . then ( ( ) => {
220+ expect ( fixture . componentInstance . changeCount ) . toBe ( 1 ) ;
221+ } ) ;
222+ } ) ) ;
233223
234224 describe ( 'state transition css classes' , ( ) => {
235225 it ( 'should transition unchecked -> checked -> unchecked' , ( ) => {
@@ -509,6 +499,7 @@ class SingleCheckbox {
509499 parentElementClicked : boolean = false ;
510500 parentElementKeyedUp : boolean = false ;
511501 lastKeydownEvent : Event = null ;
502+ changeCount : number = 0 ;
512503
513504 onCheckboxClick ( event : Event ) { }
514505}
0 commit comments