|
| 1 | +import { |
| 2 | + Component, |
| 3 | + DebugElement, |
| 4 | +} from '@angular/core'; |
1 | 5 | import {
|
2 | 6 | waitForAsync,
|
3 | 7 | ComponentFixture,
|
4 | 8 | TestBed,
|
5 | 9 | } from '@angular/core/testing';
|
| 10 | +import { By } from '@angular/platform-browser'; |
6 | 11 |
|
7 | 12 | import { DaffModalActionsComponent } from './modal-actions.component';
|
8 | 13 |
|
| 14 | +@Component({ |
| 15 | + template: ` |
| 16 | + <daff-modal-actions> |
| 17 | + <button>Close</button> |
| 18 | + <button>Save</button> |
| 19 | + </daff-modal-actions> |
| 20 | + `, |
| 21 | + standalone: true, |
| 22 | + imports: [ |
| 23 | + DaffModalActionsComponent, |
| 24 | + ], |
| 25 | +}) |
| 26 | +class WrapperComponent {} |
| 27 | + |
9 | 28 | describe('@daffodil/design/modal | DaffModalActionsComponent', () => {
|
| 29 | + let wrapper: WrapperComponent; |
| 30 | + let fixture: ComponentFixture<WrapperComponent>; |
10 | 31 | let component: DaffModalActionsComponent;
|
11 |
| - let fixture: ComponentFixture<DaffModalActionsComponent>; |
| 32 | + let de: DebugElement; |
12 | 33 |
|
13 | 34 | beforeEach(waitForAsync(() => {
|
14 | 35 | TestBed.configureTestingModule({
|
15 |
| - declarations: [ |
16 |
| - DaffModalActionsComponent, |
| 36 | + imports: [ |
| 37 | + WrapperComponent, |
17 | 38 | ],
|
18 | 39 | })
|
19 | 40 | .compileComponents();
|
20 | 41 | }));
|
21 | 42 |
|
22 | 43 | beforeEach(() => {
|
23 |
| - fixture = TestBed.createComponent(DaffModalActionsComponent); |
24 |
| - component = fixture.componentInstance; |
| 44 | + fixture = TestBed.createComponent(WrapperComponent); |
| 45 | + wrapper = fixture.componentInstance; |
| 46 | + |
| 47 | + de = fixture.debugElement.query(By.css('daff-modal-actions')); |
| 48 | + component = de.componentInstance; |
25 | 49 | fixture.detectChanges();
|
26 | 50 | });
|
27 | 51 |
|
28 | 52 | it('should create', () => {
|
29 |
| - expect(component).toBeTruthy(); |
| 53 | + expect(wrapper).toBeTruthy(); |
| 54 | + }); |
| 55 | + |
| 56 | + it('should add a class of "daff-modal-actions" to the host element', () => { |
| 57 | + expect(de.classes).toEqual(jasmine.objectContaining({ |
| 58 | + 'daff-modal-actions': true, |
| 59 | + })); |
30 | 60 | });
|
31 | 61 | });
|
0 commit comments