Newer
Older
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Component, Input, Output, EventEmitter, ViewChild } from '@angular/core';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ToastrModule } from 'ngx-toastr';
import { ToastrService } from 'ngx-toastr';
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { OutputTabsComponent } from './output-tabs.component';
import { Attribute, Family, Category } from '../../../metamodel/model';
import { ATTRIBUTE_LIST, OUTPUT_FAMILY_LIST , CATEGORY_LIST } from '../../../../settings/test-data';
describe('[Search][Output] Component: OutputTabsComponent', () => {
@Component({
selector: `app-host`,
template: `
<app-output-tabs
[outputFamilyList]="outputFamilyList"
[categoryList]="categoryList"
[datasetAttributeList]="datasetAttributeList"
[outputList]="outputList">
</app-output-tabs>`
})
class TestHostComponent {
@ViewChild(OutputTabsComponent, { static: false })
public testedComponent: OutputTabsComponent;
private outputFamilyList: Family[] = OUTPUT_FAMILY_LIST;
private datasetAttributeList: Attribute[] = ATTRIBUTE_LIST;
private categoryList: Category[] = CATEGORY_LIST;
private outputList: number[] = [1];
}
@Component({ selector: 'app-output-by-family', template: '' })
class OutputByFamilyStubComponent {
@Input() outputFamily: Family;
@Input() categoryList: Category[];
@Input() datasetAttributeList: Attribute[];
@Input() outputList: number[];
@Output() change: EventEmitter<number[]> = new EventEmitter();
}
let testHostComponent: TestHostComponent;
let testHostFixture: ComponentFixture<TestHostComponent>;
let testedComponent: OutputTabsComponent;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
OutputTabsComponent,
TestHostComponent,
OutputByFamilyStubComponent
],
imports: [AccordionModule.forRoot(), BrowserAnimationsModule, ToastrModule.forRoot()],
providers: [ToastrService]
});
testHostFixture = TestBed.createComponent(TestHostComponent);
testHostComponent = testHostFixture.componentInstance;
testHostFixture.detectChanges();
testedComponent = testHostComponent.testedComponent;
}));
it('should create the component', () => {
expect(testedComponent).toBeTruthy();
});
});