@@ -3,22 +3,24 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
33import { AccordionButtonDirective } from '../accordion-button/accordion-button.directive' ;
44import { AccordionService } from '../accordion.service' ;
55import { AccordionItemComponent } from './accordion-item.component' ;
6+ import { ComponentRef } from '@angular/core' ;
67
78describe ( 'AccordionItemComponent' , ( ) => {
89 let component : AccordionItemComponent ;
10+ let componentRef : ComponentRef < AccordionItemComponent > ;
911 let fixture : ComponentFixture < AccordionItemComponent > ;
1012
1113 beforeEach ( async ( ) => {
1214 await TestBed . configureTestingModule ( {
1315 providers : [ AccordionService ] ,
1416 imports : [ NoopAnimationsModule , AccordionButtonDirective , AccordionItemComponent ]
15- } )
16- . compileComponents ( ) ;
17+ } ) . compileComponents ( ) ;
1718 } ) ;
1819
1920 beforeEach ( ( ) => {
2021 fixture = TestBed . createComponent ( AccordionItemComponent ) ;
2122 component = fixture . componentInstance ;
23+ componentRef = fixture . componentRef ;
2224 fixture . detectChanges ( ) ;
2325 } ) ;
2426
@@ -29,4 +31,12 @@ describe('AccordionItemComponent', () => {
2931 it ( 'should have css classes' , ( ) => {
3032 expect ( fixture . nativeElement ) . toHaveClass ( 'accordion-item' ) ;
3133 } ) ;
34+
35+ it ( 'should toggle item' , ( ) => {
36+ expect ( component . visible ) . toBeFalse ( ) ;
37+ component . toggleItem ( ) ;
38+ expect ( component . visible ) . toBeTrue ( ) ;
39+ component . toggleItem ( ) ;
40+ expect ( component . visible ) . toBeFalse ( ) ;
41+ } ) ;
3242} ) ;
0 commit comments