@zeedhi/teknisa-components-common 1.107.2 → 1.108.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.
Files changed (77) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +7 -7
  3. package/coverage/clover.xml +772 -692
  4. package/coverage/coverage-final.json +47 -47
  5. package/coverage/lcov-report/index.html +15 -15
  6. package/coverage/lcov-report/tests/__helpers__/component-event-helper.ts.html +2 -2
  7. package/coverage/lcov-report/tests/__helpers__/flush-promises-helper.ts.html +2 -2
  8. package/coverage/lcov-report/tests/__helpers__/get-child-helper.ts.html +7 -7
  9. package/coverage/lcov-report/tests/__helpers__/index.html +1 -1
  10. package/coverage/lcov-report/tests/__helpers__/index.ts.html +1 -1
  11. package/coverage/lcov-report/tests/__helpers__/mock-created-helper.ts.html +1 -1
  12. package/coverage/lcov.info +1459 -1275
  13. package/dist/tek-components-common.esm.js +375 -252
  14. package/dist/tek-components-common.umd.js +375 -252
  15. package/jest.config.js +1 -1
  16. package/package.json +2 -2
  17. package/tests/__helpers__/component-event-helper.ts +5 -5
  18. package/tests/__helpers__/flush-promises-helper.ts +3 -3
  19. package/tests/__helpers__/get-child-helper.ts +27 -27
  20. package/tests/__helpers__/index.ts +3 -3
  21. package/tests/__helpers__/mock-created-helper.ts +12 -12
  22. package/tests/__mocks__/@zeedhi/core/i18n.js +74 -74
  23. package/tests/__mocks__/@zeedhi/core.js +4 -4
  24. package/tests/unit/components/crud/crud-add-button.spec.ts +56 -56
  25. package/tests/unit/components/crud/crud-button.spec.ts +94 -94
  26. package/tests/unit/components/crud/crud-cancel-button.spec.ts +91 -91
  27. package/tests/unit/components/crud/crud-delete-button.spec.ts +122 -122
  28. package/tests/unit/components/crud/crud-form.spec.ts +165 -165
  29. package/tests/unit/components/crud/crud-save-button.spec.ts +118 -118
  30. package/tests/unit/components/tek-breadcrumb-header/tek-breadcrumb-header.spec.ts +42 -42
  31. package/tests/unit/components/tek-card-title/CardTitle.spec.ts +34 -34
  32. package/tests/unit/components/tek-datasource/memory-datasource.spec.ts +470 -470
  33. package/tests/unit/components/tek-datasource/rest-datasource.spec.ts +364 -364
  34. package/tests/unit/components/tek-drag-grid/tek-drag-grid.spec.ts +112 -112
  35. package/tests/unit/components/tek-grid/filter-helper.spec.ts +148 -148
  36. package/tests/unit/components/tek-grid/grid-column.spec.ts +270 -270
  37. package/tests/unit/components/tek-grid/grid-columns-button.spec.ts +195 -195
  38. package/tests/unit/components/tek-grid/grid-filter-button.spec.ts +967 -967
  39. package/tests/unit/components/tek-grid/grid.spec.ts +3340 -3116
  40. package/tests/unit/components/tek-grid/layout_options.spec.ts +980 -980
  41. package/tests/unit/components/tek-image/Image.spec.ts +67 -67
  42. package/tests/unit/components/tek-iterable-carousel/iterable-carousel.spec.ts +37 -37
  43. package/tests/unit/components/tek-iterable-component-render/iterable-component-render.spec.ts +200 -200
  44. package/tests/unit/components/tek-loading/Loading.spec.ts +30 -30
  45. package/tests/unit/components/tek-notifications/notifications.spec.ts +201 -201
  46. package/tests/unit/components/tek-product-card/product-card.spec.ts +61 -61
  47. package/tests/unit/components/tek-user-info/TekUserInfoContoller.spec.ts +220 -220
  48. package/tests/unit/components/tek-user-info/tek-user-info-list.spec.ts +86 -86
  49. package/tests/unit/components/tek-user-info/tek-user-info.spec.ts +430 -430
  50. package/tests/unit/components/tree-grid/tree-grid.spec.ts +776 -776
  51. package/tests/unit/utils/grid-base/delete-rows-error.spec.ts +24 -0
  52. package/tests/unit/utils/grid-base/export-options/button-option.spec.ts +44 -44
  53. package/tests/unit/utils/grid-base/export-options/multi-option.spec.ts +135 -135
  54. package/tests/unit/utils/grid-base/grid-controller.spec.ts +267 -174
  55. package/tests/unit/utils/report-filter/report-filter.spec.ts +66 -66
  56. package/tsconfig.eslint.json +8 -8
  57. package/types/components/tek-datasource/memory-datasource.d.ts +2 -4
  58. package/types/components/tek-datasource/rest-datasource.d.ts +6 -3
  59. package/types/components/tek-grid/grid.d.ts +50 -6
  60. package/types/components/tek-grid/interfaces.d.ts +5 -3
  61. package/types/components/tek-tree-grid/tree-grid.d.ts +5 -1
  62. package/types/utils/grid-base/grid-base.d.ts +12 -229
  63. package/types/utils/grid-base/grid-controller.d.ts +1 -3
  64. package/types/components/tek-ag-grid/default-icons.d.ts +0 -53
  65. package/types/components/tek-ag-grid/interfaces.d.ts +0 -9
  66. package/types/components/tek-ag-grid/tek-ag-grid.d.ts +0 -35
  67. package/types/components/tek-datasource/datasource.d.ts +0 -94
  68. package/types/components/tek-grid/default-icons.d.ts +0 -53
  69. package/types/components/tek-grid/filter-dynamic-values.d.ts +0 -9
  70. package/types/components/tek-grid/grid-controller.d.ts +0 -19
  71. package/types/components/tek-grid/grid_column.d.ts +0 -14
  72. package/types/components/tek-grid/grid_controller.d.ts +0 -15
  73. package/types/components/tek-grid/tek-grid.d.ts +0 -35
  74. package/types/components/tek-login/interfaces.d.ts +0 -3
  75. package/types/components/tek-login/login-children.d.ts +0 -3
  76. package/types/components/tek-login/login.d.ts +0 -58
  77. package/types/components/tek-login/login_children.d.ts +0 -3
@@ -1,174 +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 = true;
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.showDivider2).toBeTruthy();
43
- expect(instance.showDivider3).toBeTruthy();
44
- expect(instance.showColumnsButton).toBeTruthy();
45
- expect(instance.columnsButtonIgnore).toEqual([]);
46
- expect(instance.showLayoutOptionsButton).toBeTruthy();
47
- expect(instance.showReloadButton).toBeTruthy();
48
- expect(instance.showDivider1).toBeTruthy();
49
- expect(instance.isEditing).toBeTruthy();
50
- expect(instance.isNotEditing).toBeFalsy();
51
- expect(instance.showEditButtons).toBeFalsy();
52
- expect(instance.disableDeleteButton).toBeTruthy();
53
- expect(instance.showModalFilterProps).toEqual(
54
- expect.objectContaining({
55
- height: 'auto',
56
- persistent: true,
57
- }),
58
- );
59
-
60
- grid.datasource.currentRow = { id: '1' };
61
- expect(instance.disableDeleteButton).toBeFalsy();
62
- grid.showExport = false;
63
- grid.showLayoutOptions = false;
64
- grid.showReload = false;
65
- grid.columnsButton = false;
66
- grid.actions = [];
67
- grid.deleteButton = 'selection';
68
- grid.selectedRows = [{ id: '1' }];
69
- expect(instance.disableDeleteButton).toBeFalsy();
70
- expect(instance.showExportButton).toBeFalsy();
71
- expect(instance.showActionAndExportButton).toBeFalsy();
72
- expect(instance.showLayoutOptionsButton).toBeFalsy();
73
-
74
- instance.showToolbar = false;
75
- expect(instance.toolbarStyle).toBe('is-rotated');
76
- expect(instance.tooltipName).toBe('TEKGRID_SHOW');
77
- expect(instance.showToolbar).toBeFalsy();
78
- });
79
-
80
- it('should verify if showDivider3 is visibility', () => {
81
- const grid = new TekGrid({
82
- name: 'Grid',
83
- component: 'TekGrid',
84
- addButton: false,
85
- deleteButton: 'none',
86
- filterButton: false,
87
- columnsButton: false,
88
- showReload: false,
89
- showLayoutOptions: false,
90
- showReloadButton: true,
91
- showSearch: false,
92
- showExport: false,
93
- actions: [],
94
- });
95
- const instance = new GridController(grid);
96
-
97
- expect(instance.showDivider3).toBeFalsy();
98
- expect(instance.showActionsButton).toBeFalsy();
99
- expect(instance.showExportButton).toBeFalsy();
100
- expect(instance.showSearchInput).toBeFalsy();
101
- });
102
-
103
- it('should verify if showActionAndExportButton is visibility', () => {
104
- const grid = new TekGrid({
105
- name: 'Grid',
106
- component: 'TekGrid',
107
- addButton: false,
108
- deleteButton: 'none',
109
- filterButton: false,
110
- columnsButton: true,
111
- showReload: false,
112
- showLayoutOptions: true,
113
- showReloadButton: true,
114
- showSearch: false,
115
- showExport: false,
116
- actions: [],
117
- });
118
- const instance = new GridController(grid);
119
-
120
- expect(instance.showActionAndExportButton).toBeFalsy();
121
- expect(instance.showActionsButton).toBeFalsy();
122
- expect(instance.showSearchInput).toBeFalsy();
123
- expect(instance.showExportButton).toBeFalsy();
124
- });
125
-
126
- it('should verify if showDivider2 is visibility', () => {
127
- const grid = new TekGrid({
128
- name: 'Grid',
129
- component: 'TekGrid',
130
- addButton: false,
131
- deleteButton: 'none',
132
- filterButton: false,
133
- columnsButton: false,
134
- showReload: true,
135
- showLayoutOptions: false,
136
- showSearch: false,
137
- showExport: false,
138
- actions: [],
139
- });
140
- const instance = new GridController(grid);
141
-
142
- expect(instance.showDivider2).toBeFalsy();
143
- expect(instance.showActionsButton).toBeFalsy();
144
- expect(instance.showSearchInput).toBeFalsy();
145
- expect(instance.showColumnsButton).toBeFalsy();
146
- expect(instance.showExportButton).toBeFalsy();
147
- expect(instance.showReloadButton).toBeTruthy();
148
- });
149
-
150
- it('should verify if showDivider1 is visibility', () => {
151
- const grid = new TekGrid({
152
- name: 'Grid',
153
- component: 'TekGrid',
154
- addButton: true,
155
- deleteButton: 'selection',
156
- filterButton: false,
157
- columnsButton: false,
158
- showReload: false,
159
- showLayoutOptions: false,
160
- showSearch: false,
161
- showExport: false,
162
- actions: [],
163
- });
164
- const instance = new GridController(grid);
165
-
166
- expect(instance.showDivider1).toBeFalsy();
167
- expect(instance.showActionsButton).toBeFalsy();
168
- expect(instance.showSearchInput).toBeFalsy();
169
- expect(instance.showColumnsButton).toBeFalsy();
170
- expect(instance.showExportButton).toBeFalsy();
171
- expect(instance.showReloadButton).toBeFalsy();
172
- });
173
- });
174
- });
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
+ });
@@ -1,9 +1,9 @@
1
- {
2
- // extend your base config so you don't have to redefine your compilerOptions
3
- "extends": "./tsconfig.json",
4
- "include": [
5
- "./src/**/*.ts",
6
- "./tests/**/*.ts",
7
- ],
8
- "exclude": ["node_modules"]
1
+ {
2
+ // extend your base config so you don't have to redefine your compilerOptions
3
+ "extends": "./tsconfig.json",
4
+ "include": [
5
+ "./src/**/*.ts",
6
+ "./tests/**/*.ts",
7
+ ],
8
+ "exclude": ["node_modules"]
9
9
  }
@@ -78,17 +78,15 @@ export declare class TekMemoryDatasource extends MemoryDatasource implements ITe
78
78
  currentRow?: IDictionary<any> | undefined;
79
79
  data?: IDictionary<any>[] | undefined;
80
80
  filter?: IDictionary<any> | undefined;
81
- limit?: string | number | undefined; /**
82
- * Dynamic Filter Operations
83
- */
81
+ limit?: string | number | undefined;
84
82
  loadAll?: boolean | undefined;
85
83
  loading?: boolean | undefined;
86
84
  order?: string[] | undefined;
87
85
  page?: string | number | undefined;
86
+ search?: string | undefined;
88
87
  /**
89
88
  * Dynamic Filter Relations
90
89
  */
91
- search?: string | undefined;
92
90
  searchIn?: string[] | undefined;
93
91
  searchInParams?: IDictionary<any> | undefined;
94
92
  uniqueKey?: string | undefined;
@@ -82,19 +82,22 @@ export declare class TekRestDatasource extends RestDatasource implements ITekRes
82
82
  find?: IDictionary<any> | undefined;
83
83
  localSearch?: boolean | undefined;
84
84
  currentRow?: IDictionary<any> | undefined;
85
+ /** Search Join data */
85
86
  data?: IDictionary<any>[] | undefined;
86
87
  filter?: IDictionary<any> | undefined;
87
- limit?: string | number | undefined;
88
+ limit?: string | number | undefined; /**
89
+ * Dynamic Filter Operations
90
+ */
88
91
  loadAll?: boolean | undefined;
89
92
  loading?: boolean | undefined;
90
93
  order?: string[] | undefined;
91
94
  page?: string | number | undefined;
92
95
  search?: string | undefined;
93
96
  searchIn?: string[] | undefined;
94
- searchInParams?: IDictionary<any> | undefined; /**
97
+ searchInParams?: IDictionary<any> | undefined;
98
+ uniqueKey?: string | undefined; /**
95
99
  * Dynamic Filter applied flag
96
100
  */
97
- uniqueKey?: string | undefined;
98
101
  watchUrl?: boolean | undefined;
99
102
  events?: import("@zeedhi/core").IDatasourceEvents<import("@zeedhi/core").IEventParam<any>> | undefined;
100
103
  };