Skip to content

Commit

Permalink
test(search): add tests for #3520 and #3653
Browse files Browse the repository at this point in the history
  • Loading branch information
DiyanDimitrov committed Jan 30, 2019
1 parent 9ba11a6 commit 00049aa
Showing 1 changed file with 36 additions and 8 deletions.
44 changes: 36 additions & 8 deletions projects/igniteui-angular/src/lib/grids/grid/grid.search.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -713,9 +713,12 @@ describe('IgxGrid - search API', () => {
expect(highlights.length).toBe(1);
expect(activeHighlight).toBe(highlights[0]);

cell.inEditMode = false;
await wait(30);
const nextCell = grid.getCellByColumn(0, 'JobTitle').nativeElement;
nextCell.dispatchEvent(new Event('click'));
await wait();
fix.detectChanges();

expect(cell.nativeElement.innerText.trim()).toBe('Casey Houston');
});
});

Expand Down Expand Up @@ -1178,13 +1181,38 @@ describe('IgxGrid - search API', () => {
});

/* Grid with Avatar */
it('Cells with no text should be excluded from the search', () => {
fix = TestBed.createComponent(GridWithAvatarComponent);
grid = fix.componentInstance.grid;
fix.detectChanges();
describe('', () => {
beforeEach(() => {
fix = TestBed.createComponent(GridWithAvatarComponent);
grid = fix.componentInstance.grid;
fix.detectChanges();
});

it('Cells with no text should be excluded from the search', () => {
const matches = grid.findNext('https');
expect(matches).toBe(0);
});

const matches = grid.findNext('https');
expect(matches).toBe(0);
it('Cells with custom template should be excluded from search when pin/unpin', () => {
grid.columns[1].pinned = true;
fix.detectChanges();

const matches = grid.findNext('https');
expect(matches).toBe(0);

let cell = grid.getCellByColumn(0, 'Avatar').nativeElement;
expect(cell.children.length).toBe(1);
let image = cell.querySelector('.cell__inner, .avatar-cell');
expect(image.hidden).toBeFalsy();

grid.columns[1].pinned = false;
fix.detectChanges();

cell = grid.getCellByColumn(0, 'Avatar').nativeElement;
expect(cell.children.length).toBe(1);
image = cell.querySelector('.cell__inner, .avatar-cell');
expect(image.hidden).toBeFalsy();
});
});

function findNext(currentGrid: IgxGridComponent, text: string) {
Expand Down

0 comments on commit 00049aa

Please sign in to comment.