@zeedhi/teknisa-components-common 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/teknisa-components-common.es.js +3536 -0
- package/dist/types/components/tek-breadcrumb-header/breadcrumb-header.d.ts +2 -2
- package/dist/types/components/tek-breadcrumb-header/interfaces.d.ts +1 -1
- package/dist/types/components/tek-datasource/tek-memory-datasource.d.ts +1 -21
- package/dist/types/components/tek-datasource/tek-rest-datasource.d.ts +6 -28
- package/dist/types/components/tek-grid/filter-helper.d.ts +2 -2
- package/dist/types/components/tek-grid/grid-filter-button.d.ts +1 -0
- package/dist/types/components/tek-grid/grouped-data-manager.d.ts +8 -1
- package/dist/types/components/tek-grid/interfaces.d.ts +8 -1
- package/dist/types/components/tek-grid/tek-grid-controller.d.ts +19 -17
- package/dist/types/components/tek-grid/tek-grid-data-editor.d.ts +11 -0
- package/dist/types/components/tek-grid/tek-grid-toolbar-provider/export-options/multi-option.d.ts +1 -1
- package/dist/types/components/tek-grid/tek-grid-toolbar-provider/tek-grid-toolbar-provider.d.ts +8 -1
- package/dist/types/components/tek-grid/tek-grid.d.ts +22 -5
- package/dist/types/components/tek-loading/interfaces.d.ts +1 -1
- package/dist/types/components/tek-loading/loading.d.ts +1 -1
- package/dist/types/components/tek-user-info/TekUserInfoController.d.ts +4 -4
- package/dist/types/utils/extract-properties/extract-properties.d.ts +1 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/report-filter/report-filter.d.ts +12 -0
- package/package.json +30 -12
- package/coverage/clover.xml +0 -6
- package/coverage/coverage-final.json +0 -1
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -101
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -210
- package/coverage/lcov-report/tests/__helpers__/component-event-helper.ts.html +0 -100
- package/coverage/lcov-report/tests/__helpers__/create-component.ts.html +0 -109
- package/coverage/lcov-report/tests/__helpers__/find-component.ts.html +0 -139
- package/coverage/lcov-report/tests/__helpers__/flush-promises-helper.ts.html +0 -94
- package/coverage/lcov-report/tests/__helpers__/get-child-helper.ts.html +0 -166
- package/coverage/lcov-report/tests/__helpers__/index.html +0 -221
- package/coverage/lcov-report/tests/__helpers__/index.ts.html +0 -106
- package/coverage/lcov-report/tests/__helpers__/mock-created-helper.ts.html +0 -121
- package/coverage/lcov-report/tests/__helpers__/spy-on-all-methods.ts.html +0 -223
- package/coverage/lcov.info +0 -0
- package/dist/teknisa-components-common.js +0 -3808
- package/dist/teknisa-components-common.min.js +0 -3808
- package/dist/types/components/tek-grid/grouped-view-navigator.d.ts +0 -14
- package/environments.json +0 -26
- package/jest.config.cjs +0 -23
- package/src/components/index.ts +0 -101
- package/src/components/tek-breadcrumb-header/breadcrumb-header.ts +0 -29
- package/src/components/tek-breadcrumb-header/interfaces.ts +0 -7
- package/src/components/tek-datasource/index.ts +0 -3
- package/src/components/tek-datasource/interfaces.ts +0 -36
- package/src/components/tek-datasource/tek-memory-datasource.ts +0 -314
- package/src/components/tek-datasource/tek-rest-datasource.ts +0 -224
- package/src/components/tek-grid/columns-searcher.ts +0 -22
- package/src/components/tek-grid/dynamic-filter-datasource-factory.ts +0 -20
- package/src/components/tek-grid/filter-helper.ts +0 -20
- package/src/components/tek-grid/grid-filter-button.ts +0 -421
- package/src/components/tek-grid/grouped-data-manager.ts +0 -448
- package/src/components/tek-grid/grouped-data-navigator.ts +0 -66
- package/src/components/tek-grid/grouped-data-selector.ts +0 -40
- package/src/components/tek-grid/index.ts +0 -18
- package/src/components/tek-grid/interfaces.ts +0 -329
- package/src/components/tek-grid/keymap-grouped.ts +0 -20
- package/src/components/tek-grid/layout-options.ts +0 -248
- package/src/components/tek-grid/tek-grid-column.ts +0 -193
- package/src/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button-controller.ts +0 -28
- package/src/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button.ts +0 -38
- package/src/components/tek-grid/tek-grid-controller.ts +0 -140
- package/src/components/tek-grid/tek-grid-events.ts +0 -105
- package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/button-option.ts +0 -26
- package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/index.ts +0 -3
- package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/interfaces.ts +0 -6
- package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/multi-option.ts +0 -85
- package/src/components/tek-grid/tek-grid-toolbar-provider/index.ts +0 -2
- package/src/components/tek-grid/tek-grid-toolbar-provider/tek-grid-toolbar-provider.ts +0 -365
- package/src/components/tek-grid/tek-grid.ts +0 -1122
- package/src/components/tek-loading/interfaces.ts +0 -7
- package/src/components/tek-loading/loading.ts +0 -27
- package/src/components/tek-user-info/TekUserInfoController.ts +0 -87
- package/src/components/tek-user-info/interfaces.ts +0 -21
- package/src/components/tek-user-info/tek-user-info-list.ts +0 -64
- package/src/components/tek-user-info/tek-user-info.ts +0 -337
- package/src/error/tek-grid-delete-rows-error.ts +0 -15
- package/src/error/teknisa-common-error.ts +0 -8
- package/src/utils/config/config.ts +0 -8
- package/src/utils/index.ts +0 -3
- package/src/utils/is-filled-object/is-filled-object.ts +0 -5
- package/src/utils/is-nil.ts +0 -3
- package/tests/__helpers__/component-event-helper.ts +0 -5
- package/tests/__helpers__/create-component.ts +0 -8
- package/tests/__helpers__/find-component.ts +0 -18
- package/tests/__helpers__/flush-promises-helper.ts +0 -3
- package/tests/__helpers__/get-child-helper.ts +0 -27
- package/tests/__helpers__/index.ts +0 -7
- package/tests/__helpers__/mock-created-helper.ts +0 -12
- package/tests/__helpers__/spy-on-all-methods.ts +0 -46
- package/tests/__mocks__/@zeedhi/core/i18n.js +0 -75
- package/tests/__mocks__/@zeedhi/core.js +0 -5
- package/tests/unit/components/tek-breadcrumb-header/tek-breadcrumb-header.spec.ts +0 -43
- package/tests/unit/components/tek-datasource/memory-datasource.spec.ts +0 -463
- package/tests/unit/components/tek-datasource/rest-datasource.spec.ts +0 -362
- package/tests/unit/components/tek-grid/button-option.spec.ts +0 -49
- package/tests/unit/components/tek-grid/columns-searcher.spec.ts +0 -112
- package/tests/unit/components/tek-grid/dynamic-filter-datasource-factory.spec.ts +0 -90
- package/tests/unit/components/tek-grid/filter-helper.spec.ts +0 -56
- package/tests/unit/components/tek-grid/grid-filter-button.spec.ts +0 -842
- package/tests/unit/components/tek-grid/grouped-data-manager.spec.ts +0 -593
- package/tests/unit/components/tek-grid/grouped-data-navigator.spec.ts +0 -143
- package/tests/unit/components/tek-grid/grouped-data-selector.spec.ts +0 -136
- package/tests/unit/components/tek-grid/keymap-grouped.spec.ts +0 -20
- package/tests/unit/components/tek-grid/layout-options.spec.ts +0 -1020
- package/tests/unit/components/tek-grid/tek-grid-column.spec.ts +0 -318
- package/tests/unit/components/tek-grid/tek-grid-columns-button.spec.ts +0 -229
- package/tests/unit/components/tek-grid/tek-grid-controller.spec.ts +0 -253
- package/tests/unit/components/tek-grid/tek-grid-events.spec.ts +0 -186
- package/tests/unit/components/tek-grid/tek-grid-toolbar-provider.spec.ts +0 -34
- package/tests/unit/components/tek-grid/tek-grid.spec.ts +0 -897
- package/tests/unit/components/tek-grid/tek-memory-datasource.spec.ts +0 -482
- package/tests/unit/components/tek-grid/tek-rest-datasource.spec.ts +0 -422
- package/tests/unit/components/tek-loading/loading.spec.ts +0 -29
- package/tests/unit/components/tek-user-info/TekUserInfoContoller.spec.ts +0 -220
- package/tests/unit/components/tek-user-info/tek-user-info-list.spec.ts +0 -96
- package/tests/unit/components/tek-user-info/tek-user-info.spec.ts +0 -442
- package/tests/unit/utils/mock-console.ts +0 -18
- package/tests/unit/utils/setup.ts +0 -5
- package/tsconfig.build.json +0 -7
- package/tsconfig.eslint.json +0 -9
|
@@ -1,897 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-underscore-dangle */
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
TekGrid, TekGridColumn,
|
|
5
|
-
ITekGridAtoms,
|
|
6
|
-
TekRestDatasource,
|
|
7
|
-
DynamicFilterDatasourceFactory,
|
|
8
|
-
TekMemoryDatasource,
|
|
9
|
-
ITekGridProps,
|
|
10
|
-
} from '../../../../src';
|
|
11
|
-
import {
|
|
12
|
-
Metadata,
|
|
13
|
-
Datasource,
|
|
14
|
-
Loader,
|
|
15
|
-
SimpleControllerBuilder,
|
|
16
|
-
Newable,
|
|
17
|
-
} from '@zeedhi/core';
|
|
18
|
-
import {
|
|
19
|
-
Button,
|
|
20
|
-
ComponentRender,
|
|
21
|
-
KeyMapMerger,
|
|
22
|
-
IterableTable,
|
|
23
|
-
TableActionBuilder,
|
|
24
|
-
DataEditorWithAdd,
|
|
25
|
-
ViewNavigator,
|
|
26
|
-
} from '@zeedhi/common';
|
|
27
|
-
import {
|
|
28
|
-
GroupedDataSelector,
|
|
29
|
-
TekGridEvents,
|
|
30
|
-
ColumnsSearcher,
|
|
31
|
-
GroupedDataManager,
|
|
32
|
-
TekGridToolbarProvider,
|
|
33
|
-
GroupedDataNavigator,
|
|
34
|
-
} from '../../../../src';
|
|
35
|
-
import { createComponent, findComponent, setClick, spyOnAllMethods } from '../../../__helpers__';
|
|
36
|
-
|
|
37
|
-
jest.mock('lodash.debounce', () => jest.fn((fn) => fn));
|
|
38
|
-
|
|
39
|
-
jest.useFakeTimers();
|
|
40
|
-
|
|
41
|
-
const createAtom = <T extends ComponentRender>(name: keyof ITekGridAtoms, componentClass: Newable<T>, instance: TekGrid): T => {
|
|
42
|
-
const buttonName = instance.getAtomName(name);
|
|
43
|
-
const buttonProps = findComponent(buttonName, instance.toolbarSlot)
|
|
44
|
-
return createComponent(componentClass, buttonProps);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const createAtomAndClick = <T extends ComponentRender>(name: keyof ITekGridAtoms, componentClass: Newable<T>, instance: TekGrid): T => {
|
|
48
|
-
const button = createAtom(name, componentClass, instance);
|
|
49
|
-
const event = {
|
|
50
|
-
defaultPrevented: false,
|
|
51
|
-
preventDefault() {
|
|
52
|
-
this.defaultPrevented = true;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
setClick(button, event);
|
|
56
|
-
|
|
57
|
-
return button;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const setupInstance = (props: Partial<ITekGridProps> = {}) => {
|
|
61
|
-
const instance = new TekGrid({
|
|
62
|
-
name: 'Grid',
|
|
63
|
-
component: 'TekGrid',
|
|
64
|
-
columns: [
|
|
65
|
-
{ name: 'first' },
|
|
66
|
-
{ name: 'second' },
|
|
67
|
-
{ name: 'third' },
|
|
68
|
-
],
|
|
69
|
-
datasource: {
|
|
70
|
-
limit: 2,
|
|
71
|
-
page: 1,
|
|
72
|
-
data: [
|
|
73
|
-
{ id: 1 },
|
|
74
|
-
{ id: 2 },
|
|
75
|
-
{ id: 3 },
|
|
76
|
-
{ id: 4 },
|
|
77
|
-
{ id: 5 },
|
|
78
|
-
{ id: 6 },
|
|
79
|
-
{ id: 7 },
|
|
80
|
-
],
|
|
81
|
-
},
|
|
82
|
-
...props,
|
|
83
|
-
});
|
|
84
|
-
const elem = document.createElement('DIV');
|
|
85
|
-
instance.onCreated();
|
|
86
|
-
instance.onMounted(elem);
|
|
87
|
-
|
|
88
|
-
return instance;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
describe('TekGrid', () => {
|
|
92
|
-
beforeAll(() => {
|
|
93
|
-
// mock Loader
|
|
94
|
-
Loader.setBuilder(new SimpleControllerBuilder());
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
beforeEach(() => {
|
|
98
|
-
// clear all metadata instances before testing
|
|
99
|
-
const { instances } = Metadata as any;
|
|
100
|
-
Object.keys(instances).forEach((key) => {
|
|
101
|
-
Metadata.clearInstance(key, instances[key].componentId);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
jest.clearAllTimers();
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
describe('constructor()', () => {
|
|
108
|
-
it('should create new grid with default values', () => {
|
|
109
|
-
const instance = new TekGrid({ name: 'Grid', component: 'TekGrid' });
|
|
110
|
-
expect(instance.title).toBe('');
|
|
111
|
-
expect(instance.addButton).toBeFalsy();
|
|
112
|
-
expect(instance.deleteButton).toBe('none');
|
|
113
|
-
expect(instance.filterButton).toBeFalsy();
|
|
114
|
-
expect(instance.modalFilterProps).toEqual(
|
|
115
|
-
expect.objectContaining({
|
|
116
|
-
height: 'auto',
|
|
117
|
-
persistent: true,
|
|
118
|
-
}),
|
|
119
|
-
);
|
|
120
|
-
expect(instance.columnFilterButton).toBeFalsy();
|
|
121
|
-
expect(instance.dragColumns).toBeTruthy();
|
|
122
|
-
expect(instance.resizeColumns).toBeTruthy();
|
|
123
|
-
expect(instance.showLayoutOptions).toBeTruthy();
|
|
124
|
-
expect(instance.showSearch).toBeTruthy();
|
|
125
|
-
expect(instance.showSummaryTotal).toBeTruthy();
|
|
126
|
-
expect(instance.showReload).toBeTruthy();
|
|
127
|
-
expect(instance.columnsButton).toBeFalsy();
|
|
128
|
-
expect(instance.columnsButtonIgnore).toEqual([]);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('should create new Grid replacing default values', () => {
|
|
132
|
-
const instance = new TekGrid({
|
|
133
|
-
name: 'grid',
|
|
134
|
-
component: 'TekGrid',
|
|
135
|
-
title: 'title',
|
|
136
|
-
addButton: true,
|
|
137
|
-
deleteButton: 'selection',
|
|
138
|
-
filterButton: true,
|
|
139
|
-
modalFilterProps: {
|
|
140
|
-
name: 'teste',
|
|
141
|
-
height: 'auto',
|
|
142
|
-
persistent: false,
|
|
143
|
-
cssClass: 'class-test',
|
|
144
|
-
cssStyle: 'background: red',
|
|
145
|
-
draggable: true,
|
|
146
|
-
fullscreen: true,
|
|
147
|
-
light: false,
|
|
148
|
-
dark: true,
|
|
149
|
-
},
|
|
150
|
-
columnFilterButton: true,
|
|
151
|
-
dragColumns: false,
|
|
152
|
-
resizeColumns: false,
|
|
153
|
-
showLayoutOptions: false,
|
|
154
|
-
showSearch: false,
|
|
155
|
-
showSummaryTotal: false,
|
|
156
|
-
showReload: false,
|
|
157
|
-
columns: [
|
|
158
|
-
{ name: 'id' },
|
|
159
|
-
],
|
|
160
|
-
columnsButton: true,
|
|
161
|
-
columnsButtonIgnore: ['id'],
|
|
162
|
-
});
|
|
163
|
-
expect(instance.title).toBe('title');
|
|
164
|
-
expect(instance.addButton).toBeTruthy();
|
|
165
|
-
expect(instance.deleteButton).toBe('selection');
|
|
166
|
-
expect(instance.filterButton).toBeTruthy();
|
|
167
|
-
expect(instance.modalFilterProps).toEqual(
|
|
168
|
-
expect.objectContaining({
|
|
169
|
-
height: 'auto',
|
|
170
|
-
persistent: false,
|
|
171
|
-
}),
|
|
172
|
-
);
|
|
173
|
-
expect(instance.columnFilterButton).toBeTruthy();
|
|
174
|
-
expect(instance.dragColumns).toBeFalsy();
|
|
175
|
-
expect(instance.resizeColumns).toBeFalsy();
|
|
176
|
-
expect(instance.showLayoutOptions).toBeFalsy();
|
|
177
|
-
expect(instance.showSearch).toBeFalsy();
|
|
178
|
-
expect(instance.showSummaryTotal).toBeFalsy();
|
|
179
|
-
expect(instance.showReload).toBeFalsy();
|
|
180
|
-
expect(instance.columns[0]).toBeInstanceOf(TekGridColumn);
|
|
181
|
-
expect(instance.columnsButton).toBeTruthy();
|
|
182
|
-
expect(instance.columnsButtonIgnore).toEqual(['id']);
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
it('should create toolbar and footer', () => {
|
|
186
|
-
const instance = new TekGrid({
|
|
187
|
-
name: 'grid',
|
|
188
|
-
component: 'TekGrid',
|
|
189
|
-
title: 'title',
|
|
190
|
-
addButton: true,
|
|
191
|
-
deleteButton: 'selection',
|
|
192
|
-
filterButton: true,
|
|
193
|
-
columnFilterButton: true,
|
|
194
|
-
dragColumns: false,
|
|
195
|
-
resizeColumns: false,
|
|
196
|
-
showLayoutOptions: false,
|
|
197
|
-
});
|
|
198
|
-
instance.onCreated();
|
|
199
|
-
expect(instance.toolbarSlot.length).toBe(4);
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
it('should overwrite toolbar', () => {
|
|
203
|
-
const instance = new TekGrid({
|
|
204
|
-
name: 'grid',
|
|
205
|
-
component: 'TekGrid',
|
|
206
|
-
title: 'title',
|
|
207
|
-
addButton: true,
|
|
208
|
-
deleteButton: 'selection',
|
|
209
|
-
filterButton: true,
|
|
210
|
-
columnFilterButton: true,
|
|
211
|
-
dragColumns: false,
|
|
212
|
-
resizeColumns: false,
|
|
213
|
-
showLayoutOptions: false,
|
|
214
|
-
toolbarSlot: [],
|
|
215
|
-
});
|
|
216
|
-
instance.onCreated();
|
|
217
|
-
expect(instance.toolbarSlot.length).toBe(0);
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
it('should create new TekGrid with accessor datasource', () => {
|
|
221
|
-
const spy = jest.spyOn(Loader, 'getInstance').mockImplementation(() => {
|
|
222
|
-
return {
|
|
223
|
-
datasource: {
|
|
224
|
-
uniqueKey: 'id',
|
|
225
|
-
data: [{ id: '1' }],
|
|
226
|
-
},
|
|
227
|
-
};
|
|
228
|
-
});
|
|
229
|
-
const instance = new TekGrid({
|
|
230
|
-
name: 'grid',
|
|
231
|
-
component: 'TekGrid',
|
|
232
|
-
datasource: '{{AppController.datasource}}' as any,
|
|
233
|
-
});
|
|
234
|
-
instance.onCreated();
|
|
235
|
-
|
|
236
|
-
expect(instance.datasource).toBeInstanceOf(Datasource);
|
|
237
|
-
expect(instance.datasource.data).toEqual([{ id: '1' }]);
|
|
238
|
-
|
|
239
|
-
spy.mockRestore();
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
it('should create a new grid with defined values', () => {
|
|
243
|
-
const instance = new TekGrid({
|
|
244
|
-
name: 'grid',
|
|
245
|
-
component: 'TekGrid',
|
|
246
|
-
doubleClickEdit: true,
|
|
247
|
-
backgroundColor: 'blue',
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
expect(instance.name).toBe('grid');
|
|
251
|
-
expect(instance.doubleClickEdit).toBeTruthy();
|
|
252
|
-
expect(instance.backgroundColor).toBe('blue');
|
|
253
|
-
});
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
describe('saveChanges()', () => {
|
|
257
|
-
it('should call saveEditedRows', () => {
|
|
258
|
-
const instance = new TekGrid({
|
|
259
|
-
name: 'grid_saveChanges1',
|
|
260
|
-
component: 'TekGrid',
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
const spy = jest.spyOn(instance, 'saveEditedRows');
|
|
264
|
-
instance.onCreated();
|
|
265
|
-
|
|
266
|
-
const button = createAtomAndClick('SAVE_BUTTON', Button, instance);
|
|
267
|
-
|
|
268
|
-
expect(spy).toHaveBeenCalled();
|
|
269
|
-
expect(button.isVisible).toBeFalsy();
|
|
270
|
-
spy.mockReset();
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
it('should call events', () => {
|
|
274
|
-
let beforeSaveCalled = false;
|
|
275
|
-
let afterSaveCalled = false;
|
|
276
|
-
const instance = new TekGrid({
|
|
277
|
-
name: 'grid_saveChanges2',
|
|
278
|
-
component: 'TekGrid',
|
|
279
|
-
events: {
|
|
280
|
-
beforeSave: () => { beforeSaveCalled = true; },
|
|
281
|
-
afterSave: () => { afterSaveCalled = true; },
|
|
282
|
-
},
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
instance.onCreated();
|
|
286
|
-
|
|
287
|
-
createAtomAndClick('SAVE_BUTTON', Button, instance);
|
|
288
|
-
|
|
289
|
-
expect(beforeSaveCalled).toBeTruthy();
|
|
290
|
-
expect(afterSaveCalled).toBeTruthy();
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
it('should not call saveEditedRows if beforeSave call preventDefault', () => {
|
|
294
|
-
const beforeSaveMock = jest.fn().mockImplementation(({ event }) => { event.defaultPrevented = true });
|
|
295
|
-
const afterSaveMock = jest.fn();
|
|
296
|
-
|
|
297
|
-
const instance = new TekGrid({
|
|
298
|
-
name: 'grid_saveChanges3',
|
|
299
|
-
component: 'TekGrid',
|
|
300
|
-
events: {
|
|
301
|
-
beforeSave: beforeSaveMock,
|
|
302
|
-
afterSave: afterSaveMock,
|
|
303
|
-
},
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
const spy = jest.spyOn(instance, 'saveEditedRows');
|
|
307
|
-
instance.onCreated();
|
|
308
|
-
|
|
309
|
-
createAtomAndClick('SAVE_BUTTON', Button, instance);
|
|
310
|
-
|
|
311
|
-
expect(beforeSaveMock).toHaveBeenCalled();
|
|
312
|
-
expect(afterSaveMock).not.toHaveBeenCalled();
|
|
313
|
-
expect(spy).not.toHaveBeenCalled();
|
|
314
|
-
spy.mockReset();
|
|
315
|
-
});
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
describe('cancelChanges()', () => {
|
|
319
|
-
it('should call cancelEditedRows', () => {
|
|
320
|
-
const instance = new TekGrid({
|
|
321
|
-
name: 'grid_cancelChanges1',
|
|
322
|
-
component: 'TekGrid',
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
const spy = jest.spyOn(instance, 'cancelEditedRows');
|
|
326
|
-
instance.onCreated();
|
|
327
|
-
|
|
328
|
-
const button = createAtomAndClick('CANCEL_BUTTON', Button, instance);
|
|
329
|
-
|
|
330
|
-
expect(spy).toHaveBeenCalled();
|
|
331
|
-
expect(button.isVisible).toBeFalsy();
|
|
332
|
-
spy.mockReset();
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
it('should call events', () => {
|
|
336
|
-
let beforeCancelCalled = false;
|
|
337
|
-
let afterCancelCalled = false;
|
|
338
|
-
const instance = new TekGrid({
|
|
339
|
-
name: 'grid_cancelChanges2',
|
|
340
|
-
component: 'TekGrid',
|
|
341
|
-
events: {
|
|
342
|
-
beforeCancel: () => { beforeCancelCalled = true; },
|
|
343
|
-
afterCancel: () => { afterCancelCalled = true; },
|
|
344
|
-
},
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
instance.onCreated();
|
|
348
|
-
|
|
349
|
-
createAtomAndClick('CANCEL_BUTTON', Button, instance);
|
|
350
|
-
|
|
351
|
-
expect(beforeCancelCalled).toBeTruthy();
|
|
352
|
-
expect(afterCancelCalled).toBeTruthy();
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
it('should not call cancelEditedRows if beforeSave call preventDefault', () => {
|
|
356
|
-
const beforeCancelMock = jest.fn().mockImplementation(({ event }) => { event.defaultPrevented = true });
|
|
357
|
-
const afterCancelMock = jest.fn();
|
|
358
|
-
const instance = new TekGrid({
|
|
359
|
-
name: 'grid_cancelChanges3',
|
|
360
|
-
component: 'TekGrid',
|
|
361
|
-
events: {
|
|
362
|
-
beforeCancel: beforeCancelMock,
|
|
363
|
-
afterCancel: afterCancelMock,
|
|
364
|
-
},
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
const spy = jest.spyOn(instance, 'cancelEditedRows');
|
|
368
|
-
instance.onCreated();
|
|
369
|
-
|
|
370
|
-
createAtomAndClick('CANCEL_BUTTON', Button, instance);
|
|
371
|
-
|
|
372
|
-
expect(beforeCancelMock).toHaveBeenCalled();
|
|
373
|
-
expect(afterCancelMock).not.toHaveBeenCalled();
|
|
374
|
-
expect(spy).not.toHaveBeenCalled();
|
|
375
|
-
spy.mockReset();
|
|
376
|
-
});
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
describe('addButtonClick()', () => {
|
|
380
|
-
it('should call event', () => {
|
|
381
|
-
const instance = new TekGrid({
|
|
382
|
-
name: 'grid_addClick1',
|
|
383
|
-
component: 'TekGrid',
|
|
384
|
-
addButton: true,
|
|
385
|
-
editNewRowsOnly: true,
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
instance.onCreated();
|
|
389
|
-
|
|
390
|
-
const button = createAtomAndClick('ADD_BUTTON', Button, instance);
|
|
391
|
-
|
|
392
|
-
const addClickSpy = jest.fn();
|
|
393
|
-
instance.events = {
|
|
394
|
-
addClick: addClickSpy,
|
|
395
|
-
};
|
|
396
|
-
|
|
397
|
-
expect(instance.editingNewRows).toBeTruthy();
|
|
398
|
-
|
|
399
|
-
setClick(button)
|
|
400
|
-
|
|
401
|
-
expect(addClickSpy).toHaveBeenCalled();
|
|
402
|
-
expect(button.isVisible).toBeTruthy();
|
|
403
|
-
});
|
|
404
|
-
});
|
|
405
|
-
|
|
406
|
-
describe('hideButtonClick()', () => {
|
|
407
|
-
it('should hide toolbar', () => {
|
|
408
|
-
const instance = new TekGrid({
|
|
409
|
-
name: 'grid_deleteClick2',
|
|
410
|
-
component: 'TekGrid',
|
|
411
|
-
});
|
|
412
|
-
|
|
413
|
-
instance.onCreated();
|
|
414
|
-
|
|
415
|
-
const toolbarMock = { isVisible: true };
|
|
416
|
-
jest.spyOn(Metadata, 'getInstance').mockImplementation(() => toolbarMock);
|
|
417
|
-
|
|
418
|
-
expect(toolbarMock.isVisible).toBeTruthy();
|
|
419
|
-
|
|
420
|
-
createAtomAndClick('HIDE_BUTTON', Button, instance);
|
|
421
|
-
|
|
422
|
-
expect(toolbarMock.isVisible).toBeFalsy();
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
it('should show toolbar', () => {
|
|
426
|
-
const instance = new TekGrid({
|
|
427
|
-
name: 'grid_deleteClick2',
|
|
428
|
-
component: 'TekGrid',
|
|
429
|
-
toolbarOpened: false,
|
|
430
|
-
});
|
|
431
|
-
|
|
432
|
-
instance.onCreated();
|
|
433
|
-
|
|
434
|
-
const toolbarMock = { isVisible: true };
|
|
435
|
-
jest.spyOn(Metadata, 'getInstance').mockImplementation(() => toolbarMock);
|
|
436
|
-
|
|
437
|
-
const button = createAtomAndClick('HIDE_BUTTON', Button, instance);
|
|
438
|
-
|
|
439
|
-
expect(toolbarMock.isVisible).toBeFalsy();
|
|
440
|
-
|
|
441
|
-
setClick(button);
|
|
442
|
-
|
|
443
|
-
expect(toolbarMock.isVisible).toBeTruthy();
|
|
444
|
-
});
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
describe('deleteButtonClick()', () => {
|
|
448
|
-
it('should call deleteRows', () => {
|
|
449
|
-
const instance = new TekGrid({
|
|
450
|
-
name: 'grid_deleteButtonClick1',
|
|
451
|
-
component: 'TekGrid',
|
|
452
|
-
deleteButton: 'currentRow',
|
|
453
|
-
});
|
|
454
|
-
|
|
455
|
-
const spy = jest.spyOn(instance, 'deleteRows');
|
|
456
|
-
instance.onCreated();
|
|
457
|
-
|
|
458
|
-
const button = createAtomAndClick('DELETE_BUTTON', Button, instance);
|
|
459
|
-
expect(spy).toHaveBeenCalled();
|
|
460
|
-
expect(button.isVisible).toBeTruthy();
|
|
461
|
-
expect(button.disabled).toBeTruthy();
|
|
462
|
-
spy.mockReset();
|
|
463
|
-
});
|
|
464
|
-
|
|
465
|
-
it('should call events', () => {
|
|
466
|
-
let beforeDeleteCalled = false;
|
|
467
|
-
let afterDeleteCalled = false;
|
|
468
|
-
const instance = new TekGrid({
|
|
469
|
-
name: 'grid_deleteClick2',
|
|
470
|
-
component: 'TekGrid',
|
|
471
|
-
events: {
|
|
472
|
-
beforeDelete: () => { beforeDeleteCalled = true; },
|
|
473
|
-
afterDelete: () => { afterDeleteCalled = true; },
|
|
474
|
-
},
|
|
475
|
-
});
|
|
476
|
-
|
|
477
|
-
instance.onCreated();
|
|
478
|
-
createAtomAndClick('DELETE_BUTTON', Button, instance);
|
|
479
|
-
expect(beforeDeleteCalled).toBeTruthy();
|
|
480
|
-
expect(afterDeleteCalled).toBeTruthy();
|
|
481
|
-
});
|
|
482
|
-
|
|
483
|
-
it('should not call afterDelete if beforeDelete call preventDefault', () => {
|
|
484
|
-
const beforeDeleteMock = jest.fn().mockImplementation(({ event }) => { event.defaultPrevented = true });
|
|
485
|
-
const afterDeleteMock = jest.fn();
|
|
486
|
-
const instance = new TekGrid({
|
|
487
|
-
name: 'grid_deleteClick3',
|
|
488
|
-
component: 'TekGrid',
|
|
489
|
-
events: {
|
|
490
|
-
beforeDelete: beforeDeleteMock,
|
|
491
|
-
afterDelete: afterDeleteMock,
|
|
492
|
-
},
|
|
493
|
-
});
|
|
494
|
-
|
|
495
|
-
const spy = jest.spyOn(instance, 'cancelEditedRows');
|
|
496
|
-
instance.onCreated();
|
|
497
|
-
|
|
498
|
-
createAtomAndClick('DELETE_BUTTON', Button, instance);
|
|
499
|
-
|
|
500
|
-
expect(beforeDeleteMock).toHaveBeenCalled();
|
|
501
|
-
expect(afterDeleteMock).not.toHaveBeenCalled();
|
|
502
|
-
expect(spy).not.toHaveBeenCalled();
|
|
503
|
-
spy.mockReset();
|
|
504
|
-
});
|
|
505
|
-
|
|
506
|
-
it('when deleteButton is clicked with selectAllPages, should throw', () => {
|
|
507
|
-
const instance = new TekGrid({
|
|
508
|
-
name: 'grid_deleteButtonClick1',
|
|
509
|
-
component: 'TekGrid',
|
|
510
|
-
deleteButton: 'selection',
|
|
511
|
-
selectAllPages: true,
|
|
512
|
-
datasource: {
|
|
513
|
-
data: [{ id: '1' }],
|
|
514
|
-
},
|
|
515
|
-
});
|
|
516
|
-
|
|
517
|
-
instance.onCreated();
|
|
518
|
-
|
|
519
|
-
const button = createAtom('DELETE_BUTTON', Button, instance);
|
|
520
|
-
|
|
521
|
-
expect(button.isVisible).toBeTruthy();
|
|
522
|
-
expect(button.disabled).toBeTruthy();
|
|
523
|
-
|
|
524
|
-
instance.selectAll(true);
|
|
525
|
-
|
|
526
|
-
expect(button.disabled).toBeFalsy();
|
|
527
|
-
expect(() => setClick(button)).toThrow();
|
|
528
|
-
});
|
|
529
|
-
});
|
|
530
|
-
|
|
531
|
-
describe('disableDeleteButton', () => {
|
|
532
|
-
it('should not disable deleteButton when deleteButton equals none', () => {
|
|
533
|
-
const instance = new TekGrid({
|
|
534
|
-
name: 'grid_deleteButtonClick1',
|
|
535
|
-
component: 'TekGrid',
|
|
536
|
-
deleteButton: 'none',
|
|
537
|
-
});
|
|
538
|
-
|
|
539
|
-
instance.onCreated();
|
|
540
|
-
const button = createAtom('DELETE_BUTTON', Button, instance);
|
|
541
|
-
expect(button.isVisible).toBeFalsy();
|
|
542
|
-
expect(button.disabled).toBeFalsy();
|
|
543
|
-
});
|
|
544
|
-
});
|
|
545
|
-
|
|
546
|
-
describe('getConditionalProps', () => {
|
|
547
|
-
it('should return an empty object when no conditions are applied', () => {
|
|
548
|
-
const grid = setupInstance();
|
|
549
|
-
const row = grid.datasource.data[0];
|
|
550
|
-
const column = grid.columns[0];
|
|
551
|
-
const result = grid.getConditionalProps({ row, column });
|
|
552
|
-
expect(result).toEqual({});
|
|
553
|
-
});
|
|
554
|
-
|
|
555
|
-
it('should merge row style conditions and cell applied conditions', () => {
|
|
556
|
-
const grid = setupInstance();
|
|
557
|
-
grid.getRowStyleConditions = jest.fn().mockReturnValue({ backgroundColor: 'red' });
|
|
558
|
-
grid.getAppliedConditions = jest.fn().mockReturnValue({ fontSize: '12px' });
|
|
559
|
-
const row = grid.datasource.data[0];
|
|
560
|
-
const column = grid.columns[0];
|
|
561
|
-
const result = grid.getConditionalProps({ row, column });
|
|
562
|
-
expect(result).toEqual({ backgroundColor: 'red', fontSize: '12px' });
|
|
563
|
-
});
|
|
564
|
-
});
|
|
565
|
-
|
|
566
|
-
describe('onCreated()', () => {
|
|
567
|
-
it('should call DynamicFilterDatasourceFactory to create dynamic filter datasources', () => {
|
|
568
|
-
const spy = jest.spyOn(DynamicFilterDatasourceFactory.prototype, 'factory');
|
|
569
|
-
setupInstance({ name: 'grid', component: 'TekGrid', datasource: { type: 'tek-memory' } });
|
|
570
|
-
|
|
571
|
-
expect(spy).toHaveBeenCalled();
|
|
572
|
-
spy.mockReset();
|
|
573
|
-
});
|
|
574
|
-
});
|
|
575
|
-
|
|
576
|
-
describe('onMounted()', () => {
|
|
577
|
-
it('should call KeyMapMerger bind', () => {
|
|
578
|
-
const spy = jest.spyOn(KeyMapMerger.prototype, 'bind');
|
|
579
|
-
const instance = setupInstance({ name: 'grid', component: 'TekGrid' });
|
|
580
|
-
instance.onMounted({} as HTMLElement);
|
|
581
|
-
|
|
582
|
-
expect(spy).toHaveBeenCalled();
|
|
583
|
-
spy.mockReset();
|
|
584
|
-
});
|
|
585
|
-
});
|
|
586
|
-
|
|
587
|
-
describe('onBeforeDestroy()', () => {
|
|
588
|
-
it('should call KeyMapMerger unbind', () => {
|
|
589
|
-
const spy = jest.spyOn(KeyMapMerger.prototype, 'unbind');
|
|
590
|
-
const instance = setupInstance({ name: 'grid', component: 'TekGrid' });
|
|
591
|
-
instance.onMounted({} as HTMLElement);
|
|
592
|
-
instance.onBeforeDestroy();
|
|
593
|
-
|
|
594
|
-
expect(spy).toHaveBeenCalled();
|
|
595
|
-
spy.mockReset();
|
|
596
|
-
});
|
|
597
|
-
});
|
|
598
|
-
|
|
599
|
-
describe('columnHasFilter()', () => {
|
|
600
|
-
it('should return true if column has filter', () => {
|
|
601
|
-
const datasourceMock = { hasFilter: jest.fn(() => true) };
|
|
602
|
-
const instance = new TekGrid({ name: 'grid', component: 'TekGrid' });
|
|
603
|
-
instance.datasource = datasourceMock as any as Datasource;
|
|
604
|
-
|
|
605
|
-
expect(instance.columnHasFilter('test')).toBeTruthy();
|
|
606
|
-
});
|
|
607
|
-
});
|
|
608
|
-
|
|
609
|
-
describe('TekGrid Delegations', () => {
|
|
610
|
-
const mockProps = {
|
|
611
|
-
name: 'test-grid',
|
|
612
|
-
component: 'ZdGrid',
|
|
613
|
-
};
|
|
614
|
-
|
|
615
|
-
it('should call IterableTable delegation methods', () => {
|
|
616
|
-
const spyObj = spyOnAllMethods(IterableTable.prototype);
|
|
617
|
-
const instance = new TekGrid(mockProps);
|
|
618
|
-
|
|
619
|
-
instance.changeOrder([{ key: 'name', order: 'asc' }]);
|
|
620
|
-
expect(spyObj.changeOrder).toHaveBeenCalledWith([{ key: 'name', order: 'asc' }]);
|
|
621
|
-
|
|
622
|
-
instance.selectCell({ id: 1 }, { name: 'test' } as any);
|
|
623
|
-
expect(spyObj.selectCell).toHaveBeenCalledWith({ id: 1 }, { name: 'test' });
|
|
624
|
-
|
|
625
|
-
instance.reapplyRowStyleConditions({ id: 1 });
|
|
626
|
-
expect(spyObj.reapplyRowStyleConditions).toHaveBeenCalledWith({ id: 1 });
|
|
627
|
-
|
|
628
|
-
instance.getRowStyleConditions({ id: 1 });
|
|
629
|
-
expect(spyObj.getRowStyleConditions).toHaveBeenCalledWith({ id: 1 });
|
|
630
|
-
|
|
631
|
-
instance.deleteRows();
|
|
632
|
-
expect(spyObj.deleteRows).toHaveBeenCalled();
|
|
633
|
-
});
|
|
634
|
-
|
|
635
|
-
it('should call GroupedDataSelector delegation methods', () => {
|
|
636
|
-
const spyObj = spyOnAllMethods(GroupedDataSelector.prototype);
|
|
637
|
-
const instance = new TekGrid(mockProps);
|
|
638
|
-
|
|
639
|
-
instance.selectAll(true);
|
|
640
|
-
expect(spyObj.selectAll).toHaveBeenCalledWith(true);
|
|
641
|
-
|
|
642
|
-
instance.toggleRow({ id: 1 });
|
|
643
|
-
expect(spyObj.toggleRow).toHaveBeenCalledWith({ id: 1 });
|
|
644
|
-
|
|
645
|
-
instance.selectRow({ id: 1 }, true);
|
|
646
|
-
expect(spyObj.selectRow).toHaveBeenCalledWith({ id: 1 }, true);
|
|
647
|
-
|
|
648
|
-
instance.callDisableSelection({ id: 1 });
|
|
649
|
-
expect(spyObj.callDisableSelection).toHaveBeenCalledWith({ id: 1 });
|
|
650
|
-
|
|
651
|
-
instance.selectClick({ id: 1 }, true, {} as Event);
|
|
652
|
-
expect(spyObj.selectClick).toHaveBeenCalledWith({ id: 1 }, true, {}, undefined);
|
|
653
|
-
|
|
654
|
-
instance.selectAllClick(true, {} as Event);
|
|
655
|
-
expect(spyObj.selectAllClick).toHaveBeenCalledWith(true, {}, undefined);
|
|
656
|
-
});
|
|
657
|
-
|
|
658
|
-
it('should call TekGridEvents delegation methods', () => {
|
|
659
|
-
const spyObj = spyOnAllMethods(TekGridEvents.prototype);
|
|
660
|
-
const instance = new TekGrid(mockProps);
|
|
661
|
-
|
|
662
|
-
instance.calcSummary({ name: 'test' } as any, {} as any, { id: 1 });
|
|
663
|
-
expect(spyObj.calcSummary).toHaveBeenCalledWith({ name: 'test' }, {}, { id: 1 });
|
|
664
|
-
|
|
665
|
-
instance.rowClick({ id: 1 }, {} as Event);
|
|
666
|
-
expect(spyObj.rowClick).toHaveBeenCalledWith({ id: 1 }, {}, undefined);
|
|
667
|
-
|
|
668
|
-
instance.rowDoubleClick({ id: 1 }, {} as Event);
|
|
669
|
-
expect(spyObj.rowDoubleClick).toHaveBeenCalledWith({ id: 1 }, {}, undefined);
|
|
670
|
-
|
|
671
|
-
instance.cellDoubleClick({ id: 1 }, { name: 'test' } as any, {} as Event);
|
|
672
|
-
expect(spyObj.cellDoubleClick).toHaveBeenCalledWith({ id: 1 }, { name: 'test' }, {}, undefined);
|
|
673
|
-
|
|
674
|
-
instance.inlineEdit({ id: 1 }, { name: 'test' } as any);
|
|
675
|
-
expect(spyObj.inlineEdit).toHaveBeenCalledWith({ id: 1 }, { name: 'test' }, undefined, undefined);
|
|
676
|
-
|
|
677
|
-
instance.cellClick({ id: 1 }, { name: 'test' } as any, {} as Event);
|
|
678
|
-
expect(spyObj.cellClick).toHaveBeenCalledWith({ id: 1 }, { name: 'test' }, {}, undefined);
|
|
679
|
-
|
|
680
|
-
instance.cellClickEvent({ id: 1 }, { name: 'test' } as any, {} as Event);
|
|
681
|
-
expect(spyObj.cellClickEvent).toHaveBeenCalledWith({ id: 1 }, { name: 'test' }, {}, undefined);
|
|
682
|
-
|
|
683
|
-
instance.groupRowClick({ id: 1 }, {} as Event);
|
|
684
|
-
expect(spyObj.groupRowClick).toHaveBeenCalledWith({ id: 1 }, {}, undefined);
|
|
685
|
-
|
|
686
|
-
instance.groupRowDoubleClick({ id: 1 }, {} as Event);
|
|
687
|
-
expect(spyObj.groupRowDoubleClick).toHaveBeenCalledWith({ id: 1 }, {}, undefined);
|
|
688
|
-
|
|
689
|
-
instance.selectGroupClick({ id: 1 }, true, {} as Event);
|
|
690
|
-
expect(spyObj.selectGroupClick).toHaveBeenCalledWith({ id: 1 }, true, {}, undefined);
|
|
691
|
-
});
|
|
692
|
-
|
|
693
|
-
it('should call GroupedDataNavigator delegation methods', () => {
|
|
694
|
-
const spyObj = spyOnAllMethods(GroupedDataNavigator.prototype);
|
|
695
|
-
const instance = new TekGrid(mockProps);
|
|
696
|
-
|
|
697
|
-
instance.navigatePageUp();
|
|
698
|
-
expect(spyObj.navigatePageUp).toHaveBeenCalled();
|
|
699
|
-
|
|
700
|
-
instance.navigatePageDown();
|
|
701
|
-
expect(spyObj.navigatePageDown).toHaveBeenCalled();
|
|
702
|
-
|
|
703
|
-
instance.navigateDatasource('up');
|
|
704
|
-
expect(spyObj.navigateDatasource).toHaveBeenCalledWith('up');
|
|
705
|
-
});
|
|
706
|
-
|
|
707
|
-
it('should call ViewNavigator delegation methods', () => {
|
|
708
|
-
const spyObj = spyOnAllMethods(ViewNavigator.prototype);
|
|
709
|
-
const instance = new TekGrid(mockProps);
|
|
710
|
-
|
|
711
|
-
instance.setViewNavigate(() => {});
|
|
712
|
-
expect(spyObj.setViewNavigate).toHaveBeenCalled();
|
|
713
|
-
|
|
714
|
-
instance.navigateLeft({} as any);
|
|
715
|
-
expect(spyObj.navigateLeft).not.toHaveBeenCalledWith({});
|
|
716
|
-
|
|
717
|
-
instance.navigateRight({} as any);
|
|
718
|
-
expect(spyObj.navigateRight).not.toHaveBeenCalledWith({});
|
|
719
|
-
|
|
720
|
-
instance.cellSelection = true;
|
|
721
|
-
|
|
722
|
-
instance.navigateLeft({} as any);
|
|
723
|
-
expect(spyObj.navigateLeft).toHaveBeenCalledWith({});
|
|
724
|
-
|
|
725
|
-
instance.navigateRight({} as any);
|
|
726
|
-
expect(spyObj.navigateRight).toHaveBeenCalledWith({});
|
|
727
|
-
|
|
728
|
-
instance.navigateUp();
|
|
729
|
-
expect(spyObj.navigateUp).toHaveBeenCalled();
|
|
730
|
-
|
|
731
|
-
instance.navigateDown();
|
|
732
|
-
expect(spyObj.navigateDown).toHaveBeenCalled();
|
|
733
|
-
});
|
|
734
|
-
|
|
735
|
-
it('should call DataEditorWithAdd delegation methods', () => {
|
|
736
|
-
const spyObj = spyOnAllMethods(DataEditorWithAdd.prototype);
|
|
737
|
-
const instance = new TekGrid(mockProps);
|
|
738
|
-
|
|
739
|
-
instance.addCancelColumn();
|
|
740
|
-
expect(spyObj.addCancelColumn).toHaveBeenCalled();
|
|
741
|
-
|
|
742
|
-
instance.getCancelColumnProps();
|
|
743
|
-
expect(spyObj.getCancelColumnProps).toHaveBeenCalled();
|
|
744
|
-
|
|
745
|
-
instance.isAdded({ id: 1 });
|
|
746
|
-
expect(spyObj.isAdded).toHaveBeenCalledWith({ id: 1 });
|
|
747
|
-
|
|
748
|
-
instance.cancelAddedRow('1');
|
|
749
|
-
expect(spyObj.cancelAddedRow).toHaveBeenCalledWith('1');
|
|
750
|
-
|
|
751
|
-
instance.cancelAddedRows();
|
|
752
|
-
expect(spyObj.cancelAddedRows).toHaveBeenCalled();
|
|
753
|
-
|
|
754
|
-
instance.getAddedRows();
|
|
755
|
-
expect(spyObj.getAddedRows).toHaveBeenCalled();
|
|
756
|
-
|
|
757
|
-
instance.addNewRow({ id: 1 });
|
|
758
|
-
expect(spyObj.addNewRow).toHaveBeenCalledWith({ id: 1 }, undefined);
|
|
759
|
-
|
|
760
|
-
instance.getVisibleValue({ id: 1 }, { name: 'test' } as any);
|
|
761
|
-
expect(spyObj.getVisibleValue).toHaveBeenCalledWith({ id: 1 }, { name: 'test' });
|
|
762
|
-
|
|
763
|
-
instance.getEditableComponent({ name: 'test' } as any, { id: 1 });
|
|
764
|
-
expect(spyObj.getEditableComponent).toHaveBeenCalledWith({ name: 'test' }, { id: 1 });
|
|
765
|
-
|
|
766
|
-
instance.isEdited({ name: 'test' } as any, { id: 1 });
|
|
767
|
-
expect(spyObj.isEdited).toHaveBeenCalledWith({ name: 'test' }, { id: 1 });
|
|
768
|
-
|
|
769
|
-
instance.isValid({ name: 'test' } as any, { id: 1 });
|
|
770
|
-
expect(spyObj.isValid).toHaveBeenCalledWith({ name: 'test' }, { id: 1 }, undefined);
|
|
771
|
-
|
|
772
|
-
instance.isGridValid();
|
|
773
|
-
expect(spyObj.isGridValid).toHaveBeenCalled();
|
|
774
|
-
|
|
775
|
-
instance.getComponent('1', 'name');
|
|
776
|
-
expect(spyObj.getComponent).toHaveBeenCalledWith('1', 'name');
|
|
777
|
-
|
|
778
|
-
instance.updateRow({ id: 1 });
|
|
779
|
-
expect(spyObj.updateRow).toHaveBeenCalledWith({ id: 1 });
|
|
780
|
-
|
|
781
|
-
instance.updateCell('1', 'name', 'value');
|
|
782
|
-
expect(spyObj.updateCell).toHaveBeenCalledWith('1', 'name', 'value');
|
|
783
|
-
|
|
784
|
-
instance.setViewEnterEdit(() => {});
|
|
785
|
-
expect(spyObj.setViewEnterEdit).toHaveBeenCalled();
|
|
786
|
-
|
|
787
|
-
instance.enterEdit('1', 'name');
|
|
788
|
-
expect(spyObj.enterEdit).toHaveBeenCalledWith('1', 'name');
|
|
789
|
-
|
|
790
|
-
instance.cancelEditedRows();
|
|
791
|
-
expect(spyObj.cancelEditedRows).toHaveBeenCalled();
|
|
792
|
-
|
|
793
|
-
instance.saveEditedRows();
|
|
794
|
-
expect(spyObj.saveEditedRows).toHaveBeenCalled();
|
|
795
|
-
|
|
796
|
-
instance.reapplyCanEditRow({ id: 1 });
|
|
797
|
-
expect(spyObj.reapplyCanEditRow).toHaveBeenCalledWith({ id: 1 });
|
|
798
|
-
|
|
799
|
-
instance.getCanEditRow({ id: 1 });
|
|
800
|
-
expect(spyObj.getCanEditRow).toHaveBeenCalledWith({ id: 1 });
|
|
801
|
-
|
|
802
|
-
instance.getEditedRows();
|
|
803
|
-
expect(spyObj.getEditedRows).toHaveBeenCalled();
|
|
804
|
-
|
|
805
|
-
instance.checkValid({ name: 'test' } as any, { id: 1 });
|
|
806
|
-
expect(spyObj.checkValid).toHaveBeenCalledWith({ name: 'test' }, { id: 1 });
|
|
807
|
-
|
|
808
|
-
instance.getEditedRow({ id: 1 });
|
|
809
|
-
expect(spyObj.getEditedRow).toHaveBeenCalledWith({ id: 1 });
|
|
810
|
-
});
|
|
811
|
-
|
|
812
|
-
it('should call TableActionBuilder delegation methods', () => {
|
|
813
|
-
const spyObj = spyOnAllMethods(TableActionBuilder.prototype);
|
|
814
|
-
const instance = new TekGrid(mockProps);
|
|
815
|
-
|
|
816
|
-
instance.getActionComponent({} as any, { name: 'test' } as any, { id: 1 });
|
|
817
|
-
expect(spyObj.getActionComponent).toHaveBeenCalledWith({}, { name: 'test' }, { id: 1 }, undefined);
|
|
818
|
-
});
|
|
819
|
-
|
|
820
|
-
it('should call GroupedDataManager delegation methods', () => {
|
|
821
|
-
const spyObj = spyOnAllMethods(GroupedDataManager.prototype);
|
|
822
|
-
const instance = new TekGrid(mockProps);
|
|
823
|
-
|
|
824
|
-
instance.registerTask(Promise.resolve());
|
|
825
|
-
expect(spyObj.registerTask).toHaveBeenCalled();
|
|
826
|
-
|
|
827
|
-
instance.loadAfterTasks();
|
|
828
|
-
expect(spyObj.loadAfterTasks).toHaveBeenCalled();
|
|
829
|
-
|
|
830
|
-
instance.initializeGrouping(true);
|
|
831
|
-
expect(spyObj.initializeGrouping).toHaveBeenCalledWith(true);
|
|
832
|
-
|
|
833
|
-
instance.updateGrouping();
|
|
834
|
-
expect(spyObj.updateGrouping).toHaveBeenCalled();
|
|
835
|
-
|
|
836
|
-
instance.updateGroupedData(true);
|
|
837
|
-
expect(spyObj.updateGroupedData).toHaveBeenCalledWith(true);
|
|
838
|
-
|
|
839
|
-
instance.buildGroupedData();
|
|
840
|
-
expect(spyObj.buildGroupedData).toHaveBeenCalled();
|
|
841
|
-
|
|
842
|
-
instance.openGroup({ group: true });
|
|
843
|
-
expect(spyObj.openGroup).toHaveBeenCalledWith({ group: true });
|
|
844
|
-
|
|
845
|
-
instance.isItemVisible({ id: 1 });
|
|
846
|
-
expect(spyObj.isItemVisible).toHaveBeenCalledWith({ id: 1 });
|
|
847
|
-
|
|
848
|
-
instance.isGrouped();
|
|
849
|
-
expect(spyObj.isGrouped).toHaveBeenCalled();
|
|
850
|
-
|
|
851
|
-
instance.isColumnSearchable({ name: 'test' } as any);
|
|
852
|
-
expect(spyObj.isColumnSearchable).toHaveBeenCalledWith({ name: 'test' });
|
|
853
|
-
|
|
854
|
-
instance.getGroupedData();
|
|
855
|
-
expect(spyObj.getGroupedData).toHaveBeenCalled();
|
|
856
|
-
|
|
857
|
-
instance.directionalLeft({} as any);
|
|
858
|
-
expect(spyObj.directionalLeft).toHaveBeenCalledWith({});
|
|
859
|
-
|
|
860
|
-
instance.directionalRight({} as any);
|
|
861
|
-
expect(spyObj.directionalRight).toHaveBeenCalledWith({});
|
|
862
|
-
|
|
863
|
-
instance.setViewUpdateFixedColumns(() => {});
|
|
864
|
-
expect(spyObj.setViewUpdateFixedColumns).toHaveBeenCalled();
|
|
865
|
-
|
|
866
|
-
instance.setViewUpdateScrollData(() => {});
|
|
867
|
-
expect(spyObj.setViewUpdateScrollData).toHaveBeenCalled();
|
|
868
|
-
});
|
|
869
|
-
|
|
870
|
-
it('should call TekGridToolbarProvider delegation methods', () => {
|
|
871
|
-
const spyObj = spyOnAllMethods(TekGridToolbarProvider.prototype);
|
|
872
|
-
const instance = new TekGrid(mockProps);
|
|
873
|
-
|
|
874
|
-
instance.getAtomInstance('TITLE');
|
|
875
|
-
expect(spyObj.getAtomInstance).toHaveBeenCalledWith('TITLE');
|
|
876
|
-
|
|
877
|
-
instance.getAtomName('TITLE');
|
|
878
|
-
expect(spyObj.getAtomName).toHaveBeenCalledWith('TITLE');
|
|
879
|
-
});
|
|
880
|
-
|
|
881
|
-
it('should call ColumnsSearcher delegation methods', () => {
|
|
882
|
-
const spyObj = spyOnAllMethods(ColumnsSearcher.prototype);
|
|
883
|
-
const instance = new TekGrid(mockProps);
|
|
884
|
-
instance.datasource = new TekRestDatasource({ lazyLoad: false });
|
|
885
|
-
|
|
886
|
-
instance.setSearch('test');
|
|
887
|
-
expect(spyObj.searchColumn).toHaveBeenCalled();
|
|
888
|
-
|
|
889
|
-
spyObj.searchColumn.mockClear();
|
|
890
|
-
|
|
891
|
-
instance.datasource = new TekMemoryDatasource({ lazyLoad: false });
|
|
892
|
-
|
|
893
|
-
instance.setSearch('test');
|
|
894
|
-
expect(spyObj.searchColumn).toHaveBeenCalled();
|
|
895
|
-
});
|
|
896
|
-
});
|
|
897
|
-
});
|