@@ -12,13 +12,17 @@ import { By } from '@angular/platform-browser';
12
12
import { DaffSidebarHeaderComponent } from './sidebar-header.component' ;
13
13
14
14
@Component ( {
15
- template : `<daff-sidebar-header>Header</daff-sidebar-header>` ,
15
+ template : `
16
+ <daff-sidebar-header [dismissible]="dismissible" (closeSidebar)="closeSidebarFunction()">Header</daff-sidebar-header>` ,
16
17
standalone : true ,
17
18
imports : [
18
19
DaffSidebarHeaderComponent ,
19
20
] ,
20
21
} )
21
- class WrapperComponent { }
22
+ class WrapperComponent {
23
+ dismissible : boolean ;
24
+ closeSidebarFunction = ( ) => { } ;
25
+ }
22
26
23
27
describe ( '@daffodil/design/sidebar | DaffSidebarHeaderComponent' , ( ) => {
24
28
let wrapper : WrapperComponent ;
@@ -53,4 +57,32 @@ describe('@daffodil/design/sidebar | DaffSidebarHeaderComponent', () => {
53
57
'daff-sidebar-header' : true ,
54
58
} ) ) ;
55
59
} ) ;
60
+
61
+ describe ( 'when dismissible is set to true' , ( ) => {
62
+ beforeEach ( ( ) => {
63
+ wrapper . dismissible = true ;
64
+ fixture . detectChanges ( ) ;
65
+ } ) ;
66
+
67
+ it ( 'should add a class of "dismissible" to the host element' , ( ) => {
68
+ expect ( de . classes [ 'dismissible' ] ) . toBeTrue ( ) ;
69
+ } ) ;
70
+
71
+ it ( 'should show the close icon button' , ( ) => {
72
+ expect ( fixture . debugElement . query ( By . css ( '.daff-sidebar-header__close-icon' ) ) ) . toBeTruthy ( ) ;
73
+ } ) ;
74
+ } ) ;
75
+
76
+ describe ( 'when the close icon button is clicked' , ( ) => {
77
+ it ( 'should emit closeNotification' , ( ) => {
78
+ wrapper . dismissible = true ;
79
+ fixture . detectChanges ( ) ;
80
+
81
+ spyOn ( component . closeSidebar , 'emit' ) ;
82
+
83
+ fixture . debugElement . query ( By . css ( '.daff-sidebar-header__close-icon' ) ) . nativeElement . click ( ) ;
84
+
85
+ expect ( component . closeSidebar . emit ) . toHaveBeenCalledWith ( ) ;
86
+ } ) ;
87
+ } ) ;
56
88
} ) ;
0 commit comments