Newer
Older
1
2
3
4
5
6
7
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// import { async, ComponentFixture, TestBed } from '@angular/core/testing';
// import { Component, Input, Output, EventEmitter, ViewChild } from '@angular/core';
//
// import { DatasetListComponent } from './output-by-family.component';
// import { Attribute, Family, Category } from '../../../metamodel/model';
// import { ATTRIBUTE_LIST, OUTPUT_FAMILY, CATEGORY_LIST } from '../../../../settings/test-data';
//
// describe('[Search][Output] Component: OutputByFamilyComponent', () => {
// @Component({
// selector: `app-host`,
// template: `
// <app-output-by-family
// [outputFamily]="outputFamily"
// [datasetAttributeList]="datasetAttributeList"
// [categoryList]="categoryList"
// [outputList]="outputList">
// </app-output-by-family>`
// })
// class TestHostComponent {
// @ViewChild(DatasetListComponent, { static: false })
// public testedComponent: DatasetListComponent;
// public outputFamily: Family = OUTPUT_FAMILY;
// public datasetAttributeList: Attribute[] = ATTRIBUTE_LIST;
// public categoryList: Category[] = CATEGORY_LIST;
// public outputList: number[] = [1];
// }
//
// @Component({ selector: 'app-output-by-category', template: '' })
// class OutputByCategoryStubComponent {
// @Input() categoryLabel: string;
// @Input() attributeList: Attribute[];
// @Input() outputList: number[];
// @Input() isAllSelected: boolean;
// @Input() isAllUnselected: boolean;
// @Output() change: EventEmitter<number[]> = new EventEmitter();
// }
//
// let testHostComponent: TestHostComponent;
// let testHostFixture: ComponentFixture<TestHostComponent>;
// let testedComponent: DatasetListComponent;
//
// beforeEach(async(() => {
// TestBed.configureTestingModule({
// declarations: [
// DatasetListComponent,
// TestHostComponent,
// OutputByCategoryStubComponent
// ]
// });
// testHostFixture = TestBed.createComponent(TestHostComponent);
// testHostComponent = testHostFixture.componentInstance;
// testHostFixture.detectChanges();
// testedComponent = testHostComponent.testedComponent;
// }));
//
// it('should create the component', () => {
// expect(testedComponent).toBeTruthy();
// });
//
// it('#getCategoryByFamilySortedByDisplay(idFamily) should sort by display categories belonging to idFamily', () => {
// const sortedCategoryList: Category[] = testedComponent.getCategoryByFamilySortedByDisplay(1);
// expect(sortedCategoryList.length).toBe(2);
// expect(sortedCategoryList[0].id).toBe(2);
// expect(sortedCategoryList[1].id).toBe(1);
// });
//
// it('#getAttributeByCategory(idCategory) should return attributes belonging to idCategory', () => {
// expect(testedComponent.getAttributeByCategory(1).length).toBe(1);
// expect(testedComponent.getAttributeByCategory(1)[0].id).toBe(1);
// });
//
// it('#getIsAllSelected(idCategory) should return true if all outputs of idCategory are selected', () => {
// expect(testedComponent.getIsAllSelected(1)).toBeTruthy();
// });
//
// it('#getIsAllSelected(idCategory) should return false if not all outputs of idCategory are selected', () => {
// testedComponent.outputList = [];
// expect(testedComponent.getIsAllSelected(1)).toBeFalsy();
// });
//
// it('#getIsAllUnselected(idCategory) should return true if all outputs of idCategory are not selected', () => {
// testedComponent.outputList = [];
// expect(testedComponent.getIsAllUnselected(1)).toBeTruthy();
// });
//
// it('#getIsAllUnselected(idCategory) should return false if not all outputs of idCategory are not selected', () => {
// expect(testedComponent.getIsAllUnselected(1)).toBeFalsy();
// });
//
// it('#emitChange(outputList) should raise change event', () => {
// const expectedOutputList = [1];
// testedComponent.change.subscribe((event: number[]) => expect(event).toEqual(expectedOutputList));
// testedComponent.emitChange([1]);
// });
// });
//