Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit 96bcea9

Browse files
Ghislain BeaulacGhislain Beaulac
Ghislain Beaulac
authored and
Ghislain Beaulac
committed
refactor(tests): rename service spec file & cleanup some code
1 parent f74246c commit 96bcea9

File tree

3 files changed

+5
-47
lines changed

3 files changed

+5
-47
lines changed

src/app/modules/angular-slickgrid/services/__tests__/odata.service.spec.ts renamed to src/app/modules/angular-slickgrid/services/__tests__/odataQueryBuilder.service.spec.ts

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,10 @@
11
import { CaseType } from '../../models/caseType';
22
import { OdataQueryBuilderService } from '../odataQueryBuilder.service';
3-
import {
4-
Column,
5-
ColumnFilter,
6-
ColumnSort,
7-
CurrentFilter,
8-
FilterChangedArgs,
9-
GridOption,
10-
MultiColumnSort,
11-
Pagination,
12-
ColumnFilters,
13-
OperatorType,
14-
FieldType,
15-
CurrentSorter,
16-
OdataOption,
17-
} from '../../models';
18-
19-
const DEFAULT_ITEMS_PER_PAGE = 25;
20-
const DEFAULT_PAGE_SIZE = 20;
21-
22-
const gridOptionMock = {
23-
enablePagination: true,
24-
backendServiceApi: {
25-
service: undefined,
26-
preProcess: jest.fn(),
27-
process: jest.fn(),
28-
postProcess: jest.fn(),
29-
}
30-
} as GridOption;
31-
32-
const gridStub = {
33-
autosizeColumns: jest.fn(),
34-
getColumnIndex: jest.fn(),
35-
getScrollbarDimensions: jest.fn(),
36-
getOptions: () => gridOptionMock,
37-
getColumns: jest.fn(),
38-
setColumns: jest.fn(),
39-
registerPlugin: jest.fn(),
40-
setSelectedRows: jest.fn(),
41-
setSortColumns: jest.fn(),
42-
};
43-
44-
describe('OdataService', () => {
45-
let mockColumns: Column[];
3+
4+
describe('OdataQueryBuilderService', () => {
465
let service: OdataQueryBuilderService;
476

487
beforeEach(() => {
49-
mockColumns = [{ id: 'field1', field: 'field1', width: 100 }, { id: 'field2', field: 'field2', width: 100 }];
508
service = new OdataQueryBuilderService();
519
});
5210

src/app/modules/angular-slickgrid/services/graphql.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ export class GraphqlService implements BackendService {
556556
*/
557557
private castFilterToColumnFilters(columnFilters: ColumnFilters | CurrentFilter[]): CurrentFilter[] {
558558
if (!Array.isArray(columnFilters)) {
559-
return null;
559+
return [];
560560
}
561561

562562
// keep current filters & always save it as an array (columnFilters can be an object when it is dealt by SlickGrid Filter)

src/app/modules/angular-slickgrid/services/grid-odata.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class GridOdataService implements BackendService {
7575
// save current pagination as Page 1 and page size as "top"
7676
this._currentPagination = {
7777
pageNumber: 1,
78-
pageSize: this._odataService.options.top || this.defaultOptions.top
78+
pageSize: this._odataService.options.top || this.defaultOptions.top || DEFAULT_PAGE_SIZE
7979
};
8080

8181
if (grid && grid.getColumns) {
@@ -490,7 +490,7 @@ export class GridOdataService implements BackendService {
490490
*/
491491
private castFilterToColumnFilters(columnFilters: ColumnFilters | CurrentFilter[]): CurrentFilter[] {
492492
if (!Array.isArray(columnFilters)) {
493-
return null;
493+
return [];
494494
}
495495

496496
// keep current filters & always save it as an array (columnFilters can be an object when it is dealt by SlickGrid Filter)

0 commit comments

Comments
 (0)