Skip to content

Commit ce346e7

Browse files
committed
refactor(*): change tests to account for new DI
1 parent 0991fd0 commit ce346e7

20 files changed

+160
-73
lines changed

projects/igniteui-angular/src/lib/action-strip/grid-actions/grid-editing-actions.component.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { IgxGridPinningActionsComponent } from './grid-pinning-actions.component
1515
import { IgxActionStripComponent } from '../action-strip.component';
1616
import { IRowDataCancelableEventArgs, IgxColumnComponent } from '../../grids/public_api';
1717
import { SampleTestData } from '../../test-utils/sample-test-data.spec';
18+
import { IgxGridNavigationService } from '../../grids/grid-navigation.service';
1819

1920
describe('igxGridEditingActions #grid ', () => {
2021
let fixture;
@@ -31,6 +32,9 @@ describe('igxGridEditingActions #grid ', () => {
3132
IgxActionStripEditMenuComponent,
3233
IgxActionStripOneRowComponent,
3334
IgxActionStripMenuOneRowComponent
35+
],
36+
providers: [
37+
IgxGridNavigationService
3438
]
3539
}).compileComponents();
3640
}));

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, ViewChild, TemplateRef, ChangeDetectionStrategy } from '@angular/core';
1+
import { Component, ViewChild, TemplateRef, ChangeDetectionStrategy, ElementRef } from '@angular/core';
22
import { TestBed, fakeAsync, tick, waitForAsync } from '@angular/core/testing';
33
import { By } from '@angular/platform-browser';
44
import {
@@ -14,8 +14,12 @@ import { CarouselIndicatorsOrientation, CarouselAnimationType } from './enums';
1414
describe('Carousel', () => {
1515
let fixture;
1616
let carousel: IgxCarouselComponent;
17+
let mockElement: any;
18+
let mockElementRef: ElementRef;
1719

1820
beforeEach(waitForAsync(() => {
21+
mockElement = document.createElement("div");
22+
mockElementRef = new ElementRef(mockElement);
1923
TestBed.configureTestingModule({
2024
imports: [
2125
NoopAnimationsModule,
@@ -24,6 +28,10 @@ describe('Carousel', () => {
2428
CarouselTemplateSetInTypescriptTestComponent,
2529
CarouselAnimationsComponent,
2630
CarouselDynamicSlidesComponent
31+
],
32+
providers: [
33+
{ provide: ElementRef, useValue: mockElementRef },
34+
IgxSlideComponent
2735
]
2836
}).compileComponents();
2937
}));
@@ -184,7 +192,7 @@ describe('Carousel', () => {
184192
expect(carousel.slideChanged.emit).toHaveBeenCalledTimes(3);
185193

186194
spyOn(carousel.slideAdded, 'emit');
187-
const newSlide = new IgxSlideComponent();
195+
const newSlide = TestBed.inject(IgxSlideComponent);
188196
carousel.add(newSlide);
189197
fixture.detectChanges();
190198
args = {

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ import {
148148
RowType,
149149
IPinningConfig,
150150
IClipboardOptions,
151-
EntityType
151+
EntityType,
152+
GridServiceType
152153
} from './common/grid.interface';
153154
import { DropPosition } from './moving/moving.service';
154155
import { IgxHeadSelectorDirective, IgxRowSelectorDirective } from './selection/row-selectors';
@@ -212,7 +213,7 @@ export abstract class IgxGridBaseDirective implements GridType,
212213
/** @hidden @internal */
213214
public readonly selectionService = inject(IgxGridSelectionService);
214215
protected colResizingService = inject(IgxColumnResizingService);
215-
public readonly gridAPI = inject(IGX_GRID_SERVICE_BASE);
216+
public readonly gridAPI = inject<GridServiceType>(IGX_GRID_SERVICE_BASE);
216217
protected transactionFactory = inject(IgxFlatTransactionFactory);
217218
private elementRef = inject(ElementRef<HTMLElement>);
218219
protected zone = inject(NgZone);

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { TransactionType } from '../../services/public_api';
1818
import { IgxGridRowComponent } from './grid-row.component';
1919
import { takeUntil, first } from 'rxjs/operators';
2020
import { Subject } from 'rxjs';
21+
import { IgxGridMRLNavigationService } from '../grid-mrl-navigation.service';
2122

2223
const DEBOUNCETIME = 30;
2324

@@ -47,6 +48,9 @@ describe('IgxGrid - Row Adding #grid', () => {
4748
IgxGridRowEditingDefinedColumnsComponent,
4849
ColumnLayoutTestComponent,
4950
DefaultGridMasterDetailComponent
51+
],
52+
providers: [
53+
IgxGridMRLNavigationService
5054
]
5155
}).compileComponents();
5256
}));

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { IgxDateTimeEditorDirective } from '../../directives/date-time-editor/da
2929
import { QueryBuilderSelectors } from '../../query-builder/query-builder.common';
3030
import { IgxHGridRemoteOnDemandComponent } from '../hierarchical-grid/hierarchical-grid.spec';
3131
import { IGridResourceStrings } from '../../core/i18n/grid-resources';
32+
import { IgxGridNavigationService } from '../grid-navigation.service';
3233

3334
describe('IgxGrid - Advanced Filtering #grid - ', () => {
3435
beforeEach(waitForAsync(() => {
@@ -45,6 +46,9 @@ describe('IgxGrid - Advanced Filtering #grid - ', () => {
4546
IgxHierarchicalGridTestBaseComponent,
4647
IgxHierarchicalGridExportComponent,
4748
IgxHGridRemoteOnDemandComponent
49+
],
50+
providers: [
51+
IgxGridNavigationService
4852
]
4953
}).compileComponents();
5054
}));

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { IActiveNodeChangeEventArgs } from '../common/events';
1515
import { IgxStringFilteringOperand } from '../../data-operations/filtering-condition';
1616
import { IgxGridHeaderRowComponent } from '../headers/grid-header-row.component';
1717
import { ISortingStrategy, SortingDirection } from '../../data-operations/sorting-strategy';
18+
import { IgxGridMRLNavigationService } from '../grid-mrl-navigation.service';
1819

1920
const DEBOUNCETIME = 30;
2021

@@ -27,6 +28,9 @@ describe('IgxGrid - Headers Keyboard navigation #grid', () => {
2728
TestBed.configureTestingModule({
2829
imports: [
2930
SelectionWithScrollsComponent, NoopAnimationsModule
31+
],
32+
providers: [
33+
IgxGridMRLNavigationService
3034
]
3135
}).compileComponents();
3236
}));
@@ -732,6 +736,9 @@ describe('IgxGrid - Headers Keyboard navigation #grid', () => {
732736
TestBed.configureTestingModule({
733737
imports: [
734738
MRLTestComponent, NoopAnimationsModule
739+
],
740+
providers: [
741+
IgxGridMRLNavigationService
735742
]
736743
}).compileComponents();
737744
}));

projects/igniteui-angular/src/lib/grids/grid/grid-mrl-keyboard-nav.spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { GridFunctions, GRID_MRL_BLOCK } from '../../test-utils/grid-functions.s
1212
import { CellType } from '../common/grid.interface';
1313
import { IgxColumnLayoutComponent } from '../columns/column-layout.component';
1414
import { IGridCellEventArgs, IgxColumnComponent } from '../public_api';
15+
import { IgxGridMRLNavigationService } from '../grid-mrl-navigation.service';
1516

1617
const DEBOUNCE_TIME = 30;
1718
const CELL_CSS_CLASS = '.igx-grid__td';
@@ -23,7 +24,8 @@ describe('IgxGrid Multi Row Layout - Keyboard navigation #grid', () => {
2324

2425
beforeEach(waitForAsync(() => {
2526
TestBed.configureTestingModule({
26-
imports: [NoopAnimationsModule, ColumnLayoutTestComponent]
27+
imports: [NoopAnimationsModule, ColumnLayoutTestComponent],
28+
providers: [IgxGridMRLNavigationService]
2729
}).compileComponents();
2830
}));
2931

@@ -1458,7 +1460,7 @@ describe('IgxGrid Multi Row Layout - Keyboard navigation #grid', () => {
14581460
fix.detectChanges();
14591461
setupGridScrollDetection(fix, fix.componentInstance.grid);
14601462

1461-
const [ _firstCell, _secondCell, thirdCell ] = fix.debugElement.queryAll(By.css(CELL_CSS_CLASS));
1463+
const [_firstCell, _secondCell, thirdCell] = fix.debugElement.queryAll(By.css(CELL_CSS_CLASS));
14621464

14631465
UIInteractions.simulateClickAndSelectEvent(thirdCell);
14641466
fix.detectChanges();
@@ -1899,7 +1901,7 @@ describe('IgxGrid Multi Row Layout - Keyboard navigation #grid', () => {
18991901
fix.detectChanges();
19001902

19011903
const grid = fix.componentInstance.grid;
1902-
fix.detectChanges();
1904+
fix.detectChanges();
19031905

19041906
// focus 3rd row, first cell
19051907
let cell = grid.gridAPI.get_cell_by_index(2, 'ContactName');
@@ -2361,7 +2363,7 @@ describe('IgxGrid Multi Row Layout - Keyboard navigation #grid', () => {
23612363
const secondBlock = fix.debugElement.query(By.css('igx-grid-row')).queryAll(By.css(CELL_BLOCK))[1];
23622364
const thirdBlock = fix.debugElement.query(By.css('igx-grid-row')).queryAll(By.css(CELL_BLOCK))[2];
23632365

2364-
const [secondCell, thirdCell, _fourthCell ] = thirdBlock.queryAll(By.css(CELL_CSS_CLASS));
2366+
const [secondCell, thirdCell, _fourthCell] = thirdBlock.queryAll(By.css(CELL_CSS_CLASS));
23652367
const firstCell = secondBlock.queryAll(By.css(CELL_CSS_CLASS))[0];
23662368

23672369
fix.componentInstance.grid.headerContainer.getScroll().scrollLeft = 500;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { GridRowConditionalStylingComponent } from '../../test-utils/grid-base-c
1717
import { SortingDirection } from '../../data-operations/sorting-strategy';
1818
import { IgxColumnLayoutComponent } from '../columns/column-layout.component';
1919
import { CellType, IPinRowEventArgs, IPinningConfig, IgxColumnComponent } from '../public_api';
20+
import { IgxGridMRLNavigationService } from '../grid-mrl-navigation.service';
2021

2122
describe('Row Pinning #grid', () => {
2223
const FIXED_ROW_CONTAINER = '.igx-grid__tr--pinned ';
@@ -35,6 +36,9 @@ describe('Row Pinning #grid', () => {
3536
GridRowPinningWithMDVComponent,
3637
GridRowPinningWithTransactionsComponent,
3738
GridRowPinningWithInitialPinningComponent
39+
],
40+
providers: [
41+
IgxGridMRLNavigationService
3842
]
3943
}).compileComponents();
4044
}));

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { SortingDirection } from '../../data-operations/sorting-strategy';
1717
import { IgxPaginatorComponent } from '../../paginator/paginator.component';
1818
import { IgxColumnLayoutComponent } from '../columns/column-layout.component';
1919
import { CellType, IgxColumnComponent, IgxGridDetailTemplateDirective } from '../public_api';
20+
import { IgxGridMRLNavigationService } from '../grid-mrl-navigation.service';
2021

2122
const DEBOUNCE_TIME = 30;
2223
const ROW_TAG = 'igx-grid-row';
@@ -38,6 +39,9 @@ describe('IgxGrid Master Detail #grid', () => {
3839
DefaultGridMasterDetailComponent,
3940
AllExpandedGridMasterDetailComponent,
4041
MRLMasterDetailComponent
42+
],
43+
providers: [
44+
IgxGridMRLNavigationService
4145
]
4246
}).compileComponents();
4347
}));

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { DropPosition } from '../moving/moving.service';
2626
import { clearGridSubs, setupGridScrollDetection } from '../../test-utils/helper-utils.spec';
2727
import { SortingDirection } from '../../data-operations/sorting-strategy';
2828
import { IPinningConfig } from '../public_api';
29+
import { IgxGridMRLNavigationService } from '../grid-mrl-navigation.service';
2930

3031
describe('IgxGrid - Column Pinning #grid', () => {
3132

@@ -40,6 +41,9 @@ describe('IgxGrid - Column Pinning #grid', () => {
4041
GridFeaturesComponent,
4142
MultiColumnHeadersWithGroupingComponent,
4243
GridPinningMRLComponent
44+
],
45+
providers: [
46+
IgxGridMRLNavigationService
4347
]
4448
}).compileComponents();
4549
}))

0 commit comments

Comments
 (0)