@@ -101,15 +101,15 @@ describe('MdCheckbox', () => {
101
101
expect ( inputElement . indeterminate ) . toBe ( false ) ;
102
102
} ) ;
103
103
104
- it ( 'should set indeterminate to false when set checked ' , async ( ( ) => {
104
+ it ( 'should set indeterminate to false when input clicked ' , async ( ( ) => {
105
105
testComponent . isIndeterminate = true ;
106
106
fixture . detectChanges ( ) ;
107
107
108
108
expect ( checkboxInstance . indeterminate ) . toBe ( true ) ;
109
109
expect ( inputElement . indeterminate ) . toBe ( true ) ;
110
110
expect ( testComponent . isIndeterminate ) . toBe ( true ) ;
111
111
112
- testComponent . isChecked = true ;
112
+ inputElement . click ( ) ;
113
113
fixture . detectChanges ( ) ;
114
114
115
115
fixture . whenStable ( ) . then ( ( ) => {
@@ -127,7 +127,7 @@ describe('MdCheckbox', () => {
127
127
expect ( inputElement . checked ) . toBe ( true ) ;
128
128
expect ( testComponent . isIndeterminate ) . toBe ( true ) ;
129
129
130
- testComponent . isChecked = false ;
130
+ inputElement . click ( ) ;
131
131
fixture . detectChanges ( ) ;
132
132
133
133
fixture . whenStable ( ) . then ( ( ) => {
@@ -141,6 +141,31 @@ describe('MdCheckbox', () => {
141
141
142
142
} ) ) ;
143
143
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
+
144
169
it ( 'should change native element checked when check programmatically' , ( ) => {
145
170
expect ( inputElement . checked ) . toBe ( false ) ;
146
171
@@ -216,11 +241,11 @@ describe('MdCheckbox', () => {
216
241
expect ( checkboxInstance . checked ) . toBe ( false ) ;
217
242
} ) ;
218
243
219
- it ( 'should overwrite indeterminate state when checked is re-set ' , async ( ( ) => {
244
+ it ( 'should overwrite indeterminate state when clicked ' , async ( ( ) => {
220
245
testComponent . isIndeterminate = true ;
221
246
fixture . detectChanges ( ) ;
222
247
223
- testComponent . isChecked = true ;
248
+ inputElement . click ( ) ;
224
249
fixture . detectChanges ( ) ;
225
250
226
251
fixture . whenStable ( ) . then ( ( ) => {
0 commit comments