@@ -3,22 +3,24 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
3
3
import { AccordionButtonDirective } from '../accordion-button/accordion-button.directive' ;
4
4
import { AccordionService } from '../accordion.service' ;
5
5
import { AccordionItemComponent } from './accordion-item.component' ;
6
+ import { ComponentRef } from '@angular/core' ;
6
7
7
8
describe ( 'AccordionItemComponent' , ( ) => {
8
9
let component : AccordionItemComponent ;
10
+ let componentRef : ComponentRef < AccordionItemComponent > ;
9
11
let fixture : ComponentFixture < AccordionItemComponent > ;
10
12
11
13
beforeEach ( async ( ) => {
12
14
await TestBed . configureTestingModule ( {
13
15
providers : [ AccordionService ] ,
14
16
imports : [ NoopAnimationsModule , AccordionButtonDirective , AccordionItemComponent ]
15
- } )
16
- . compileComponents ( ) ;
17
+ } ) . compileComponents ( ) ;
17
18
} ) ;
18
19
19
20
beforeEach ( ( ) => {
20
21
fixture = TestBed . createComponent ( AccordionItemComponent ) ;
21
22
component = fixture . componentInstance ;
23
+ componentRef = fixture . componentRef ;
22
24
fixture . detectChanges ( ) ;
23
25
} ) ;
24
26
@@ -29,4 +31,12 @@ describe('AccordionItemComponent', () => {
29
31
it ( 'should have css classes' , ( ) => {
30
32
expect ( fixture . nativeElement ) . toHaveClass ( 'accordion-item' ) ;
31
33
} ) ;
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
+ } ) ;
32
42
} ) ;
0 commit comments