@@ -9,15 +9,9 @@ import {FormControl, FormsModule, NgModel, ReactiveFormsModule} from '@angular/f
9
9
import { Component , DebugElement , ViewChild , Type , ChangeDetectionStrategy } from '@angular/core' ;
10
10
import { By } from '@angular/platform-browser' ;
11
11
import { dispatchFakeEvent } from '@angular/cdk/testing/private' ;
12
- import {
13
- MAT_CHECKBOX_DEFAULT_OPTIONS ,
14
- MatCheckbox ,
15
- MatCheckboxChange ,
16
- MatCheckboxModule
17
- } from './index' ;
12
+ import { MatCheckbox , MatCheckboxChange , MatCheckboxModule } from './index' ;
18
13
import { MAT_CHECKBOX_CLICK_ACTION } from './checkbox-config' ;
19
14
import { MutationObserverFactory } from '@angular/cdk/observers' ;
20
- import { ThemePalette } from '@angular/material/core' ;
21
15
22
16
23
17
describe ( 'MatCheckbox' , ( ) => {
@@ -539,47 +533,14 @@ describe('MatCheckbox', () => {
539
533
} ) ) ;
540
534
} ) ;
541
535
542
- describe ( `when MAT_CHECKBOX_CLICK_ACTION is set` , ( ) => {
543
- beforeEach ( ( ) => {
544
- TestBed . resetTestingModule ( ) ;
545
- TestBed . configureTestingModule ( {
546
- imports : [ MatCheckboxModule , FormsModule , ReactiveFormsModule ] ,
547
- declarations : [ SingleCheckbox ] ,
548
- providers : [
549
- { provide : MAT_CHECKBOX_CLICK_ACTION , useValue : 'check' } ,
550
- { provide : MAT_CHECKBOX_DEFAULT_OPTIONS , useValue : { clickAction : 'noop' } }
551
- ]
552
- } ) ;
553
-
554
- fixture = createComponent ( SingleCheckbox ) ;
555
- fixture . detectChanges ( ) ;
556
-
557
- checkboxDebugElement = fixture . debugElement . query ( By . directive ( MatCheckbox ) ) ! ;
558
- checkboxNativeElement = checkboxDebugElement . nativeElement ;
559
- testComponent = fixture . debugElement . componentInstance ;
560
-
561
- inputElement = checkboxNativeElement . querySelector ( 'input' ) as HTMLInputElement ;
562
- } ) ;
563
-
564
- it ( 'should override the value set in the default options' , fakeAsync ( ( ) => {
565
- testComponent . isIndeterminate = true ;
566
- inputElement . click ( ) ;
567
- fixture . detectChanges ( ) ;
568
- flush ( ) ;
569
-
570
- expect ( inputElement . checked ) . toBe ( true ) ;
571
- expect ( inputElement . indeterminate ) . toBe ( true ) ;
572
- } ) ) ;
573
- } ) ;
574
-
575
536
describe ( `when MAT_CHECKBOX_CLICK_ACTION is 'check'` , ( ) => {
576
537
beforeEach ( ( ) => {
577
538
TestBed . resetTestingModule ( ) ;
578
539
TestBed . configureTestingModule ( {
579
540
imports : [ MatCheckboxModule , FormsModule , ReactiveFormsModule ] ,
580
541
declarations : [ SingleCheckbox ] ,
581
542
providers : [
582
- { provide : MAT_CHECKBOX_DEFAULT_OPTIONS , useValue : { clickAction : 'check' } }
543
+ { provide : MAT_CHECKBOX_CLICK_ACTION , useValue : 'check' }
583
544
]
584
545
} ) ;
585
546
@@ -616,7 +577,7 @@ describe('MatCheckbox', () => {
616
577
imports : [ MatCheckboxModule , FormsModule , ReactiveFormsModule ] ,
617
578
declarations : [ SingleCheckbox ] ,
618
579
providers : [
619
- { provide : MAT_CHECKBOX_DEFAULT_OPTIONS , useValue : { clickAction : 'noop' } }
580
+ { provide : MAT_CHECKBOX_CLICK_ACTION , useValue : 'noop' }
620
581
]
621
582
} ) ;
622
583
@@ -1194,50 +1155,6 @@ describe('MatCheckbox', () => {
1194
1155
} ) ;
1195
1156
} ) ;
1196
1157
1197
- describe ( 'MatCheckboxDefaultOptions' , ( ) => {
1198
- describe ( 'when MAT_CHECKBOX_DEFAULT_OPTIONS overridden' , ( ) => {
1199
- beforeEach ( ( ) => {
1200
- TestBed . configureTestingModule ( {
1201
- imports : [ MatCheckboxModule , FormsModule ] ,
1202
- declarations : [ SingleCheckbox , SimpleCheckbox ] ,
1203
- providers : [ {
1204
- provide : MAT_CHECKBOX_DEFAULT_OPTIONS ,
1205
- useValue : { color : 'primary' } ,
1206
- } ] ,
1207
- } ) ;
1208
-
1209
- TestBed . compileComponents ( ) ;
1210
- } ) ;
1211
-
1212
- it ( 'should override default color in Component' , ( ) => {
1213
- const fixture : ComponentFixture < SimpleCheckbox > =
1214
- TestBed . createComponent ( SimpleCheckbox ) ;
1215
- fixture . detectChanges ( ) ;
1216
- const checkboxDebugElement : DebugElement =
1217
- fixture . debugElement . query ( By . directive ( MatCheckbox ) ) ! ;
1218
- expect (
1219
- checkboxDebugElement . nativeElement . classList
1220
- ) . toContain ( 'mat-primary' ) ;
1221
- } ) ;
1222
-
1223
- it ( 'should not override explicit input bindings' , ( ) => {
1224
- const fixture : ComponentFixture < SingleCheckbox > =
1225
- TestBed . createComponent ( SingleCheckbox ) ;
1226
- fixture . componentInstance . checkboxColor = 'warn' ;
1227
- fixture . detectChanges ( ) ;
1228
- const checkboxDebugElement : DebugElement =
1229
- fixture . debugElement . query ( By . directive ( MatCheckbox ) ) ! ;
1230
- expect (
1231
- checkboxDebugElement . nativeElement . classList
1232
- ) . not . toContain ( 'mat-primary' ) ;
1233
- expect (
1234
- checkboxDebugElement . nativeElement . classList
1235
- ) . toContain ( 'mat-warn' ) ;
1236
- expect ( checkboxDebugElement . nativeElement . classList ) . toContain ( 'mat-warn' ) ;
1237
- } ) ;
1238
- } ) ;
1239
- } ) ;
1240
-
1241
1158
/** Simple component for testing a single checkbox. */
1242
1159
@Component ( {
1243
1160
template : `
@@ -1268,7 +1185,7 @@ class SingleCheckbox {
1268
1185
parentElementClicked : boolean = false ;
1269
1186
parentElementKeyedUp : boolean = false ;
1270
1187
checkboxId : string | null = 'simple-check' ;
1271
- checkboxColor : ThemePalette = 'primary' ;
1188
+ checkboxColor : string = 'primary' ;
1272
1189
checkboxValue : string = 'single_checkbox' ;
1273
1190
1274
1191
onCheckboxClick : ( event ?: Event ) => void = ( ) => { } ;
@@ -1389,8 +1306,3 @@ class CheckboxWithProjectedLabel {}
1389
1306
class TextBindingComponent {
1390
1307
text : string = 'Some text' ;
1391
1308
}
1392
-
1393
- /** Test component with a simple checkbox with no inputs. */
1394
- @Component ( { template : `<mat-checkbox></mat-checkbox>` } )
1395
- class SimpleCheckbox {
1396
- }
0 commit comments