@@ -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,31 @@ 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+ expect ( checkboxInstance . checked ) . toBe ( true ) ;
156+ expect ( inputElement . indeterminate ) . toBe ( true ) ;
157+ expect ( inputElement . checked ) . toBe ( true ) ;
158+ expect ( testComponent . isIndeterminate ) . toBe ( true ) ;
159+
160+ testComponent . isChecked = false ;
161+ fixture . detectChanges ( ) ;
162+
163+ expect ( checkboxInstance . checked ) . toBe ( false ) ;
164+ expect ( inputElement . indeterminate ) . toBe ( true ) ;
165+ expect ( inputElement . checked ) . toBe ( false ) ;
166+ expect ( testComponent . isIndeterminate ) . toBe ( true ) ;
167+ } ) ) ;
168+
144169 it ( 'should change native element checked when check programmatically' , ( ) => {
145170 expect ( inputElement . checked ) . toBe ( false ) ;
146171
@@ -216,11 +241,11 @@ describe('MdCheckbox', () => {
216241 expect ( checkboxInstance . checked ) . toBe ( false ) ;
217242 } ) ;
218243
219- it ( 'should overwrite indeterminate state when checked is re-set ' , async ( ( ) => {
244+ it ( 'should overwrite indeterminate state when clicked ' , async ( ( ) => {
220245 testComponent . isIndeterminate = true ;
221246 fixture . detectChanges ( ) ;
222247
223- testComponent . isChecked = true ;
248+ inputElement . click ( ) ;
224249 fixture . detectChanges ( ) ;
225250
226251 fixture . whenStable ( ) . then ( ( ) => {
0 commit comments