@zeedhi/teknisa-components-common 1.108.0 → 1.109.1
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/LICENSE +21 -21
- package/README.md +7 -7
- package/coverage/clover.xml +49 -49
- package/coverage/coverage-final.json +47 -47
- package/coverage/lcov-report/index.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/component-event-helper.ts.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/flush-promises-helper.ts.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/get-child-helper.ts.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/index.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/index.ts.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/mock-created-helper.ts.html +1 -1
- package/coverage/lcov.info +47 -47
- package/jest.config.js +1 -1
- package/package.json +2 -2
- package/tests/__helpers__/component-event-helper.ts +5 -5
- package/tests/__helpers__/flush-promises-helper.ts +3 -3
- package/tests/__helpers__/get-child-helper.ts +27 -27
- package/tests/__helpers__/index.ts +3 -3
- package/tests/__helpers__/mock-created-helper.ts +12 -12
- package/tests/__mocks__/@zeedhi/core/i18n.js +74 -74
- package/tests/__mocks__/@zeedhi/core.js +4 -4
- package/tests/unit/components/crud/crud-add-button.spec.ts +56 -56
- package/tests/unit/components/crud/crud-button.spec.ts +94 -94
- package/tests/unit/components/crud/crud-cancel-button.spec.ts +91 -91
- package/tests/unit/components/crud/crud-delete-button.spec.ts +122 -122
- package/tests/unit/components/crud/crud-form.spec.ts +165 -165
- package/tests/unit/components/crud/crud-save-button.spec.ts +118 -118
- package/tests/unit/components/tek-breadcrumb-header/tek-breadcrumb-header.spec.ts +42 -42
- package/tests/unit/components/tek-card-title/CardTitle.spec.ts +34 -34
- package/tests/unit/components/tek-datasource/memory-datasource.spec.ts +470 -470
- package/tests/unit/components/tek-datasource/rest-datasource.spec.ts +364 -364
- package/tests/unit/components/tek-drag-grid/tek-drag-grid.spec.ts +112 -112
- package/tests/unit/components/tek-grid/filter-helper.spec.ts +148 -148
- package/tests/unit/components/tek-grid/grid-column.spec.ts +270 -270
- package/tests/unit/components/tek-grid/grid-columns-button.spec.ts +195 -195
- package/tests/unit/components/tek-grid/grid-filter-button.spec.ts +967 -967
- package/tests/unit/components/tek-grid/grid.spec.ts +3340 -3340
- package/tests/unit/components/tek-grid/layout_options.spec.ts +980 -980
- package/tests/unit/components/tek-image/Image.spec.ts +67 -67
- package/tests/unit/components/tek-iterable-carousel/iterable-carousel.spec.ts +37 -37
- package/tests/unit/components/tek-iterable-component-render/iterable-component-render.spec.ts +200 -200
- package/tests/unit/components/tek-loading/Loading.spec.ts +30 -30
- package/tests/unit/components/tek-notifications/notifications.spec.ts +201 -201
- package/tests/unit/components/tek-product-card/product-card.spec.ts +61 -61
- package/tests/unit/components/tek-user-info/TekUserInfoContoller.spec.ts +220 -220
- package/tests/unit/components/tek-user-info/tek-user-info-list.spec.ts +86 -86
- package/tests/unit/components/tek-user-info/tek-user-info.spec.ts +430 -430
- package/tests/unit/components/tree-grid/tree-grid.spec.ts +776 -776
- package/tests/unit/utils/grid-base/delete-rows-error.spec.ts +24 -24
- package/tests/unit/utils/grid-base/export-options/button-option.spec.ts +44 -44
- package/tests/unit/utils/grid-base/export-options/multi-option.spec.ts +135 -135
- package/tests/unit/utils/grid-base/grid-controller.spec.ts +267 -267
- package/tests/unit/utils/report-filter/report-filter.spec.ts +66 -66
- package/tsconfig.eslint.json +8 -8
- package/types/components/tek-ag-grid/default-icons.d.ts +53 -0
- package/types/components/tek-ag-grid/interfaces.d.ts +9 -0
- package/types/components/tek-ag-grid/tek-ag-grid.d.ts +35 -0
- package/types/components/tek-datasource/datasource.d.ts +94 -0
- package/types/components/tek-datasource/memory-datasource.d.ts +4 -2
- package/types/components/tek-datasource/rest-datasource.d.ts +4 -6
- package/types/components/tek-grid/default-icons.d.ts +53 -0
- package/types/components/tek-grid/filter-dynamic-values.d.ts +9 -0
- package/types/components/tek-grid/grid-controller.d.ts +19 -0
- package/types/components/tek-grid/grid_column.d.ts +14 -0
- package/types/components/tek-grid/grid_controller.d.ts +15 -0
- package/types/components/tek-grid/tek-grid.d.ts +35 -0
- package/types/components/tek-login/interfaces.d.ts +3 -0
- package/types/components/tek-login/login-children.d.ts +3 -0
- package/types/components/tek-login/login.d.ts +58 -0
- package/types/components/tek-login/login_children.d.ts +3 -0
|
@@ -1,267 +1,267 @@
|
|
|
1
|
-
import {
|
|
2
|
-
TekGrid,
|
|
3
|
-
} from '../../../../src';
|
|
4
|
-
import { GridController } from '../../../../src/utils/grid-base/grid-controller';
|
|
5
|
-
|
|
6
|
-
describe('GridController', () => {
|
|
7
|
-
describe('constructor()', () => {
|
|
8
|
-
it('should create controller and get info from grid', () => {
|
|
9
|
-
const grid = new TekGrid({
|
|
10
|
-
name: 'Grid',
|
|
11
|
-
component: 'TekGrid',
|
|
12
|
-
title: 'title',
|
|
13
|
-
addButton: false,
|
|
14
|
-
deleteButton: 'currentRow',
|
|
15
|
-
filterButton: true,
|
|
16
|
-
columnsButton: true,
|
|
17
|
-
editing: true,
|
|
18
|
-
showEditButtons: false,
|
|
19
|
-
modalFilterProps: {
|
|
20
|
-
name: 'name',
|
|
21
|
-
height: 'auto',
|
|
22
|
-
persistent: true,
|
|
23
|
-
},
|
|
24
|
-
showExport: true,
|
|
25
|
-
showLayoutOptionsButton: true,
|
|
26
|
-
showReloadButton: true,
|
|
27
|
-
actions: [{ name: 'button', component: 'ZdButton' }],
|
|
28
|
-
});
|
|
29
|
-
grid.editing = false;
|
|
30
|
-
const instance = new GridController(grid);
|
|
31
|
-
expect(instance.gridTitle).toBe('title');
|
|
32
|
-
expect(instance.showAddButton).toBeFalsy();
|
|
33
|
-
expect(instance.showDeleteButton).toBeTruthy();
|
|
34
|
-
expect(instance.showFilterButton).toBeTruthy();
|
|
35
|
-
expect(instance.showActionsButton).toBeTruthy();
|
|
36
|
-
expect(instance.showExportButton).toBeTruthy();
|
|
37
|
-
expect(instance.showActionAndExportButton).toBeTruthy();
|
|
38
|
-
expect(instance.showSearchInput).toBeTruthy();
|
|
39
|
-
expect(instance.showToolbar).toBeTruthy();
|
|
40
|
-
expect(instance.toolbarStyle).toBe('');
|
|
41
|
-
expect(instance.tooltipName).toBe('TEKGRID_HIDE');
|
|
42
|
-
expect(instance.showColumnsButton).toBeTruthy();
|
|
43
|
-
expect(instance.columnsButtonIgnore).toEqual([]);
|
|
44
|
-
expect(instance.showLayoutOptionsButton).toBeTruthy();
|
|
45
|
-
expect(instance.showReloadButton).toBeTruthy();
|
|
46
|
-
expect(instance.showDivider).toBeTruthy();
|
|
47
|
-
expect(instance.isEditing).toBeFalsy();
|
|
48
|
-
expect(instance.isNotEditing).toBeTruthy();
|
|
49
|
-
expect(instance.showEditButtons).toBeFalsy();
|
|
50
|
-
expect(instance.disableDeleteButton).toBeTruthy();
|
|
51
|
-
expect(instance.showModalFilterProps).toEqual(
|
|
52
|
-
expect.objectContaining({
|
|
53
|
-
height: 'auto',
|
|
54
|
-
persistent: true,
|
|
55
|
-
}),
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
grid.datasource.currentRow = { id: '1' };
|
|
59
|
-
expect(instance.disableDeleteButton).toBeFalsy();
|
|
60
|
-
grid.showExport = false;
|
|
61
|
-
grid.showLayoutOptions = false;
|
|
62
|
-
grid.showReload = false;
|
|
63
|
-
grid.columnsButton = false;
|
|
64
|
-
grid.actions = [];
|
|
65
|
-
grid.deleteButton = 'selection';
|
|
66
|
-
grid.selectedRows = [{ id: '1' }];
|
|
67
|
-
expect(instance.disableDeleteButton).toBeFalsy();
|
|
68
|
-
expect(instance.showExportButton).toBeFalsy();
|
|
69
|
-
expect(instance.showActionAndExportButton).toBeFalsy();
|
|
70
|
-
expect(instance.showLayoutOptionsButton).toBeFalsy();
|
|
71
|
-
|
|
72
|
-
instance.showToolbar = false;
|
|
73
|
-
expect(instance.toolbarStyle).toBe('is-rotated');
|
|
74
|
-
expect(instance.tooltipName).toBe('TEKGRID_SHOW');
|
|
75
|
-
expect(instance.showToolbar).toBeFalsy();
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('should verify if showDivider3 is visibility', () => {
|
|
79
|
-
const grid = new TekGrid({
|
|
80
|
-
name: 'Grid',
|
|
81
|
-
component: 'TekGrid',
|
|
82
|
-
addButton: false,
|
|
83
|
-
deleteButton: 'none',
|
|
84
|
-
filterButton: false,
|
|
85
|
-
columnsButton: false,
|
|
86
|
-
showReload: false,
|
|
87
|
-
showLayoutOptions: false,
|
|
88
|
-
showReloadButton: true,
|
|
89
|
-
showSearch: false,
|
|
90
|
-
showExport: false,
|
|
91
|
-
actions: [],
|
|
92
|
-
});
|
|
93
|
-
const instance = new GridController(grid);
|
|
94
|
-
|
|
95
|
-
expect(instance.showActionsButton).toBeFalsy();
|
|
96
|
-
expect(instance.showExportButton).toBeFalsy();
|
|
97
|
-
expect(instance.showSearchInput).toBeFalsy();
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('should verify if showActionAndExportButton is visibility', () => {
|
|
101
|
-
const grid = new TekGrid({
|
|
102
|
-
name: 'Grid',
|
|
103
|
-
component: 'TekGrid',
|
|
104
|
-
addButton: false,
|
|
105
|
-
deleteButton: 'none',
|
|
106
|
-
filterButton: false,
|
|
107
|
-
columnsButton: true,
|
|
108
|
-
showReload: false,
|
|
109
|
-
showLayoutOptions: true,
|
|
110
|
-
showReloadButton: true,
|
|
111
|
-
showSearch: false,
|
|
112
|
-
showExport: false,
|
|
113
|
-
actions: [],
|
|
114
|
-
});
|
|
115
|
-
const instance = new GridController(grid);
|
|
116
|
-
|
|
117
|
-
expect(instance.showActionAndExportButton).toBeFalsy();
|
|
118
|
-
expect(instance.showActionsButton).toBeFalsy();
|
|
119
|
-
expect(instance.showSearchInput).toBeFalsy();
|
|
120
|
-
expect(instance.showExportButton).toBeFalsy();
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('should verify if showDivider2 is visibility', () => {
|
|
124
|
-
const grid = new TekGrid({
|
|
125
|
-
name: 'Grid',
|
|
126
|
-
component: 'TekGrid',
|
|
127
|
-
addButton: false,
|
|
128
|
-
deleteButton: 'none',
|
|
129
|
-
filterButton: false,
|
|
130
|
-
columnsButton: false,
|
|
131
|
-
showReload: true,
|
|
132
|
-
showLayoutOptions: false,
|
|
133
|
-
showSearch: false,
|
|
134
|
-
showExport: false,
|
|
135
|
-
actions: [],
|
|
136
|
-
});
|
|
137
|
-
const instance = new GridController(grid);
|
|
138
|
-
|
|
139
|
-
expect(instance.showActionsButton).toBeFalsy();
|
|
140
|
-
expect(instance.showSearchInput).toBeFalsy();
|
|
141
|
-
expect(instance.showColumnsButton).toBeFalsy();
|
|
142
|
-
expect(instance.showExportButton).toBeFalsy();
|
|
143
|
-
expect(instance.showReloadButton).toBeTruthy();
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it('should verify if showDivider1 is visibility', () => {
|
|
147
|
-
const grid = new TekGrid({
|
|
148
|
-
name: 'Grid',
|
|
149
|
-
component: 'TekGrid',
|
|
150
|
-
addButton: true,
|
|
151
|
-
deleteButton: 'selection',
|
|
152
|
-
filterButton: false,
|
|
153
|
-
columnsButton: false,
|
|
154
|
-
showReload: false,
|
|
155
|
-
showLayoutOptions: false,
|
|
156
|
-
showSearch: false,
|
|
157
|
-
showExport: false,
|
|
158
|
-
actions: [],
|
|
159
|
-
});
|
|
160
|
-
const instance = new GridController(grid);
|
|
161
|
-
|
|
162
|
-
expect(instance.showActionsButton).toBeFalsy();
|
|
163
|
-
expect(instance.showSearchInput).toBeFalsy();
|
|
164
|
-
expect(instance.showColumnsButton).toBeFalsy();
|
|
165
|
-
expect(instance.showExportButton).toBeFalsy();
|
|
166
|
-
expect(instance.showReloadButton).toBeFalsy();
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
describe('showAddButton', () => {
|
|
170
|
-
it('should return true when addButton is true, not editing, and toolbar is open', () => {
|
|
171
|
-
const grid = new TekGrid({
|
|
172
|
-
name: 'Grid', component: 'TekGrid', addButton: true, editing: false,
|
|
173
|
-
});
|
|
174
|
-
const instance = new GridController(grid);
|
|
175
|
-
instance.openToolbar = true;
|
|
176
|
-
expect(instance.showAddButton).toBe(true);
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it('should return false when grid is in editing mode', () => {
|
|
180
|
-
const grid = new TekGrid({
|
|
181
|
-
name: 'Grid', component: 'TekGrid', addButton: true, editing: true,
|
|
182
|
-
});
|
|
183
|
-
const instance = new GridController(grid);
|
|
184
|
-
expect(instance.showAddButton).toBe(true);
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it('should return false when toolbar is closed', () => {
|
|
188
|
-
const grid = new TekGrid({
|
|
189
|
-
name: 'Grid', component: 'TekGrid', addButton: true, editing: false,
|
|
190
|
-
});
|
|
191
|
-
const instance = new GridController(grid);
|
|
192
|
-
instance.openToolbar = false;
|
|
193
|
-
expect(instance.showAddButton).toBe(false);
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
describe('disableDeleteButton', () => {
|
|
198
|
-
it('should be disabled if selectAllPages is true, allSelected is true, and all items are exceptions', () => {
|
|
199
|
-
const grid = new TekGrid({
|
|
200
|
-
name: 'Grid', component: 'TekGrid', deleteButton: 'selection', selectAllPages: true,
|
|
201
|
-
});
|
|
202
|
-
grid.datasource.total = 3;
|
|
203
|
-
grid.selectionState = { allSelected: true, except: [{ id: 1 }, { id: 2 }, { id: 3 }] };
|
|
204
|
-
const instance = new GridController(grid);
|
|
205
|
-
expect(instance.disableDeleteButton).toBe(true);
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
it('should be disabled if selectAllPages is true, allSelected is false, and no items are exceptions', () => {
|
|
209
|
-
const grid = new TekGrid({
|
|
210
|
-
name: 'Grid', component: 'TekGrid', deleteButton: 'selection', selectAllPages: true,
|
|
211
|
-
});
|
|
212
|
-
grid.selectionState = { allSelected: false, except: [] };
|
|
213
|
-
const instance = new GridController(grid);
|
|
214
|
-
expect(instance.disableDeleteButton).toBe(true);
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
it('should be enabled if selectAllPages is true and there is a valid selection', () => {
|
|
218
|
-
const grid = new TekGrid({
|
|
219
|
-
name: 'Grid', component: 'TekGrid', deleteButton: 'selection', selectAllPages: true,
|
|
220
|
-
});
|
|
221
|
-
grid.datasource.total = 5;
|
|
222
|
-
grid.selectionState = { allSelected: true, except: [{ id: 1 }] };
|
|
223
|
-
const instance = new GridController(grid);
|
|
224
|
-
expect(instance.disableDeleteButton).toBe(false);
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
it('should not be disabled when deleteButton is "none"', () => {
|
|
228
|
-
const grid = new TekGrid({ name: 'Grid', component: 'TekGrid', deleteButton: 'none' }); //
|
|
229
|
-
const instance = new GridController(grid);
|
|
230
|
-
expect(instance.disableDeleteButton).toBe(false);
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
describe('showEditButtons', () => {
|
|
235
|
-
it('deve retornar true quando o grid está em modo de edição e a propriedade showEditButtons é true', () => {
|
|
236
|
-
const grid = new TekGrid({
|
|
237
|
-
name: 'Grid',
|
|
238
|
-
component: 'TekGrid',
|
|
239
|
-
});
|
|
240
|
-
grid.editing = true;
|
|
241
|
-
const instance = new GridController(grid);
|
|
242
|
-
expect(instance.showEditButtons).toBe(true);
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
it('deve retornar false quando o grid não está em modo de edição', () => {
|
|
246
|
-
const grid = new TekGrid({
|
|
247
|
-
name: 'Grid',
|
|
248
|
-
component: 'TekGrid',
|
|
249
|
-
editing: false,
|
|
250
|
-
showEditButtons: true,
|
|
251
|
-
});
|
|
252
|
-
const instance = new GridController(grid);
|
|
253
|
-
expect(instance.showEditButtons).toBe(false);
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
it('deve retornar false quando a propriedade showEditButtons do grid é false', () => {
|
|
257
|
-
const grid = new TekGrid({
|
|
258
|
-
name: 'Grid',
|
|
259
|
-
component: 'TekGrid',
|
|
260
|
-
editing: true,
|
|
261
|
-
showEditButtons: false,
|
|
262
|
-
});
|
|
263
|
-
const instance = new GridController(grid);
|
|
264
|
-
expect(instance.showEditButtons).toBe(false);
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
});
|
|
1
|
+
import {
|
|
2
|
+
TekGrid,
|
|
3
|
+
} from '../../../../src';
|
|
4
|
+
import { GridController } from '../../../../src/utils/grid-base/grid-controller';
|
|
5
|
+
|
|
6
|
+
describe('GridController', () => {
|
|
7
|
+
describe('constructor()', () => {
|
|
8
|
+
it('should create controller and get info from grid', () => {
|
|
9
|
+
const grid = new TekGrid({
|
|
10
|
+
name: 'Grid',
|
|
11
|
+
component: 'TekGrid',
|
|
12
|
+
title: 'title',
|
|
13
|
+
addButton: false,
|
|
14
|
+
deleteButton: 'currentRow',
|
|
15
|
+
filterButton: true,
|
|
16
|
+
columnsButton: true,
|
|
17
|
+
editing: true,
|
|
18
|
+
showEditButtons: false,
|
|
19
|
+
modalFilterProps: {
|
|
20
|
+
name: 'name',
|
|
21
|
+
height: 'auto',
|
|
22
|
+
persistent: true,
|
|
23
|
+
},
|
|
24
|
+
showExport: true,
|
|
25
|
+
showLayoutOptionsButton: true,
|
|
26
|
+
showReloadButton: true,
|
|
27
|
+
actions: [{ name: 'button', component: 'ZdButton' }],
|
|
28
|
+
});
|
|
29
|
+
grid.editing = false;
|
|
30
|
+
const instance = new GridController(grid);
|
|
31
|
+
expect(instance.gridTitle).toBe('title');
|
|
32
|
+
expect(instance.showAddButton).toBeFalsy();
|
|
33
|
+
expect(instance.showDeleteButton).toBeTruthy();
|
|
34
|
+
expect(instance.showFilterButton).toBeTruthy();
|
|
35
|
+
expect(instance.showActionsButton).toBeTruthy();
|
|
36
|
+
expect(instance.showExportButton).toBeTruthy();
|
|
37
|
+
expect(instance.showActionAndExportButton).toBeTruthy();
|
|
38
|
+
expect(instance.showSearchInput).toBeTruthy();
|
|
39
|
+
expect(instance.showToolbar).toBeTruthy();
|
|
40
|
+
expect(instance.toolbarStyle).toBe('');
|
|
41
|
+
expect(instance.tooltipName).toBe('TEKGRID_HIDE');
|
|
42
|
+
expect(instance.showColumnsButton).toBeTruthy();
|
|
43
|
+
expect(instance.columnsButtonIgnore).toEqual([]);
|
|
44
|
+
expect(instance.showLayoutOptionsButton).toBeTruthy();
|
|
45
|
+
expect(instance.showReloadButton).toBeTruthy();
|
|
46
|
+
expect(instance.showDivider).toBeTruthy();
|
|
47
|
+
expect(instance.isEditing).toBeFalsy();
|
|
48
|
+
expect(instance.isNotEditing).toBeTruthy();
|
|
49
|
+
expect(instance.showEditButtons).toBeFalsy();
|
|
50
|
+
expect(instance.disableDeleteButton).toBeTruthy();
|
|
51
|
+
expect(instance.showModalFilterProps).toEqual(
|
|
52
|
+
expect.objectContaining({
|
|
53
|
+
height: 'auto',
|
|
54
|
+
persistent: true,
|
|
55
|
+
}),
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
grid.datasource.currentRow = { id: '1' };
|
|
59
|
+
expect(instance.disableDeleteButton).toBeFalsy();
|
|
60
|
+
grid.showExport = false;
|
|
61
|
+
grid.showLayoutOptions = false;
|
|
62
|
+
grid.showReload = false;
|
|
63
|
+
grid.columnsButton = false;
|
|
64
|
+
grid.actions = [];
|
|
65
|
+
grid.deleteButton = 'selection';
|
|
66
|
+
grid.selectedRows = [{ id: '1' }];
|
|
67
|
+
expect(instance.disableDeleteButton).toBeFalsy();
|
|
68
|
+
expect(instance.showExportButton).toBeFalsy();
|
|
69
|
+
expect(instance.showActionAndExportButton).toBeFalsy();
|
|
70
|
+
expect(instance.showLayoutOptionsButton).toBeFalsy();
|
|
71
|
+
|
|
72
|
+
instance.showToolbar = false;
|
|
73
|
+
expect(instance.toolbarStyle).toBe('is-rotated');
|
|
74
|
+
expect(instance.tooltipName).toBe('TEKGRID_SHOW');
|
|
75
|
+
expect(instance.showToolbar).toBeFalsy();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('should verify if showDivider3 is visibility', () => {
|
|
79
|
+
const grid = new TekGrid({
|
|
80
|
+
name: 'Grid',
|
|
81
|
+
component: 'TekGrid',
|
|
82
|
+
addButton: false,
|
|
83
|
+
deleteButton: 'none',
|
|
84
|
+
filterButton: false,
|
|
85
|
+
columnsButton: false,
|
|
86
|
+
showReload: false,
|
|
87
|
+
showLayoutOptions: false,
|
|
88
|
+
showReloadButton: true,
|
|
89
|
+
showSearch: false,
|
|
90
|
+
showExport: false,
|
|
91
|
+
actions: [],
|
|
92
|
+
});
|
|
93
|
+
const instance = new GridController(grid);
|
|
94
|
+
|
|
95
|
+
expect(instance.showActionsButton).toBeFalsy();
|
|
96
|
+
expect(instance.showExportButton).toBeFalsy();
|
|
97
|
+
expect(instance.showSearchInput).toBeFalsy();
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('should verify if showActionAndExportButton is visibility', () => {
|
|
101
|
+
const grid = new TekGrid({
|
|
102
|
+
name: 'Grid',
|
|
103
|
+
component: 'TekGrid',
|
|
104
|
+
addButton: false,
|
|
105
|
+
deleteButton: 'none',
|
|
106
|
+
filterButton: false,
|
|
107
|
+
columnsButton: true,
|
|
108
|
+
showReload: false,
|
|
109
|
+
showLayoutOptions: true,
|
|
110
|
+
showReloadButton: true,
|
|
111
|
+
showSearch: false,
|
|
112
|
+
showExport: false,
|
|
113
|
+
actions: [],
|
|
114
|
+
});
|
|
115
|
+
const instance = new GridController(grid);
|
|
116
|
+
|
|
117
|
+
expect(instance.showActionAndExportButton).toBeFalsy();
|
|
118
|
+
expect(instance.showActionsButton).toBeFalsy();
|
|
119
|
+
expect(instance.showSearchInput).toBeFalsy();
|
|
120
|
+
expect(instance.showExportButton).toBeFalsy();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('should verify if showDivider2 is visibility', () => {
|
|
124
|
+
const grid = new TekGrid({
|
|
125
|
+
name: 'Grid',
|
|
126
|
+
component: 'TekGrid',
|
|
127
|
+
addButton: false,
|
|
128
|
+
deleteButton: 'none',
|
|
129
|
+
filterButton: false,
|
|
130
|
+
columnsButton: false,
|
|
131
|
+
showReload: true,
|
|
132
|
+
showLayoutOptions: false,
|
|
133
|
+
showSearch: false,
|
|
134
|
+
showExport: false,
|
|
135
|
+
actions: [],
|
|
136
|
+
});
|
|
137
|
+
const instance = new GridController(grid);
|
|
138
|
+
|
|
139
|
+
expect(instance.showActionsButton).toBeFalsy();
|
|
140
|
+
expect(instance.showSearchInput).toBeFalsy();
|
|
141
|
+
expect(instance.showColumnsButton).toBeFalsy();
|
|
142
|
+
expect(instance.showExportButton).toBeFalsy();
|
|
143
|
+
expect(instance.showReloadButton).toBeTruthy();
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('should verify if showDivider1 is visibility', () => {
|
|
147
|
+
const grid = new TekGrid({
|
|
148
|
+
name: 'Grid',
|
|
149
|
+
component: 'TekGrid',
|
|
150
|
+
addButton: true,
|
|
151
|
+
deleteButton: 'selection',
|
|
152
|
+
filterButton: false,
|
|
153
|
+
columnsButton: false,
|
|
154
|
+
showReload: false,
|
|
155
|
+
showLayoutOptions: false,
|
|
156
|
+
showSearch: false,
|
|
157
|
+
showExport: false,
|
|
158
|
+
actions: [],
|
|
159
|
+
});
|
|
160
|
+
const instance = new GridController(grid);
|
|
161
|
+
|
|
162
|
+
expect(instance.showActionsButton).toBeFalsy();
|
|
163
|
+
expect(instance.showSearchInput).toBeFalsy();
|
|
164
|
+
expect(instance.showColumnsButton).toBeFalsy();
|
|
165
|
+
expect(instance.showExportButton).toBeFalsy();
|
|
166
|
+
expect(instance.showReloadButton).toBeFalsy();
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
describe('showAddButton', () => {
|
|
170
|
+
it('should return true when addButton is true, not editing, and toolbar is open', () => {
|
|
171
|
+
const grid = new TekGrid({
|
|
172
|
+
name: 'Grid', component: 'TekGrid', addButton: true, editing: false,
|
|
173
|
+
});
|
|
174
|
+
const instance = new GridController(grid);
|
|
175
|
+
instance.openToolbar = true;
|
|
176
|
+
expect(instance.showAddButton).toBe(true);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('should return false when grid is in editing mode', () => {
|
|
180
|
+
const grid = new TekGrid({
|
|
181
|
+
name: 'Grid', component: 'TekGrid', addButton: true, editing: true,
|
|
182
|
+
});
|
|
183
|
+
const instance = new GridController(grid);
|
|
184
|
+
expect(instance.showAddButton).toBe(true);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it('should return false when toolbar is closed', () => {
|
|
188
|
+
const grid = new TekGrid({
|
|
189
|
+
name: 'Grid', component: 'TekGrid', addButton: true, editing: false,
|
|
190
|
+
});
|
|
191
|
+
const instance = new GridController(grid);
|
|
192
|
+
instance.openToolbar = false;
|
|
193
|
+
expect(instance.showAddButton).toBe(false);
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
describe('disableDeleteButton', () => {
|
|
198
|
+
it('should be disabled if selectAllPages is true, allSelected is true, and all items are exceptions', () => {
|
|
199
|
+
const grid = new TekGrid({
|
|
200
|
+
name: 'Grid', component: 'TekGrid', deleteButton: 'selection', selectAllPages: true,
|
|
201
|
+
});
|
|
202
|
+
grid.datasource.total = 3;
|
|
203
|
+
grid.selectionState = { allSelected: true, except: [{ id: 1 }, { id: 2 }, { id: 3 }] };
|
|
204
|
+
const instance = new GridController(grid);
|
|
205
|
+
expect(instance.disableDeleteButton).toBe(true);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('should be disabled if selectAllPages is true, allSelected is false, and no items are exceptions', () => {
|
|
209
|
+
const grid = new TekGrid({
|
|
210
|
+
name: 'Grid', component: 'TekGrid', deleteButton: 'selection', selectAllPages: true,
|
|
211
|
+
});
|
|
212
|
+
grid.selectionState = { allSelected: false, except: [] };
|
|
213
|
+
const instance = new GridController(grid);
|
|
214
|
+
expect(instance.disableDeleteButton).toBe(true);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it('should be enabled if selectAllPages is true and there is a valid selection', () => {
|
|
218
|
+
const grid = new TekGrid({
|
|
219
|
+
name: 'Grid', component: 'TekGrid', deleteButton: 'selection', selectAllPages: true,
|
|
220
|
+
});
|
|
221
|
+
grid.datasource.total = 5;
|
|
222
|
+
grid.selectionState = { allSelected: true, except: [{ id: 1 }] };
|
|
223
|
+
const instance = new GridController(grid);
|
|
224
|
+
expect(instance.disableDeleteButton).toBe(false);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it('should not be disabled when deleteButton is "none"', () => {
|
|
228
|
+
const grid = new TekGrid({ name: 'Grid', component: 'TekGrid', deleteButton: 'none' }); //
|
|
229
|
+
const instance = new GridController(grid);
|
|
230
|
+
expect(instance.disableDeleteButton).toBe(false);
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
describe('showEditButtons', () => {
|
|
235
|
+
it('deve retornar true quando o grid está em modo de edição e a propriedade showEditButtons é true', () => {
|
|
236
|
+
const grid = new TekGrid({
|
|
237
|
+
name: 'Grid',
|
|
238
|
+
component: 'TekGrid',
|
|
239
|
+
});
|
|
240
|
+
grid.editing = true;
|
|
241
|
+
const instance = new GridController(grid);
|
|
242
|
+
expect(instance.showEditButtons).toBe(true);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it('deve retornar false quando o grid não está em modo de edição', () => {
|
|
246
|
+
const grid = new TekGrid({
|
|
247
|
+
name: 'Grid',
|
|
248
|
+
component: 'TekGrid',
|
|
249
|
+
editing: false,
|
|
250
|
+
showEditButtons: true,
|
|
251
|
+
});
|
|
252
|
+
const instance = new GridController(grid);
|
|
253
|
+
expect(instance.showEditButtons).toBe(false);
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
it('deve retornar false quando a propriedade showEditButtons do grid é false', () => {
|
|
257
|
+
const grid = new TekGrid({
|
|
258
|
+
name: 'Grid',
|
|
259
|
+
component: 'TekGrid',
|
|
260
|
+
editing: true,
|
|
261
|
+
showEditButtons: false,
|
|
262
|
+
});
|
|
263
|
+
const instance = new GridController(grid);
|
|
264
|
+
expect(instance.showEditButtons).toBe(false);
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
});
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import { ReportFilter } from '../../../../src/utils';
|
|
2
|
-
|
|
3
|
-
describe('ReportFilter', () => {
|
|
4
|
-
describe('constructor()', () => {
|
|
5
|
-
it('should create a ReportFilter with defined values', () => {
|
|
6
|
-
const filter = {
|
|
7
|
-
name: [
|
|
8
|
-
{
|
|
9
|
-
value: 'Luiz',
|
|
10
|
-
relation: 'AND',
|
|
11
|
-
operation: 'CONTAINS',
|
|
12
|
-
},
|
|
13
|
-
],
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const instance = new ReportFilter(filter);
|
|
17
|
-
|
|
18
|
-
expect(instance.filter).toEqual(filter);
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
describe('build', () => {
|
|
23
|
-
it('should build the filter in ZhReports format', () => {
|
|
24
|
-
const filter = {
|
|
25
|
-
name: [
|
|
26
|
-
{
|
|
27
|
-
value: 'Luiz',
|
|
28
|
-
relation: 'AND',
|
|
29
|
-
operation: 'CONTAINS',
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
salary: [
|
|
33
|
-
{
|
|
34
|
-
value: '100',
|
|
35
|
-
relation: 'AND',
|
|
36
|
-
operation: 'GREATER_THAN',
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
value: '200',
|
|
40
|
-
relation: 'AND',
|
|
41
|
-
operation: 'LESS_THAN',
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
value: '500',
|
|
45
|
-
relation: 'OR',
|
|
46
|
-
operation: 'EQUALS',
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
};
|
|
50
|
-
const instance = new ReportFilter(filter);
|
|
51
|
-
|
|
52
|
-
const newFilter = instance.build();
|
|
53
|
-
|
|
54
|
-
expect(newFilter).toEqual([
|
|
55
|
-
{
|
|
56
|
-
label: 'name',
|
|
57
|
-
value: 'contains Luiz',
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
label: 'salary',
|
|
61
|
-
value: 'is greater than 100 and is less than 200 or is equal to 500',
|
|
62
|
-
},
|
|
63
|
-
]);
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
});
|
|
1
|
+
import { ReportFilter } from '../../../../src/utils';
|
|
2
|
+
|
|
3
|
+
describe('ReportFilter', () => {
|
|
4
|
+
describe('constructor()', () => {
|
|
5
|
+
it('should create a ReportFilter with defined values', () => {
|
|
6
|
+
const filter = {
|
|
7
|
+
name: [
|
|
8
|
+
{
|
|
9
|
+
value: 'Luiz',
|
|
10
|
+
relation: 'AND',
|
|
11
|
+
operation: 'CONTAINS',
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const instance = new ReportFilter(filter);
|
|
17
|
+
|
|
18
|
+
expect(instance.filter).toEqual(filter);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe('build', () => {
|
|
23
|
+
it('should build the filter in ZhReports format', () => {
|
|
24
|
+
const filter = {
|
|
25
|
+
name: [
|
|
26
|
+
{
|
|
27
|
+
value: 'Luiz',
|
|
28
|
+
relation: 'AND',
|
|
29
|
+
operation: 'CONTAINS',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
salary: [
|
|
33
|
+
{
|
|
34
|
+
value: '100',
|
|
35
|
+
relation: 'AND',
|
|
36
|
+
operation: 'GREATER_THAN',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
value: '200',
|
|
40
|
+
relation: 'AND',
|
|
41
|
+
operation: 'LESS_THAN',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
value: '500',
|
|
45
|
+
relation: 'OR',
|
|
46
|
+
operation: 'EQUALS',
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
};
|
|
50
|
+
const instance = new ReportFilter(filter);
|
|
51
|
+
|
|
52
|
+
const newFilter = instance.build();
|
|
53
|
+
|
|
54
|
+
expect(newFilter).toEqual([
|
|
55
|
+
{
|
|
56
|
+
label: 'name',
|
|
57
|
+
value: 'contains Luiz',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
label: 'salary',
|
|
61
|
+
value: 'is greater than 100 and is less than 200 or is equal to 500',
|
|
62
|
+
},
|
|
63
|
+
]);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
});
|