@@ -4,13 +4,9 @@ import {TestBed, fakeAsync, tick} from '@angular/core/testing';
44import { FormControl , ReactiveFormsModule } from '@angular/forms' ;
55import { By } from '@angular/platform-browser' ;
66import { dispatchFakeEvent , dispatchKeyboardEvent , dispatchMouseEvent } from '../testing/private' ;
7- import { CdkListbox , CdkListboxModule , CdkOption , ListboxValueChangeEvent } from './index' ;
7+ import { CdkListbox , CdkOption , ListboxValueChangeEvent } from './index' ;
88
9- function setupComponent < T , O = string > ( component : Type < T > , imports : any [ ] = [ ] ) {
10- TestBed . configureTestingModule ( {
11- imports : [ CdkListboxModule , ...imports ] ,
12- declarations : [ component ] ,
13- } ) ;
9+ function setupComponent < T , O = string > ( component : Type < T > ) {
1410 const fixture = TestBed . createComponent ( component ) ;
1511 fixture . detectChanges ( ) ;
1612
@@ -861,29 +857,23 @@ describe('CdkOption and CdkListbox', () => {
861857
862858 describe ( 'with FormControl' , ( ) => {
863859 it ( 'should reflect disabled state of the FormControl' , ( ) => {
864- const { testComponent, fixture, listbox} = setupComponent ( ListboxWithFormControl , [
865- ReactiveFormsModule ,
866- ] ) ;
860+ const { testComponent, fixture, listbox} = setupComponent ( ListboxWithFormControl ) ;
867861 testComponent . formControl . disable ( ) ;
868862 fixture . detectChanges ( ) ;
869863
870864 expect ( listbox . disabled ) . toBeTrue ( ) ;
871865 } ) ;
872866
873867 it ( 'should update when FormControl value changes' , ( ) => {
874- const { testComponent, fixture, options} = setupComponent ( ListboxWithFormControl , [
875- ReactiveFormsModule ,
876- ] ) ;
868+ const { testComponent, fixture, options} = setupComponent ( ListboxWithFormControl ) ;
877869 testComponent . formControl . setValue ( [ 'banana' ] ) ;
878870 fixture . detectChanges ( ) ;
879871
880872 expect ( options [ 2 ] . isSelected ( ) ) . toBeTrue ( ) ;
881873 } ) ;
882874
883875 it ( 'should update FormControl when selection changes' , ( ) => {
884- const { testComponent, fixture, optionEls} = setupComponent ( ListboxWithFormControl , [
885- ReactiveFormsModule ,
886- ] ) ;
876+ const { testComponent, fixture, optionEls} = setupComponent ( ListboxWithFormControl ) ;
887877 const spy = jasmine . createSpy ( ) ;
888878 const subscription = testComponent . formControl . valueChanges . subscribe ( spy ) ;
889879 fixture . detectChanges ( ) ;
@@ -898,9 +888,7 @@ describe('CdkOption and CdkListbox', () => {
898888 } ) ;
899889
900890 it ( 'should update multi-select listbox when FormControl value changes' , ( ) => {
901- const { testComponent, fixture, options} = setupComponent ( ListboxWithFormControl , [
902- ReactiveFormsModule ,
903- ] ) ;
891+ const { testComponent, fixture, options} = setupComponent ( ListboxWithFormControl ) ;
904892 testComponent . isMultiselectable = true ;
905893 fixture . changeDetectorRef . markForCheck ( ) ;
906894 fixture . detectChanges ( ) ;
@@ -912,9 +900,7 @@ describe('CdkOption and CdkListbox', () => {
912900 } ) ;
913901
914902 it ( 'should update FormControl when multi-selection listbox changes' , ( ) => {
915- const { testComponent, fixture, optionEls} = setupComponent ( ListboxWithFormControl , [
916- ReactiveFormsModule ,
917- ] ) ;
903+ const { testComponent, fixture, optionEls} = setupComponent ( ListboxWithFormControl ) ;
918904 testComponent . isMultiselectable = true ;
919905 fixture . changeDetectorRef . markForCheck ( ) ;
920906 fixture . detectChanges ( ) ;
@@ -935,9 +921,7 @@ describe('CdkOption and CdkListbox', () => {
935921 } ) ;
936922
937923 it ( 'should throw when multiple values selected in single-select listbox' , ( ) => {
938- const { testComponent, fixture} = setupComponent ( ListboxWithFormControl , [
939- ReactiveFormsModule ,
940- ] ) ;
924+ const { testComponent, fixture} = setupComponent ( ListboxWithFormControl ) ;
941925
942926 expect ( ( ) => {
943927 testComponent . formControl . setValue ( [ 'orange' , 'banana' ] ) ;
@@ -946,9 +930,7 @@ describe('CdkOption and CdkListbox', () => {
946930 } ) ;
947931
948932 it ( 'should throw when an invalid value is selected' , ( ) => {
949- const { testComponent, fixture} = setupComponent ( ListboxWithFormControl , [
950- ReactiveFormsModule ,
951- ] ) ;
933+ const { testComponent, fixture} = setupComponent ( ListboxWithFormControl ) ;
952934 testComponent . isMultiselectable = true ;
953935 fixture . changeDetectorRef . markForCheck ( ) ;
954936 fixture . detectChanges ( ) ;
@@ -961,13 +943,13 @@ describe('CdkOption and CdkListbox', () => {
961943
962944 it ( 'should not throw on init with a preselected form control and a dynamic set of options' , ( ) => {
963945 expect ( ( ) => {
964- setupComponent ( ListboxWithPreselectedFormControl , [ ReactiveFormsModule ] ) ;
946+ setupComponent ( ListboxWithPreselectedFormControl ) ;
965947 } ) . not . toThrow ( ) ;
966948 } ) ;
967949
968950 it ( 'should throw on init if the preselected value is invalid' , ( ) => {
969951 expect ( ( ) => {
970- setupComponent ( ListboxWithInvalidPreselectedFormControl , [ ReactiveFormsModule ] ) ;
952+ setupComponent ( ListboxWithInvalidPreselectedFormControl ) ;
971953 } ) . toThrowError ( 'Listbox has selected values that do not match any of its options.' ) ;
972954 } ) ;
973955 } ) ;
@@ -1000,7 +982,7 @@ describe('CdkOption and CdkListbox', () => {
1000982 <div cdkOption="peach">Peach</div>
1001983 </div>
1002984 ` ,
1003- standalone : false ,
985+ imports : [ CdkListbox , CdkOption ] ,
1004986} )
1005987class ListboxWithOptions {
1006988 changedOption : CdkOption | null ;
@@ -1026,7 +1008,7 @@ class ListboxWithOptions {
10261008
10271009@Component ( {
10281010 template : `<div cdkListbox></div>` ,
1029- standalone : false ,
1011+ imports : [ CdkListbox ] ,
10301012} )
10311013class ListboxWithNoOptions { }
10321014
@@ -1042,7 +1024,7 @@ class ListboxWithNoOptions {}
10421024 <div cdkOption="peach">Peach</div>
10431025 </div>
10441026 ` ,
1045- standalone : false ,
1027+ imports : [ CdkListbox , CdkOption , ReactiveFormsModule ] ,
10461028} )
10471029class ListboxWithFormControl {
10481030 formControl = new FormControl ( ) ;
@@ -1058,7 +1040,7 @@ class ListboxWithFormControl {
10581040 }
10591041 </div>
10601042 ` ,
1061- standalone : false ,
1043+ imports : [ CdkListbox , CdkOption , ReactiveFormsModule ] ,
10621044} )
10631045class ListboxWithPreselectedFormControl {
10641046 options = [ 'a' , 'b' , 'c' ] ;
@@ -1073,7 +1055,7 @@ class ListboxWithPreselectedFormControl {
10731055 }
10741056 </div>
10751057 ` ,
1076- standalone : false ,
1058+ imports : [ CdkListbox , CdkOption , ReactiveFormsModule ] ,
10771059} )
10781060class ListboxWithInvalidPreselectedFormControl {
10791061 options = [ 'a' , 'b' , 'c' ] ;
@@ -1089,7 +1071,7 @@ class ListboxWithInvalidPreselectedFormControl {
10891071 <li cdkOption="peach" cdkOptionTypeaheadLabel="peach">🍑</li>
10901072 </ul>
10911073 ` ,
1092- standalone : false ,
1074+ imports : [ CdkListbox , CdkOption ] ,
10931075} )
10941076class ListboxWithCustomTypeahead { }
10951077
@@ -1103,7 +1085,7 @@ class ListboxWithCustomTypeahead {}
11031085 <div cdkOption="peach">Peach</div>
11041086 </div>
11051087 ` ,
1106- standalone : false ,
1088+ imports : [ CdkListbox , CdkOption ] ,
11071089} )
11081090class ListboxWithBoundValue {
11091091 value = [ 'banana' ] ;
@@ -1120,7 +1102,7 @@ class ListboxWithBoundValue {
11201102 <div cdkOption="peach">Peach</div>
11211103 </div>
11221104 ` ,
1123- standalone : false ,
1105+ imports : [ CdkListbox , CdkOption ] ,
11241106} )
11251107class ListboxWithMultipleBoundValues {
11261108 value = [ 'apple' , 'banana' ] ;
@@ -1134,7 +1116,7 @@ class ListboxWithMultipleBoundValues {
11341116 }
11351117 </div>
11361118 ` ,
1137- standalone : false ,
1119+ imports : [ CdkListbox , CdkOption ] ,
11381120} )
11391121class ListboxWithObjectValues {
11401122 fruits = [ { name : 'Apple' } , { name : 'Orange' } , { name : 'Banana' } , { name : 'Peach' } ] ;
0 commit comments