1- import { BrowserAnimationsModule } from "@angular/platform-browser/animations" ;
2- import {
3- ComponentFixture ,
4- TestBed ,
5- fakeAsync ,
6- tick ,
7- async
8- } from "@angular/core/testing" ;
1+ import { ComponentFixture , TestBed } from "@angular/core/testing" ;
92import { By } from "@angular/platform-browser" ;
103import { FormsModule } from "@angular/forms" ;
114import { DebugElement , Component } from "@angular/core" ;
@@ -14,12 +7,25 @@ import { StaticIconModule } from "../icon/static-icon.module";
147import { Radio } from "./radio.component" ;
158import { RadioGroup } from "./radio-group.component" ;
169
10+ @Component ( {
11+ selector : "test-cmp" ,
12+ template : `
13+ <ibm-radio-group [(ngModel)]="radio">
14+ <ibm-radio *ngFor="let one of manyRadios" [value]="one"
15+ class="indent">Radio {{one}}
16+ </ibm-radio>
17+ </ibm-radio-group>`
18+ } )
19+ class RadioTest {
20+ manyRadios = [ "one" , "two" , "three" , "four" , "five" , "six" ] ;
21+ radio : string ;
22+ }
23+
1724describe ( "RadioGroup" , ( ) => {
1825 beforeEach ( ( ) => {
1926 TestBed . configureTestingModule ( {
2027 declarations : [ Radio , RadioGroup , RadioTest ] ,
21- imports : [ BrowserAnimationsModule , FormsModule , StaticIconModule ] ,
22- providers : [ ]
28+ imports : [ FormsModule , StaticIconModule ]
2329 } ) ;
2430 } ) ;
2531
@@ -35,31 +41,15 @@ describe("RadioGroup", () => {
3541 const fixture = TestBed . createComponent ( RadioTest ) ;
3642 fixture . detectChanges ( ) ;
3743
38- const directiveEl = fixture . debugElement . query ( By . directive ( RadioGroup ) ) ;
3944 const radioOne = fixture . debugElement . query ( By . directive ( Radio ) ) ;
45+ radioOne . triggerEventHandler ( "click" , null ) ;
4046 radioOne . nativeElement . querySelector ( "input" ) . click ( ) ;
4147 fixture . detectChanges ( ) ;
4248
4349 expect ( fixture . componentInstance . radio ) . toBe ( "one" ) ;
4450 } ) ;
4551} ) ;
4652
47- @Component ( {
48- selector : "test-cmp" ,
49- template : `
50- <ibm-radio-group [(ngModel)]="radio">
51- <ibm-radio *ngFor="let one of manyRadios" [value]="one"
52- class="indent">Radio {{one}}
53- </ibm-radio>
54- </ibm-radio-group>` ,
55- entryComponents : [ Radio ]
56- } )
57- class RadioTest {
58- manyRadios = [ "one" , "two" , "three" , "four" , "five" , "six" ] ;
59- radio : string ;
60- }
61-
62-
6353describe ( "RadioComponent" , ( ) => {
6454 let component : Radio ;
6555 let fixture : ComponentFixture < Radio > ;
@@ -68,9 +58,7 @@ describe("RadioComponent", () => {
6858
6959 beforeEach ( ( ) => {
7060 TestBed . configureTestingModule ( {
71- declarations : [ Radio ] ,
72- imports : [ BrowserAnimationsModule ] ,
73- providers : [ ]
61+ declarations : [ Radio ]
7462 } ) ;
7563
7664 fixture = TestBed . createComponent ( Radio ) ;
0 commit comments