@@ -101,15 +101,15 @@ describe('MdCheckbox', () => {
101101 expect ( inputElement . indeterminate ) . toBe ( false ) ;
102102 } ) ;
103103
104- it ( 'should set indeterminate to false when set checked ' , async ( ( ) => {
104+ it ( 'should set indeterminate to false when input clicked ' , async ( ( ) => {
105105 testComponent . isIndeterminate = true ;
106106 fixture . detectChanges ( ) ;
107107
108108 expect ( checkboxInstance . indeterminate ) . toBe ( true ) ;
109109 expect ( inputElement . indeterminate ) . toBe ( true ) ;
110110 expect ( testComponent . isIndeterminate ) . toBe ( true ) ;
111111
112- testComponent . isChecked = true ;
112+ inputElement . click ( ) ;
113113 fixture . detectChanges ( ) ;
114114
115115 fixture . whenStable ( ) . then ( ( ) => {
@@ -127,7 +127,7 @@ describe('MdCheckbox', () => {
127127 expect ( inputElement . checked ) . toBe ( true ) ;
128128 expect ( testComponent . isIndeterminate ) . toBe ( true ) ;
129129
130- testComponent . isChecked = false ;
130+ inputElement . click ( ) ;
131131 fixture . detectChanges ( ) ;
132132
133133 fixture . whenStable ( ) . then ( ( ) => {
@@ -141,6 +141,38 @@ describe('MdCheckbox', () => {
141141
142142 } ) ) ;
143143
144+ it ( 'should not set indeterminate to false when checked is set programmatically' , async ( ( ) => {
145+ testComponent . isIndeterminate = true ;
146+ fixture . detectChanges ( ) ;
147+
148+ expect ( checkboxInstance . indeterminate ) . toBe ( true ) ;
149+ expect ( inputElement . indeterminate ) . toBe ( true ) ;
150+ expect ( testComponent . isIndeterminate ) . toBe ( true ) ;
151+
152+ testComponent . isChecked = true ;
153+ fixture . detectChanges ( ) ;
154+
155+ fixture . whenStable ( ) . then ( ( ) => {
156+ fixture . detectChanges ( ) ;
157+ expect ( checkboxInstance . checked ) . toBe ( true ) ;
158+ expect ( inputElement . indeterminate ) . toBe ( true ) ;
159+ expect ( inputElement . checked ) . toBe ( true ) ;
160+ expect ( testComponent . isIndeterminate ) . toBe ( true ) ;
161+
162+ testComponent . isChecked = false ;
163+ fixture . detectChanges ( ) ;
164+
165+ fixture . whenStable ( ) . then ( ( ) => {
166+ fixture . detectChanges ( ) ;
167+ expect ( checkboxInstance . checked ) . toBe ( false ) ;
168+ expect ( inputElement . indeterminate ) . toBe ( true ) ;
169+ expect ( inputElement . checked ) . toBe ( false ) ;
170+ expect ( testComponent . isIndeterminate ) . toBe ( true ) ;
171+ } ) ;
172+ } ) ;
173+
174+ } ) ) ;
175+
144176 it ( 'should change native element checked when check programmatically' , ( ) => {
145177 expect ( inputElement . checked ) . toBe ( false ) ;
146178
@@ -216,11 +248,11 @@ describe('MdCheckbox', () => {
216248 expect ( checkboxInstance . checked ) . toBe ( false ) ;
217249 } ) ;
218250
219- it ( 'should overwrite indeterminate state when checked is re-set ' , async ( ( ) => {
251+ it ( 'should overwrite indeterminate state when clicked ' , async ( ( ) => {
220252 testComponent . isIndeterminate = true ;
221253 fixture . detectChanges ( ) ;
222254
223- testComponent . isChecked = true ;
255+ inputElement . click ( ) ;
224256 fixture . detectChanges ( ) ;
225257
226258 fixture . whenStable ( ) . then ( ( ) => {
0 commit comments