Newer
Older
import { Component, Input } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { AccordionModule } from 'ngx-bootstrap/accordion';
import { CriteriaTabsComponent } from './criteria-tabs.component';
import { Attribute } from '../../../../metamodel/models';
import { Criterion, FieldCriterion, SvomKeyword } from '../../../store/models';
import { AttributeListByFamilyPipe } from '../../../../shared/pipes/attribute-list-by-family.pipe';
describe('[Instance][Search][Component][Criteria] CriteriaTabsComponent', () => {
@Component({ selector: 'app-criteria-by-family', template: '' })
class CriteriaByFamilyStubComponent {
@Input() attributeList: Attribute[];
@Input() criteriaList: Criterion[];
@Input() svomKeywords: SvomKeyword[];
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
52
53
54
}
let component: CriteriaTabsComponent;
let fixture: ComponentFixture<CriteriaTabsComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
CriteriaTabsComponent,
CriteriaByFamilyStubComponent,
AttributeListByFamilyPipe
],
imports: [
AccordionModule.forRoot(),
BrowserAnimationsModule
]
});
fixture = TestBed.createComponent(CriteriaTabsComponent);
component = fixture.componentInstance;
});
it('should create the component', () => {
expect(component).toBeTruthy();
});
it('raises the add criterion event when clicked', () => {
const criterion = { id: 1, type: 'field', operator: 'eq', value: 'test' } as FieldCriterion;
component.addCriterion.subscribe((event: FieldCriterion) => expect(event).toEqual(criterion));
component.emitAdd(criterion);
});
it('raises the delete criterion event when clicked', () => {
const criterionId = 1;
component.deleteCriterion.subscribe((event: number) => expect(event).toEqual(1));
component.emitDelete(criterionId);
});
});