@@ -214,7 +214,33 @@ describe('MdCheckbox', () => {
214214 expect ( testComponent . onCheckboxClick ) . toHaveBeenCalledTimes ( 1 ) ;
215215 } ) ;
216216
217- it ( 'should emit a change event when the `checked` value changes' , async ( ( ) => {
217+ it ( 'should trigger a change event when the native input does' , async ( ( ) => {
218+ spyOn ( testComponent , 'onCheckboxChange' ) ;
219+
220+ expect ( inputElement . checked ) . toBe ( false ) ;
221+ expect ( checkboxNativeElement . classList ) . not . toContain ( 'md-checkbox-checked' ) ;
222+
223+ labelElement . click ( ) ;
224+ fixture . detectChanges ( ) ;
225+
226+ expect ( inputElement . checked ) . toBe ( true ) ;
227+ expect ( checkboxNativeElement . classList ) . toContain ( 'md-checkbox-checked' ) ;
228+
229+ // Wait for the fixture to become stable, because the EventEmitter for the change event,
230+ // will only fire after the zone async change detection has finished.
231+ fixture . whenStable ( ) . then ( ( ) => {
232+ // The change event shouldn't fire, because the value change was not caused
233+ // by any interaction.
234+ expect ( testComponent . onCheckboxChange ) . toHaveBeenCalledTimes ( 1 ) ;
235+ } ) ;
236+ } ) ) ;
237+
238+ it ( 'should not trigger the change event by changing the native value' , async ( ( ) => {
239+ spyOn ( testComponent , 'onCheckboxChange' ) ;
240+
241+ expect ( inputElement . checked ) . toBe ( false ) ;
242+ expect ( checkboxNativeElement . classList ) . not . toContain ( 'md-checkbox-checked' ) ;
243+
218244 testComponent . isChecked = true ;
219245 fixture . detectChanges ( ) ;
220246
0 commit comments