Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions projects/igniteui-angular/src/lib/dialog/dialog.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,14 @@ describe('Dialog', () => {
expect(overlayWrapper.classList.contains(OVERLAY_WRAPPER_CLASS)).toBe(false);
}));

it('Default button of the dialog is focused after opening the dialog and can be closed with keyboard.', (async() => {
it('Default button of the dialog is focused after opening the dialog and can be closed with keyboard.', fakeAsync( () => {
const fix = TestBed.createComponent(DialogComponent);
fix.detectChanges();

const dialog: IgxDialogComponent = fix.componentInstance.dialog as IgxDialogComponent;
dialog.open();
tick(100);
fix.detectChanges();
await wait(16);

// Verify dialog is opened and its default right button is focused
const dialogDOM = fix.debugElement.query(By.css('.igx-dialog'));
Expand All @@ -318,8 +318,8 @@ describe('Dialog', () => {

// Press 'escape' key
UIInteractions.simulateKeyDownEvent(document.activeElement, 'Escape');
tick(100);
fix.detectChanges();
await wait(16);

// Verify dialog is closed and its default right button is no longer focused
expect(document.activeElement).not.toBe(rightButton.nativeElement);
Expand All @@ -329,20 +329,18 @@ describe('Dialog', () => {
describe('Position settings', () => {
let fix;
let dialog;
let detect;

beforeEach( fakeAsync(() => {
fix = TestBed.createComponent(PositionSettingsDialogComponent);
fix.detectChanges();
dialog = fix.componentInstance.dialog;
detect = () => dialog.cdr.detectChanges();
}));

it('Define different position settings ', (async() => {
it('Define different position settings ', fakeAsync(() => {
const currentElement = fix.componentInstance;
dialog.open();
tick(16);
fix.detectChanges();
await wait(16);

expect(dialog.isOpen).toEqual(true);
const firstContentRect = document.getElementsByClassName(CLASS_OVERLAY_CONTENT_MODAL)[0].getBoundingClientRect();
Expand All @@ -352,17 +350,17 @@ describe('Dialog', () => {
expect(firstContentRect.top).toBeLessThanOrEqual(middleDialogPosition + 2, 'OffsetTop position check');

dialog.close();
tick(16);
fix.detectChanges();
await wait(16);

expect(dialog.isOpen).toEqual(false);
dialog.positionSettings = currentElement.newPositionSettings;
tick(16);
fix.detectChanges();
await wait(16);

dialog.open();
tick(16);
fix.detectChanges();
await wait(16);

expect(dialog.isOpen).toEqual(true);
const secondContentRect = document.getElementsByClassName(CLASS_OVERLAY_CONTENT_MODAL)[0].getBoundingClientRect();
Expand All @@ -372,13 +370,13 @@ describe('Dialog', () => {
expect(secondContentRect.left).toBeLessThanOrEqual(topDialogPosition + 2, 'OffsetLeft position check');

dialog.close();
tick(16);
fix.detectChanges();
await wait(16);

expect(dialog.isOpen).toEqual(false);
}));

it('Set animation settings', (async() => {
it('Set animation settings', () => {
const currentElement = fix.componentInstance;

// Check initial animation settings
Expand All @@ -390,12 +388,11 @@ describe('Dialog', () => {

dialog.positionSettings = currentElement.animationSettings;
fix.detectChanges();
await wait(16);

// Check the new animation settings
expect(dialog.positionSettings.openAnimation.options.params.duration).toEqual('800ms', 'Animation duration is set to 800ms');
expect(dialog.positionSettings.closeAnimation.options.params.duration).toEqual('700ms', 'Animation duration is set to 700ms');
}));
});
});

function dispatchEvent(element: HTMLElement, eventType: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ describe('IgxToggle', () => {
toggle.open();
tick();
expect(toggle.onOpened.emit).toHaveBeenCalledTimes(2);
const otherId = overlay.show(fixture.componentInstance.other);
const otherId = overlay.attach(fixture.componentInstance.other);
overlay.show(otherId);
overlay.hide(otherId);
tick();
expect(toggle.onClosed.emit).toHaveBeenCalledTimes(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2908,30 +2908,32 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
it('Verify condition chips are scrolled into/(out of) view by using arrow buttons.', (async () => {
grid.width = '700px';
fix.detectChanges();
await wait(100);

GridFunctions.clickFilterCellChip(fix, 'ProductName');
fix.detectChanges();
await wait(16);

// Add first chip.
GridFunctions.typeValueInFilterRowInput('a', fix);
fix.detectChanges();
await wait(16);
fix.detectChanges();
GridFunctions.submitFilterRowInput(fix);
await wait(200);
fix.detectChanges();
await wait(100);
// Add second chip.
GridFunctions.typeValueInFilterRowInput('e', fix);
await wait(16);
fix.detectChanges();
GridFunctions.submitFilterRowInput(fix);
await wait(100);
await wait(200);
fix.detectChanges();
// Add third chip.
GridFunctions.typeValueInFilterRowInput('i', fix);
await wait(16);
fix.detectChanges();
GridFunctions.submitFilterRowInput(fix);
await wait(100);
await wait(200);
fix.detectChanges();

verifyMultipleChipsVisibility(fix, [false, false, true]);
Expand Down Expand Up @@ -3277,7 +3279,7 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
it('Should not throw error when deleting the last chip', (async () => {
grid.width = '700px';
fix.detectChanges();
await wait(16);
await wait(100);

GridFunctions.clickFilterCellChip(fix, 'ProductName');
fix.detectChanges();
Expand Down Expand Up @@ -3360,10 +3362,9 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
expect(chips.length).toBe(3);

GridFunctions.removeFilterChipByIndex(2, filterUIRow);
// wait for chip to be scrolled in view
fix.detectChanges();
// wait for chip to be scrolled in view
fix.detectChanges();
await wait(200);
await wait(200);

verifyMultipleChipsVisibility(fix, [true, false]);
chips = filterUIRow.queryAll(By.directive(IgxChipComponent));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('IgxHierarchicalGrid Basic Navigation #hGrid', () => {
}));

beforeEach(async(() => {
resizeObserverIgnoreError();
fixture = TestBed.createComponent(IgxHierarchicalGridTestBaseComponent);
fixture.detectChanges();
hierarchicalGrid = fixture.componentInstance.hgrid;
Expand Down Expand Up @@ -295,7 +296,6 @@ describe('IgxHierarchicalGrid Basic Navigation #hGrid', () => {
}));

it('should not lose focus when pressing Ctrl+ArrowDown is pressed at the bottom row(expended) in a child grid.', (async () => {
resizeObserverIgnoreError();
hierarchicalGrid.height = '600px';
hierarchicalGrid.width = '800px';
fixture.componentInstance.rowIsland.height = '400px';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { DisplayDensity } from '../../core/displayDensity';
import { IgxStringFilteringOperand } from '../../data-operations/filtering-condition';
import { IGridCellEventArgs } from '../grid';
import { GridSelectionMode } from '../common/enums';
import { resizeObserverIgnoreError } from '../../test-utils/helper-utils.spec';

describe('Basic IgxHierarchicalGrid #hGrid', () => {
configureTestSuite();
Expand All @@ -29,6 +30,7 @@ describe('Basic IgxHierarchicalGrid #hGrid', () => {
}));

beforeEach(async(() => {
resizeObserverIgnoreError();
fixture = TestBed.createComponent(IgxHierarchicalGridTestBaseComponent);
fixture.detectChanges();
hierarchicalGrid = fixture.componentInstance.hgrid;
Expand Down Expand Up @@ -422,6 +424,7 @@ describe('IgxHierarchicalGrid Row Islands #hGrid', () => {
}));

beforeEach(async(() => {
resizeObserverIgnoreError();
fixture = TestBed.createComponent(IgxHierarchicalGridMultiLayoutComponent);
fixture.detectChanges();
hierarchicalGrid = fixture.componentInstance.hgrid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('igxSelect', () => {
expect(focusedItems.length).toEqual(1);
expect(selectList.children[focusedItemIndex].nativeElement.classList.contains(CSS_CLASS_FOCUSED_ITEM)).toBeTruthy();
expect(select.focusedItem).toBe(select.items[focusedItemIndex]);
expect(select.items[focusedItemIndex].isFocused).toBeTruthy();
expect(select.items[focusedItemIndex].focused).toBeTruthy();
};
const verifySelectedItem = function (itemIndex) {
expect(select.input.value).toEqual(select.items[itemIndex].value);
Expand Down Expand Up @@ -742,7 +742,7 @@ describe('igxSelect', () => {
tick();
fixture.detectChanges();
verifySelectedItem(selectedItemIndex);
expect(select.items[focusedItemIndex].isFocused).toBeFalsy();
expect(select.items[focusedItemIndex].focused).toBeFalsy();

// Unselect selected item
select.value = '';
Expand Down Expand Up @@ -790,10 +790,10 @@ describe('igxSelect', () => {
fixture.detectChanges();
checkInputValue();

// Select item - item isSelected property
// Select item - item selected property
selectedItemIndex = 12;
selectedItemValue = select.items[selectedItemIndex].value;
select.items[selectedItemIndex].isSelected = true;
select.items[selectedItemIndex].selected = true;
fixture.detectChanges();
tick();
fixture.detectChanges();
Expand Down Expand Up @@ -936,7 +936,7 @@ describe('igxSelect', () => {
selectedItemEl.nativeElement.click();
tick();
fixture.detectChanges();
expect(selectedItem.isSelected).toBeTruthy();
expect(selectedItem.selected).toBeTruthy();
expect(select.value).toEqual(selectedItem.value);
expect(select.input.value.toString().trim()).toEqual(selectedItem.value);
expect(select.selectedItem).toEqual(selectedItem);
Expand All @@ -945,7 +945,7 @@ describe('igxSelect', () => {
// Throws an error 'Cannot read property disabled of null'
select.selectItem(null);
fixture.detectChanges();
expect(selectedItem.isSelected).toBeTruthy();
expect(selectedItem.selected).toBeTruthy();
expect(select.value).toEqual(selectedItem.value);
expect(select.input.value.toString().trim()).toEqual(selectedItem.value);
expect(select.selectedItem).toEqual(selectedItem);
Expand Down Expand Up @@ -998,15 +998,15 @@ describe('igxSelect', () => {
cancel: false
};

selectedItem.isSelected = true;
selectedItem.selected = true;
fixture.detectChanges();
expect(select.onSelection.emit).toHaveBeenCalledTimes(1);
expect(select.selectItem).toHaveBeenCalledTimes(1);
expect(select.onSelection.emit).toHaveBeenCalledWith(args);

args.oldSelection = selectedItem;
selectedItem = select.items[9];
selectedItem.isSelected = true;
selectedItem.selected = true;
args.newSelection = selectedItem;
fixture.detectChanges();
expect(select.onSelection.emit).toHaveBeenCalledTimes(2);
Expand Down Expand Up @@ -1198,7 +1198,7 @@ describe('igxSelect', () => {
expect(focusedItems.length).toEqual(1);
expect(focusedItemElement.classList.contains(CSS_CLASS_FOCUSED_ITEM)).toBeTruthy();
expect(select.focusedItem).toBe(select.items[0]);
expect(select.items[0].isFocused).toBeTruthy();
expect(select.items[0].focused).toBeTruthy();
expect(groupElement.nativeElement.classList.contains(CSS_CLASS_FOCUSED_ITEM)).toBeFalsy();
}));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ describe('IgxTimePicker', () => {

const target = dom.query(By.directive(IgxInputDirective));

spyOn(timePicker.onOpen, 'emit');
spyOn(timePicker.onOpened, 'emit');

target.nativeElement.dispatchEvent(new Event('click', { bubbles: true }));
tick();

expect(timePicker.onOpen.emit).toHaveBeenCalled();
expect(timePicker.onOpened.emit).toHaveBeenCalled();
}));

it('TimePicker Validation Failed event', fakeAsync(() => {
Expand Down Expand Up @@ -1398,26 +1398,26 @@ describe('IgxTimePicker', () => {
expect(dom.query(By.css('.igx-time-picker--dropdown'))).toBeNull();
}));

it('should fire events onOpen and onClose for dropdown mode.', fakeAsync(() => {
it('should fire events onOpened and onClosed for dropdown mode.', fakeAsync(() => {
fixture.detectChanges();

const iconTime = dom.queryAll(By.css('.igx-icon'))[0];

spyOn(timePicker.onOpen, 'emit');
spyOn(timePicker.onOpened, 'emit');

UIInteractions.clickElement(iconTime);
tick();
fixture.detectChanges();

expect(timePicker.onOpen.emit).toHaveBeenCalled();
expect(timePicker.onOpened.emit).toHaveBeenCalled();

spyOn(timePicker.onClose, 'emit');
spyOn(timePicker.onClosed, 'emit');

UIInteractions.clickElement(iconTime);
tick();
fixture.detectChanges();

expect(timePicker.onOpen.emit).toHaveBeenCalled();
expect(timePicker.onOpened.emit).toHaveBeenCalled();
}));

it('should display OK and Cancel buttons by default.', fakeAsync(() => {
Expand Down