|
| 1 | +import { Component } from '@angular/core'; |
| 2 | +import { |
| 3 | + ComponentFixture, |
| 4 | + TestBed, |
| 5 | + waitForAsync, |
| 6 | +} from '@angular/core/testing'; |
| 7 | +import { By } from '@angular/platform-browser'; |
| 8 | +import { RouterTestingModule } from '@angular/router/testing'; |
| 9 | +import { provideMockStore } from '@ngrx/store/testing'; |
| 10 | + |
| 11 | +import { DAFF_ARTICLE_COMPONENTS } from '@daffodil/design/article'; |
| 12 | +import { |
| 13 | + DaffApiPackageDoc, |
| 14 | + DaffBreadcrumb, |
| 15 | + DaffDocTableOfContents, |
| 16 | +} from '@daffodil/docs-utils'; |
| 17 | + |
| 18 | +import { DaffioDocArticleComponent } from './component'; |
| 19 | +import { DaffioApiPackageComponent } from '../../api/components/api-package/api-package.component'; |
| 20 | +import { DaffioDocsFactory } from '../../testing/factories/docs.factory'; |
| 21 | +import { DaffioDocsTableOfContentsModule } from '../table-of-contents/table-of-contents.module'; |
| 22 | + |
| 23 | +@Component({ |
| 24 | + template: `<daffio-doc-article |
| 25 | + [toc]="tocValue" |
| 26 | + [breadcrumbs]="breadcrumbsValue" |
| 27 | + ></daffio-doc-article>`, |
| 28 | +}) |
| 29 | +class WrapperComponent { |
| 30 | + tocValue: DaffDocTableOfContents; |
| 31 | + breadcrumbsValue: Array<DaffBreadcrumb>; |
| 32 | +} |
| 33 | + |
| 34 | +describe('DaffioDocArticleComponent', () => { |
| 35 | + let component: DaffioDocArticleComponent; |
| 36 | + let fixture: ComponentFixture<WrapperComponent>; |
| 37 | + let wrapper: WrapperComponent; |
| 38 | + const docFactory = new DaffioDocsFactory(); |
| 39 | + |
| 40 | + beforeEach(waitForAsync(() => { |
| 41 | + TestBed.configureTestingModule({ |
| 42 | + imports: [ |
| 43 | + RouterTestingModule, |
| 44 | + DAFF_ARTICLE_COMPONENTS, |
| 45 | + DaffioDocsTableOfContentsModule, |
| 46 | + DaffioApiPackageComponent, |
| 47 | + ], |
| 48 | + declarations: [ |
| 49 | + WrapperComponent, |
| 50 | + DaffioDocArticleComponent, |
| 51 | + ], |
| 52 | + providers: [ |
| 53 | + provideMockStore(), |
| 54 | + ], |
| 55 | + }) |
| 56 | + .compileComponents(); |
| 57 | + })); |
| 58 | + |
| 59 | + beforeEach(() => { |
| 60 | + fixture = TestBed.createComponent(WrapperComponent); |
| 61 | + wrapper = fixture.componentInstance; |
| 62 | + wrapper.tocValue = []; |
| 63 | + wrapper.breadcrumbsValue = []; |
| 64 | + fixture.detectChanges(); |
| 65 | + |
| 66 | + component = fixture.debugElement.query(By.directive(DaffioDocArticleComponent)).componentInstance; |
| 67 | + }); |
| 68 | + |
| 69 | + it('should create', () => { |
| 70 | + expect(wrapper).toBeTruthy(); |
| 71 | + }); |
| 72 | + |
| 73 | + it('should take toc as an input', () => { |
| 74 | + expect(component.toc).toEqual(wrapper.tocValue); |
| 75 | + }); |
| 76 | + |
| 77 | + it('should take breadcrumbs as an input', () => { |
| 78 | + expect(component.breadcrumbs).toEqual(wrapper.breadcrumbsValue); |
| 79 | + }); |
| 80 | +}); |
0 commit comments