Skip to content

Commit fd491ad

Browse files
authored
Remove duplicate detectChanges #5810 (#5811)
* tests(fix): update failing tests and fix deprecated warnings
1 parent 194a4cf commit fd491ad

File tree

7 files changed

+42
-40
lines changed

7 files changed

+42
-40
lines changed

projects/igniteui-angular/src/lib/dialog/dialog.component.spec.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -301,14 +301,14 @@ describe('Dialog', () => {
301301
expect(overlayWrapper.classList.contains(OVERLAY_WRAPPER_CLASS)).toBe(false);
302302
}));
303303

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

308308
const dialog: IgxDialogComponent = fix.componentInstance.dialog as IgxDialogComponent;
309309
dialog.open();
310+
tick(100);
310311
fix.detectChanges();
311-
await wait(16);
312312

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

319319
// Press 'escape' key
320320
UIInteractions.simulateKeyDownEvent(document.activeElement, 'Escape');
321+
tick(100);
321322
fix.detectChanges();
322-
await wait(16);
323323

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

334333
beforeEach( fakeAsync(() => {
335334
fix = TestBed.createComponent(PositionSettingsDialogComponent);
336335
fix.detectChanges();
337336
dialog = fix.componentInstance.dialog;
338-
detect = () => dialog.cdr.detectChanges();
339337
}));
340338

341-
it('Define different position settings ', (async() => {
339+
it('Define different position settings ', fakeAsync(() => {
342340
const currentElement = fix.componentInstance;
343341
dialog.open();
342+
tick(16);
344343
fix.detectChanges();
345-
await wait(16);
346344

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

354352
dialog.close();
353+
tick(16);
355354
fix.detectChanges();
356-
await wait(16);
357355

358356
expect(dialog.isOpen).toEqual(false);
359357
dialog.positionSettings = currentElement.newPositionSettings;
358+
tick(16);
360359
fix.detectChanges();
361-
await wait(16);
362360

363361
dialog.open();
362+
tick(16);
364363
fix.detectChanges();
365-
await wait(16);
366364

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

374372
dialog.close();
373+
tick(16);
375374
fix.detectChanges();
376-
await wait(16);
377375

378376
expect(dialog.isOpen).toEqual(false);
379377
}));
380378

381-
it('Set animation settings', (async() => {
379+
it('Set animation settings', () => {
382380
const currentElement = fix.componentInstance;
383381

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

391389
dialog.positionSettings = currentElement.animationSettings;
392390
fix.detectChanges();
393-
await wait(16);
394391

395392
// Check the new animation settings
396393
expect(dialog.positionSettings.openAnimation.options.params.duration).toEqual('800ms', 'Animation duration is set to 800ms');
397394
expect(dialog.positionSettings.closeAnimation.options.params.duration).toEqual('700ms', 'Animation duration is set to 700ms');
398-
}));
395+
});
399396
});
400397

401398
function dispatchEvent(element: HTMLElement, eventType: string) {

projects/igniteui-angular/src/lib/directives/toggle/toggle.directive.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ describe('IgxToggle', () => {
118118
toggle.open();
119119
tick();
120120
expect(toggle.onOpened.emit).toHaveBeenCalledTimes(2);
121-
const otherId = overlay.show(fixture.componentInstance.other);
121+
const otherId = overlay.attach(fixture.componentInstance.other);
122+
overlay.show(otherId);
122123
overlay.hide(otherId);
123124
tick();
124125
expect(toggle.onClosed.emit).toHaveBeenCalledTimes(1);

projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2908,30 +2908,32 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
29082908
it('Verify condition chips are scrolled into/(out of) view by using arrow buttons.', (async () => {
29092909
grid.width = '700px';
29102910
fix.detectChanges();
2911+
await wait(100);
29112912

29122913
GridFunctions.clickFilterCellChip(fix, 'ProductName');
29132914
fix.detectChanges();
2915+
await wait(16);
29142916

29152917
// Add first chip.
29162918
GridFunctions.typeValueInFilterRowInput('a', fix);
2917-
fix.detectChanges();
29182919
await wait(16);
2920+
fix.detectChanges();
29192921
GridFunctions.submitFilterRowInput(fix);
2922+
await wait(200);
29202923
fix.detectChanges();
2921-
await wait(100);
29222924
// Add second chip.
29232925
GridFunctions.typeValueInFilterRowInput('e', fix);
29242926
await wait(16);
29252927
fix.detectChanges();
29262928
GridFunctions.submitFilterRowInput(fix);
2927-
await wait(100);
2929+
await wait(200);
29282930
fix.detectChanges();
29292931
// Add third chip.
29302932
GridFunctions.typeValueInFilterRowInput('i', fix);
29312933
await wait(16);
29322934
fix.detectChanges();
29332935
GridFunctions.submitFilterRowInput(fix);
2934-
await wait(100);
2936+
await wait(200);
29352937
fix.detectChanges();
29362938

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

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

33623364
GridFunctions.removeFilterChipByIndex(2, filterUIRow);
3365+
// wait for chip to be scrolled in view
33633366
fix.detectChanges();
3364-
// wait for chip to be scrolled in view
3365-
fix.detectChanges();
3366-
await wait(200);
3367+
await wait(200);
33673368

33683369
verifyMultipleChipsVisibility(fix, [true, false]);
33693370
chips = filterUIRow.queryAll(By.directive(IgxChipComponent));

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid.navigation.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ describe('IgxHierarchicalGrid Basic Navigation #hGrid', () => {
2525
}));
2626

2727
beforeEach(async(() => {
28+
resizeObserverIgnoreError();
2829
fixture = TestBed.createComponent(IgxHierarchicalGridTestBaseComponent);
2930
fixture.detectChanges();
3031
hierarchicalGrid = fixture.componentInstance.hgrid;
@@ -295,7 +296,6 @@ describe('IgxHierarchicalGrid Basic Navigation #hGrid', () => {
295296
}));
296297

297298
it('should not lose focus when pressing Ctrl+ArrowDown is pressed at the bottom row(expended) in a child grid.', (async () => {
298-
resizeObserverIgnoreError();
299299
hierarchicalGrid.height = '600px';
300300
hierarchicalGrid.width = '800px';
301301
fixture.componentInstance.rowIsland.height = '400px';

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { DisplayDensity } from '../../core/displayDensity';
1313
import { IgxStringFilteringOperand } from '../../data-operations/filtering-condition';
1414
import { IGridCellEventArgs } from '../grid';
1515
import { GridSelectionMode } from '../common/enums';
16+
import { resizeObserverIgnoreError } from '../../test-utils/helper-utils.spec';
1617

1718
describe('Basic IgxHierarchicalGrid #hGrid', () => {
1819
configureTestSuite();
@@ -29,6 +30,7 @@ describe('Basic IgxHierarchicalGrid #hGrid', () => {
2930
}));
3031

3132
beforeEach(async(() => {
33+
resizeObserverIgnoreError();
3234
fixture = TestBed.createComponent(IgxHierarchicalGridTestBaseComponent);
3335
fixture.detectChanges();
3436
hierarchicalGrid = fixture.componentInstance.hgrid;
@@ -422,6 +424,7 @@ describe('IgxHierarchicalGrid Row Islands #hGrid', () => {
422424
}));
423425

424426
beforeEach(async(() => {
427+
resizeObserverIgnoreError();
425428
fixture = TestBed.createComponent(IgxHierarchicalGridMultiLayoutComponent);
426429
fixture.detectChanges();
427430
hierarchicalGrid = fixture.componentInstance.hgrid;

projects/igniteui-angular/src/lib/select/select.component.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('igxSelect', () => {
5353
expect(focusedItems.length).toEqual(1);
5454
expect(selectList.children[focusedItemIndex].nativeElement.classList.contains(CSS_CLASS_FOCUSED_ITEM)).toBeTruthy();
5555
expect(select.focusedItem).toBe(select.items[focusedItemIndex]);
56-
expect(select.items[focusedItemIndex].isFocused).toBeTruthy();
56+
expect(select.items[focusedItemIndex].focused).toBeTruthy();
5757
};
5858
const verifySelectedItem = function (itemIndex) {
5959
expect(select.input.value).toEqual(select.items[itemIndex].value);
@@ -742,7 +742,7 @@ describe('igxSelect', () => {
742742
tick();
743743
fixture.detectChanges();
744744
verifySelectedItem(selectedItemIndex);
745-
expect(select.items[focusedItemIndex].isFocused).toBeFalsy();
745+
expect(select.items[focusedItemIndex].focused).toBeFalsy();
746746

747747
// Unselect selected item
748748
select.value = '';
@@ -790,10 +790,10 @@ describe('igxSelect', () => {
790790
fixture.detectChanges();
791791
checkInputValue();
792792

793-
// Select item - item isSelected property
793+
// Select item - item selected property
794794
selectedItemIndex = 12;
795795
selectedItemValue = select.items[selectedItemIndex].value;
796-
select.items[selectedItemIndex].isSelected = true;
796+
select.items[selectedItemIndex].selected = true;
797797
fixture.detectChanges();
798798
tick();
799799
fixture.detectChanges();
@@ -936,7 +936,7 @@ describe('igxSelect', () => {
936936
selectedItemEl.nativeElement.click();
937937
tick();
938938
fixture.detectChanges();
939-
expect(selectedItem.isSelected).toBeTruthy();
939+
expect(selectedItem.selected).toBeTruthy();
940940
expect(select.value).toEqual(selectedItem.value);
941941
expect(select.input.value.toString().trim()).toEqual(selectedItem.value);
942942
expect(select.selectedItem).toEqual(selectedItem);
@@ -945,7 +945,7 @@ describe('igxSelect', () => {
945945
// Throws an error 'Cannot read property disabled of null'
946946
select.selectItem(null);
947947
fixture.detectChanges();
948-
expect(selectedItem.isSelected).toBeTruthy();
948+
expect(selectedItem.selected).toBeTruthy();
949949
expect(select.value).toEqual(selectedItem.value);
950950
expect(select.input.value.toString().trim()).toEqual(selectedItem.value);
951951
expect(select.selectedItem).toEqual(selectedItem);
@@ -998,15 +998,15 @@ describe('igxSelect', () => {
998998
cancel: false
999999
};
10001000

1001-
selectedItem.isSelected = true;
1001+
selectedItem.selected = true;
10021002
fixture.detectChanges();
10031003
expect(select.onSelection.emit).toHaveBeenCalledTimes(1);
10041004
expect(select.selectItem).toHaveBeenCalledTimes(1);
10051005
expect(select.onSelection.emit).toHaveBeenCalledWith(args);
10061006

10071007
args.oldSelection = selectedItem;
10081008
selectedItem = select.items[9];
1009-
selectedItem.isSelected = true;
1009+
selectedItem.selected = true;
10101010
args.newSelection = selectedItem;
10111011
fixture.detectChanges();
10121012
expect(select.onSelection.emit).toHaveBeenCalledTimes(2);
@@ -1198,7 +1198,7 @@ describe('igxSelect', () => {
11981198
expect(focusedItems.length).toEqual(1);
11991199
expect(focusedItemElement.classList.contains(CSS_CLASS_FOCUSED_ITEM)).toBeTruthy();
12001200
expect(select.focusedItem).toBe(select.items[0]);
1201-
expect(select.items[0].isFocused).toBeTruthy();
1201+
expect(select.items[0].focused).toBeTruthy();
12021202
expect(groupElement.nativeElement.classList.contains(CSS_CLASS_FOCUSED_ITEM)).toBeFalsy();
12031203
}));
12041204
});

projects/igniteui-angular/src/lib/time-picker/time-picker.component.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ describe('IgxTimePicker', () => {
147147

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

150-
spyOn(timePicker.onOpen, 'emit');
150+
spyOn(timePicker.onOpened, 'emit');
151151

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

155-
expect(timePicker.onOpen.emit).toHaveBeenCalled();
155+
expect(timePicker.onOpened.emit).toHaveBeenCalled();
156156
}));
157157

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

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

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

1406-
spyOn(timePicker.onOpen, 'emit');
1406+
spyOn(timePicker.onOpened, 'emit');
14071407

14081408
UIInteractions.clickElement(iconTime);
14091409
tick();
14101410
fixture.detectChanges();
14111411

1412-
expect(timePicker.onOpen.emit).toHaveBeenCalled();
1412+
expect(timePicker.onOpened.emit).toHaveBeenCalled();
14131413

1414-
spyOn(timePicker.onClose, 'emit');
1414+
spyOn(timePicker.onClosed, 'emit');
14151415

14161416
UIInteractions.clickElement(iconTime);
14171417
tick();
14181418
fixture.detectChanges();
14191419

1420-
expect(timePicker.onOpen.emit).toHaveBeenCalled();
1420+
expect(timePicker.onOpened.emit).toHaveBeenCalled();
14211421
}));
14221422

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

0 commit comments

Comments
 (0)