-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix(grid): add pipeTrigger in the AfterViewInit event #3467 * test(grid): add general test for treegrid default rendering #8347 * fix(grid): calling pipeTrigger is not needed #3467 * test(grid): move general test to component test file #3467 * test(grid): remove f from test file #3467
- Loading branch information
1 parent
c4f7b5e
commit c9017b5
Showing
4 changed files
with
149 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { async, TestBed, fakeAsync, tick } from '@angular/core/testing'; | ||
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; | ||
import { IgxTreeGridModule } from './index'; | ||
import { IgxTreeGridComponent } from './tree-grid.component'; | ||
import { DisplayDensity } from '../../core/displayDensity'; | ||
import { configureTestSuite } from '../../test-utils/configure-suite'; | ||
import { By } from '@angular/platform-browser'; | ||
import { IgxTreeGridWrappedInContComponent } from '../../test-utils/tree-grid-components.spec'; | ||
|
||
describe('IgxTreeGrid Component Tests', () => { | ||
|
||
describe('IgxTreeGrid - default rendering for rows and columns', () => { | ||
configureTestSuite(); | ||
let fix; | ||
let grid: IgxTreeGridComponent; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ | ||
IgxTreeGridWrappedInContComponent | ||
], | ||
imports: [ | ||
NoopAnimationsModule, IgxTreeGridModule] | ||
}).compileComponents(); | ||
})); | ||
|
||
beforeEach(async(() => { | ||
fix = TestBed.createComponent(IgxTreeGridWrappedInContComponent); | ||
grid = fix.componentInstance.treeGrid; | ||
})); | ||
|
||
it('should match width and height of parent container when width/height are set in %', fakeAsync(() => { | ||
fix.componentInstance.outerWidth = 800; | ||
fix.componentInstance.outerHeight = 600; | ||
grid.width = '50%'; | ||
grid.height = '50%'; | ||
tick(); | ||
fix.detectChanges(); | ||
|
||
expect(window.getComputedStyle(grid.nativeElement).height).toMatch('300px'); | ||
expect(window.getComputedStyle(grid.nativeElement).width).toMatch('400px'); | ||
expect(grid.rowList.length).toBeGreaterThan(0); | ||
})); | ||
|
||
it('should render 10 records if height is unset and parent container\'s height is unset', () => { | ||
fix.detectChanges(); | ||
const defaultHeight = fix.debugElement.query(By.css('.igx-grid__tbody')).styles.height; | ||
expect(defaultHeight).not.toBeNull(); | ||
expect(parseInt(defaultHeight, 10)).toBeGreaterThan(400); | ||
expect(fix.componentInstance.isVerticalScrollbarVisible()).toBeTruthy(); | ||
expect(grid.rowList.length).toBeGreaterThanOrEqual(10); | ||
}); | ||
|
||
it('should render 10 records if height is 100% and parent container\'s height is unset', fakeAsync(() => { | ||
grid.height = '600px'; | ||
tick(); | ||
fix.detectChanges(); | ||
const defaultHeight = fix.debugElement.query(By.css('.igx-grid__tbody')).styles.height; | ||
expect(defaultHeight).not.toBeNull(); | ||
expect(parseInt(defaultHeight, 10)).toBeGreaterThan(400); | ||
expect(fix.componentInstance.isVerticalScrollbarVisible()).toBeTruthy(); | ||
expect(grid.rowList.length).toBeGreaterThanOrEqual(10); | ||
})); | ||
|
||
it(`should render all records exactly if height is 100% and parent container\'s height is unset and | ||
there are fewer than 10 records in the data view`, fakeAsync(() => { | ||
grid.height = '100%'; | ||
fix.componentInstance.data = fix.componentInstance.data.slice(0, 1); | ||
tick(); | ||
fix.detectChanges(); | ||
const defaultHeight = fix.debugElement.query(By.css('.igx-grid__tbody')).styles.height; | ||
expect(defaultHeight).not.toBeNull(); | ||
expect(parseInt(defaultHeight, 10)).toBeGreaterThan(200); | ||
expect(fix.componentInstance.isVerticalScrollbarVisible()).toBeFalsy(); | ||
expect(grid.rowList.length).toEqual(6); | ||
})); | ||
|
||
it(`should render 11 records if height is 100% and parent container\'s height is unset and | ||
display density is changed`, fakeAsync(() => { | ||
grid.height = '100%'; | ||
fix.componentInstance.density = DisplayDensity.compact; | ||
tick(); | ||
fix.detectChanges(); | ||
const defaultHeight = fix.debugElement.query(By.css('.igx-grid__tbody')).styles.height; | ||
const defaultHeightNum = parseInt(defaultHeight, 10); | ||
expect(defaultHeight).not.toBeNull(); | ||
expect(defaultHeightNum).toBeGreaterThan(300); | ||
expect(defaultHeightNum).toBeLessThan(330); | ||
expect(fix.componentInstance.isVerticalScrollbarVisible()).toBeTruthy(); | ||
expect(grid.rowList.length).toEqual(11); | ||
})); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters