Skip to content

Commit

Permalink
test(treeGrid): create tree-grid-search.spec.ts file #3519
Browse files Browse the repository at this point in the history
  • Loading branch information
Tacho committed Jan 18, 2019
1 parent 4a6a4a0 commit 4e37998
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { async, TestBed } from '@angular/core/testing';
import { IgxTreeGridComponent } from './tree-grid.component';
import { IgxTreeGridModule } from './index';
import { TreeGridFunctions } from '../../test-utils/tree-grid-functions.spec';
import { IgxTreeGridSearchComponent, IgxTreeGridPrimaryForeignKeyComponent } from '../../test-utils/tree-grid-components.spec';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { configureTestSuite } from '../../test-utils/configure-suite';


describe('IgxTreeGrid - search API', () => {
configureTestSuite();
let fix;
let treeGrid: IgxTreeGridComponent;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
IgxTreeGridSearchComponent,
IgxTreeGridPrimaryForeignKeyComponent
],
imports: [IgxTreeGridModule, NoopAnimationsModule]
}).compileComponents();
}));

describe('Child Collection', () => {
beforeEach(() => {
fix = TestBed.createComponent(IgxTreeGridSearchComponent);
fix.detectChanges();
treeGrid = fix.componentInstance.treeGrid;
});

});

describe('Primary/Foreign key', () => {
beforeEach(() => {
fix = TestBed.createComponent(IgxTreeGridPrimaryForeignKeyComponent);
fix.detectChanges();
treeGrid = fix.componentInstance.treeGrid;
});

});
});
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,86 @@ export class SampleTestData {
}
])

/* Search tree data: Every employee node has ID, Name, HireDate, Age, JobTitle and Employees */
public static employeeSearchTreeData = () => ([
{
ID: 147,
Name: 'John Winchester',
HireDate: new Date(2008, 3, 20),
Age: 55,
JobTitle: 'Director',
Employees: [
{
ID: 475,
Name: 'Michael Langdon',
HireDate: new Date(2011, 6, 3),
Age: 30,
JobTitle: 'Junior Software Developer',
Employees: null
},
{
ID: 957,
Name: 'Thomas Hardy',
HireDate: new Date(2009, 6, 19),
Age: 29,
JobTitle: 'Junior Software Developer',
Employees: undefined
},
{
ID: 317,
Name: 'Monica Reyes',
HireDate: new Date(2014, 8, 18),
Age: 31,
JobTitle: 'Manager',
Employees: [
{
ID: 711,
Name: 'Roland Mendel',
HireDate: new Date(2015, 9, 17),
JobTitle: 'Senior Software Developer',
Age: 35
},
{
ID: 998,
Name: 'Sven Ottlieb',
HireDate: new Date(2009, 10, 11),
JobTitle: 'Senior Software Developer',
Age: 44
},
{
ID: 299,
Name: 'Peter Lewis',
HireDate: new Date(2018, 3, 18),
JobTitle: 'QA Developer',
Age: 25
}
]
}]
},
{
ID: 19,
Name: 'Yang Wang',
HireDate: new Date(2010, 1, 1),
JobTitle: 'Software Developer',
Age: 61
},
{
ID: 847,
Name: 'Ana Sanders',
HireDate: new Date(2014, 1, 22),
Age: 42,
JobTitle: 'QA Developer',
Employees: [
{
ID: 663,
Name: 'Elizabeth Richards',
HireDate: new Date(2017, 11, 9),
JobTitle: 'Software Developer',
Age: 25
}]
}
])

/* All types tree data: Every employee node has ID, Name, HireDate, Age, OnPTO and Employees */
public static employeeAllTypesTreeData = () => ([
{
Expand Down Expand Up @@ -1304,7 +1384,7 @@ export class SampleTestData {
])

public static employeeGroupByData = () => ([
{
{
ID: 475,
ParentID: 147,
Name: 'Michael Langdon',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,3 +456,19 @@ export class IgxTreeGridSummariesScrollingComponent {
@ViewChild(IgxTreeGridComponent) public treeGrid: IgxTreeGridComponent;
public data = SampleTestData.employeeScrollingData();
}

@Component({
template: `
<igx-tree-grid #treeGrid [data]="data" childDataKey="Employees" width="900px" height="600px">
<igx-column [field]="'JobTitle'" dataType="string"></igx-column>
<igx-column [field]="'ID'" dataType="number"></igx-column>
<igx-column [field]="'Name'" dataType="string"></igx-column>
<igx-column [field]="'HireDate'" dataType="date"></igx-column>
<igx-column [field]="'Age'" dataType="number"></igx-column>
</igx-tree-grid>
`
})
export class IgxTreeGridSearchComponent {
@ViewChild(IgxTreeGridComponent) public treeGrid: IgxTreeGridComponent;
public data = SampleTestData.employeeSearchTreeData();
}

0 comments on commit 4e37998

Please sign in to comment.