@zeedhi/teknisa-components-common 3.0.4 → 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.
Files changed (134) hide show
  1. package/dist/teknisa-components-common.es.js +3536 -0
  2. package/dist/types/components/index.d.ts +2 -0
  3. package/dist/types/components/tek-breadcrumb-header/breadcrumb-header.d.ts +2 -2
  4. package/dist/types/components/tek-breadcrumb-header/interfaces.d.ts +1 -1
  5. package/dist/types/components/tek-datasource/tek-memory-datasource.d.ts +1 -21
  6. package/dist/types/components/tek-datasource/tek-rest-datasource.d.ts +6 -30
  7. package/dist/types/components/tek-grid/filter-helper.d.ts +2 -2
  8. package/dist/types/components/tek-grid/grid-filter-button.d.ts +1 -0
  9. package/dist/types/components/tek-grid/grouped-data-manager.d.ts +8 -1
  10. package/dist/types/components/tek-grid/grouped-data-navigator.d.ts +12 -0
  11. package/dist/types/components/tek-grid/index.d.ts +1 -1
  12. package/dist/types/components/tek-grid/interfaces.d.ts +8 -1
  13. package/dist/types/components/tek-grid/tek-grid-controller.d.ts +19 -17
  14. package/dist/types/components/tek-grid/tek-grid-data-editor.d.ts +11 -0
  15. package/dist/types/components/tek-grid/tek-grid-toolbar-provider/export-options/multi-option.d.ts +1 -1
  16. package/dist/types/components/tek-grid/tek-grid-toolbar-provider/tek-grid-toolbar-provider.d.ts +8 -1
  17. package/dist/types/components/tek-grid/tek-grid.d.ts +24 -6
  18. package/dist/types/components/tek-loading/interfaces.d.ts +6 -0
  19. package/dist/types/components/tek-loading/loading.d.ts +16 -0
  20. package/dist/types/components/tek-user-info/TekUserInfoController.d.ts +4 -4
  21. package/dist/types/utils/extract-properties/extract-properties.d.ts +1 -0
  22. package/dist/types/utils/index.d.ts +2 -0
  23. package/dist/types/utils/report-filter/report-filter.d.ts +12 -0
  24. package/package.json +32 -12
  25. package/coverage/clover.xml +0 -6
  26. package/coverage/coverage-final.json +0 -1
  27. package/coverage/lcov-report/base.css +0 -224
  28. package/coverage/lcov-report/block-navigation.js +0 -87
  29. package/coverage/lcov-report/favicon.png +0 -0
  30. package/coverage/lcov-report/index.html +0 -101
  31. package/coverage/lcov-report/prettify.css +0 -1
  32. package/coverage/lcov-report/prettify.js +0 -2
  33. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  34. package/coverage/lcov-report/sorter.js +0 -210
  35. package/coverage/lcov.info +0 -0
  36. package/dist/teknisa-components-common.js +0 -3802
  37. package/dist/teknisa-components-common.min.js +0 -3802
  38. package/dist/types/components/tek-grid/grouped-view-navigator.d.ts +0 -14
  39. package/dist/types/error/delete-rows-error.d.ts +0 -6
  40. package/environments.json +0 -14
  41. package/jest.config.js +0 -1
  42. package/src/components/index.ts +0 -101
  43. package/src/components/tek-breadcrumb-header/breadcrumb-header.ts +0 -29
  44. package/src/components/tek-breadcrumb-header/interfaces.ts +0 -7
  45. package/src/components/tek-datasource/index.ts +0 -3
  46. package/src/components/tek-datasource/interfaces.ts +0 -36
  47. package/src/components/tek-datasource/tek-memory-datasource.ts +0 -314
  48. package/src/components/tek-datasource/tek-rest-datasource.ts +0 -224
  49. package/src/components/tek-grid/columns-searcher.ts +0 -22
  50. package/src/components/tek-grid/dynamic-filter-datasource-factory.ts +0 -20
  51. package/src/components/tek-grid/filter-helper.ts +0 -20
  52. package/src/components/tek-grid/grid-filter-button.ts +0 -419
  53. package/src/components/tek-grid/grouped-data-manager.ts +0 -448
  54. package/src/components/tek-grid/grouped-data-selector.ts +0 -40
  55. package/src/components/tek-grid/grouped-view-navigator.ts +0 -84
  56. package/src/components/tek-grid/index.ts +0 -18
  57. package/src/components/tek-grid/interfaces.ts +0 -329
  58. package/src/components/tek-grid/keymap-grouped.ts +0 -20
  59. package/src/components/tek-grid/layout-options.ts +0 -248
  60. package/src/components/tek-grid/tek-grid-column.ts +0 -193
  61. package/src/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button-controller.ts +0 -28
  62. package/src/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button.ts +0 -38
  63. package/src/components/tek-grid/tek-grid-controller.ts +0 -140
  64. package/src/components/tek-grid/tek-grid-events.ts +0 -105
  65. package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/button-option.ts +0 -26
  66. package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/index.ts +0 -3
  67. package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/interfaces.ts +0 -6
  68. package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/multi-option.ts +0 -85
  69. package/src/components/tek-grid/tek-grid-toolbar-provider/index.ts +0 -2
  70. package/src/components/tek-grid/tek-grid-toolbar-provider/tek-grid-toolbar-provider.ts +0 -365
  71. package/src/components/tek-grid/tek-grid.ts +0 -1118
  72. package/src/components/tek-user-info/TekUserInfoController.ts +0 -87
  73. package/src/components/tek-user-info/interfaces.ts +0 -21
  74. package/src/components/tek-user-info/tek-user-info-list.ts +0 -64
  75. package/src/components/tek-user-info/tek-user-info.ts +0 -337
  76. package/src/error/tek-grid-delete-rows-error.ts +0 -15
  77. package/src/error/teknisa-common-error.ts +0 -8
  78. package/src/utils/config/config.ts +0 -8
  79. package/src/utils/index.ts +0 -3
  80. package/src/utils/is-filled-object/is-filled-object.ts +0 -5
  81. package/src/utils/is-nil.ts +0 -3
  82. package/tests/__helpers__/component-event-helper.ts +0 -5
  83. package/tests/__helpers__/flush-promises-helper.ts +0 -3
  84. package/tests/__helpers__/get-child-helper.ts +0 -27
  85. package/tests/__helpers__/index.ts +0 -3
  86. package/tests/__helpers__/mock-created-helper.ts +0 -12
  87. package/tests/__mocks__/@zeedhi/core/i18n.js +0 -75
  88. package/tests/__mocks__/@zeedhi/core.js +0 -5
  89. package/tests/unit/components/crud/crud-add-button.spec.ts +0 -56
  90. package/tests/unit/components/crud/crud-button.spec.ts +0 -94
  91. package/tests/unit/components/crud/crud-cancel-button.spec.ts +0 -91
  92. package/tests/unit/components/crud/crud-delete-button.spec.ts +0 -122
  93. package/tests/unit/components/crud/crud-form.spec.ts +0 -165
  94. package/tests/unit/components/crud/crud-save-button.spec.ts +0 -118
  95. package/tests/unit/components/tek-breadcrumb-header/tek-breadcrumb-header.spec.ts +0 -42
  96. package/tests/unit/components/tek-card-title/CardTitle.spec.ts +0 -34
  97. package/tests/unit/components/tek-datasource/memory-datasource.spec.ts +0 -460
  98. package/tests/unit/components/tek-datasource/rest-datasource.spec.ts +0 -362
  99. package/tests/unit/components/tek-drag-grid/tek-drag-grid.spec.ts +0 -112
  100. package/tests/unit/components/tek-grid/button-option.spec.ts +0 -49
  101. package/tests/unit/components/tek-grid/columns-searcher.spec.ts +0 -112
  102. package/tests/unit/components/tek-grid/dynamic-filter-datasource-factory.spec.ts +0 -90
  103. package/tests/unit/components/tek-grid/filter-helper.spec.ts +0 -52
  104. package/tests/unit/components/tek-grid/grid-filter-button.spec.ts +0 -842
  105. package/tests/unit/components/tek-grid/grouped-data-manager.spec.ts +0 -593
  106. package/tests/unit/components/tek-grid/grouped-data-selector.spec.ts +0 -136
  107. package/tests/unit/components/tek-grid/grouped-view-navigator.spec.ts +0 -244
  108. package/tests/unit/components/tek-grid/keymap-grouped.spec.ts +0 -20
  109. package/tests/unit/components/tek-grid/layout-options.spec.ts +0 -1020
  110. package/tests/unit/components/tek-grid/multi-option.spec.ts +0 -139
  111. package/tests/unit/components/tek-grid/tek-grid-column.spec.ts +0 -312
  112. package/tests/unit/components/tek-grid/tek-grid-columns-button.spec.ts +0 -228
  113. package/tests/unit/components/tek-grid/tek-grid-controller.spec.ts +0 -253
  114. package/tests/unit/components/tek-grid/tek-grid-events.spec.ts +0 -186
  115. package/tests/unit/components/tek-grid/tek-grid-toolbar-provider.spec.ts +0 -34
  116. package/tests/unit/components/tek-grid/tek-grid.spec.ts +0 -895
  117. package/tests/unit/components/tek-grid/tek-memory-datasource.spec.ts +0 -482
  118. package/tests/unit/components/tek-grid/tek-rest-datasource.spec.ts +0 -422
  119. package/tests/unit/components/tek-image/Image.spec.ts +0 -67
  120. package/tests/unit/components/tek-iterable-carousel/iterable-carousel.spec.ts +0 -37
  121. package/tests/unit/components/tek-iterable-component-render/iterable-component-render.spec.ts +0 -200
  122. package/tests/unit/components/tek-loading/Loading.spec.ts +0 -30
  123. package/tests/unit/components/tek-notifications/notifications.spec.ts +0 -201
  124. package/tests/unit/components/tek-product-card/product-card.spec.ts +0 -61
  125. package/tests/unit/components/tek-user-info/TekUserInfoContoller.spec.ts +0 -220
  126. package/tests/unit/components/tek-user-info/tek-user-info-list.spec.ts +0 -86
  127. package/tests/unit/components/tek-user-info/tek-user-info.spec.ts +0 -430
  128. package/tests/unit/components/tree-grid/tree-grid.spec.ts +0 -776
  129. package/tests/unit/utils/grid-base/export-options/button-option.spec.ts +0 -44
  130. package/tests/unit/utils/grid-base/export-options/multi-option.spec.ts +0 -135
  131. package/tests/unit/utils/grid-base/grid-controller.spec.ts +0 -174
  132. package/tests/unit/utils/report-filter/report-filter.spec.ts +0 -66
  133. package/tsconfig.build.json +0 -7
  134. package/tsconfig.eslint.json +0 -9
@@ -1,253 +0,0 @@
1
- import { Loader, SimpleControllerBuilder } from '@zeedhi/core';
2
- import {
3
- ITekGridProps,
4
- TekGrid, TekGridController,
5
- } from '../../../../src';
6
-
7
- const setupInstance = (props: Partial<ITekGridProps> = {}) => {
8
- const instance = new TekGrid({
9
- name: 'Grid',
10
- component: 'TekGrid',
11
- columns: [
12
- { name: 'first' },
13
- { name: 'second' },
14
- { name: 'third' },
15
- ],
16
- datasource: {
17
- limit: 2,
18
- page: 1,
19
- data: [
20
- { id: 1 },
21
- { id: 2 },
22
- { id: 3 },
23
- { id: 4 },
24
- { id: 5 },
25
- { id: 6 },
26
- { id: 7 },
27
- ],
28
- },
29
- ...props,
30
- });
31
- const elem = document.createElement('DIV');
32
- instance.onCreated();
33
- instance.onMounted(elem);
34
-
35
- return instance;
36
- };
37
-
38
- describe('GridController', () => {
39
- beforeAll(() => {
40
- Loader.setBuilder(new SimpleControllerBuilder());
41
- });
42
-
43
- describe('constructor()', () => {
44
- it('should create controller and get info from grid', () => {
45
- const grid = setupInstance({
46
- name: 'Grid',
47
- component: 'TekGrid',
48
- title: 'title',
49
- addButton: false,
50
- deleteButton: 'currentRow',
51
- filterButton: true,
52
- columnsButton: true,
53
- editing: true,
54
- showEditButtons: false,
55
- modalFilterProps: {
56
- name: 'name',
57
- height: 'auto',
58
- persistent: true,
59
- },
60
- showExport: true,
61
- showLayoutOptionsButton: true,
62
- showReloadButton: true,
63
- actions: [{ name: 'button', component: 'ZdButton' }],
64
- });
65
- grid.editing = true;
66
- const instance = new TekGridController(grid);
67
- expect(instance.gridTitle).toBe('title');
68
- expect(instance.showAddButton).toBeFalsy();
69
- expect(instance.showDeleteButton).toBeTruthy();
70
- expect(instance.showFilterButton).toBeTruthy();
71
- expect(instance.showActionsButton).toBeTruthy();
72
- expect(instance.showExportButton).toBeTruthy();
73
- expect(instance.showActionAndExportButton).toBeTruthy();
74
- expect(instance.showSearchInput).toBeTruthy();
75
- expect(instance.showToolbar).toBeTruthy();
76
- expect(instance.toolbarClass).toBe('');
77
- expect(instance.tooltipName).toBe('TEKGRID_HIDE');
78
- expect(instance.showDivider2).toBeTruthy();
79
- expect(instance.showDivider3).toBeTruthy();
80
- expect(instance.showColumnsButton).toBeTruthy();
81
- expect(instance.columnsButtonIgnore).toEqual([]);
82
- expect(instance.showLayoutOptionsButton).toBeTruthy();
83
- expect(instance.showReloadButton).toBeTruthy();
84
- expect(instance.showDivider1).toBeTruthy();
85
- expect(instance.isEditing).toBeTruthy();
86
- expect(instance.isNotEditing).toBeFalsy();
87
- expect(instance.showEditButtons).toBeFalsy();
88
- expect(instance.disableDeleteButton).toBeTruthy();
89
- expect(instance.showModalFilterProps).toEqual(
90
- expect.objectContaining({
91
- height: 'auto',
92
- persistent: true,
93
- }),
94
- );
95
-
96
- grid.datasource.currentRow = { id: '1' };
97
- expect(instance.disableDeleteButton).toBeFalsy();
98
- grid.showExport = false;
99
- grid.showLayoutOptions = false;
100
- grid.showReload = false;
101
- grid.columnsButton = false;
102
- grid.actions = [];
103
- grid.deleteButton = 'selection';
104
- grid.selectedRows = [{ id: '1' }];
105
- expect(instance.disableDeleteButton).toBeFalsy();
106
- expect(instance.showExportButton).toBeFalsy();
107
- expect(instance.showActionAndExportButton).toBeFalsy();
108
- expect(instance.showLayoutOptionsButton).toBeFalsy();
109
-
110
- instance.showToolbar = false;
111
- expect(instance.toolbarClass).toBe('is-rotated');
112
- expect(instance.tooltipName).toBe('TEKGRID_SHOW');
113
- expect(instance.showToolbar).toBeFalsy();
114
- });
115
-
116
- it('should verify if showDivider3 is visibility', () => {
117
- const grid = setupInstance({
118
- name: 'Grid',
119
- component: 'TekGrid',
120
- addButton: false,
121
- deleteButton: 'none',
122
- filterButton: false,
123
- columnsButton: false,
124
- showReload: false,
125
- showLayoutOptions: false,
126
- showReloadButton: true,
127
- showSearch: false,
128
- showExport: false,
129
- actions: [],
130
- });
131
- const instance = new TekGridController(grid);
132
-
133
- expect(instance.showDivider3).toBeFalsy();
134
- expect(instance.showActionsButton).toBeFalsy();
135
- expect(instance.showExportButton).toBeFalsy();
136
- expect(instance.showSearchInput).toBeFalsy();
137
- });
138
-
139
- it('should verify if showActionAndExportButton is visibility', () => {
140
- const grid = setupInstance({
141
- name: 'Grid',
142
- component: 'TekGrid',
143
- addButton: false,
144
- deleteButton: 'none',
145
- filterButton: false,
146
- columnsButton: true,
147
- showReload: false,
148
- showLayoutOptions: true,
149
- showReloadButton: true,
150
- showSearch: false,
151
- showExport: false,
152
- actions: [],
153
- });
154
- const instance = new TekGridController(grid);
155
-
156
- expect(instance.showActionAndExportButton).toBeFalsy();
157
- expect(instance.showActionsButton).toBeFalsy();
158
- expect(instance.showSearchInput).toBeFalsy();
159
- expect(instance.showExportButton).toBeFalsy();
160
- });
161
-
162
- it('should verify if showDivider2 is visibility', () => {
163
- const grid = setupInstance({
164
- name: 'Grid',
165
- component: 'TekGrid',
166
- addButton: false,
167
- deleteButton: 'none',
168
- filterButton: false,
169
- columnsButton: false,
170
- showReload: true,
171
- showLayoutOptions: false,
172
- showSearch: false,
173
- showExport: false,
174
- actions: [],
175
- });
176
- const instance = new TekGridController(grid);
177
-
178
- expect(instance.showDivider2).toBeFalsy();
179
- expect(instance.showActionsButton).toBeFalsy();
180
- expect(instance.showSearchInput).toBeFalsy();
181
- expect(instance.showColumnsButton).toBeFalsy();
182
- expect(instance.showExportButton).toBeFalsy();
183
- expect(instance.showReloadButton).toBeTruthy();
184
- });
185
-
186
- it('should verify if showDivider1 is visibility', () => {
187
- const grid = setupInstance({
188
- name: 'Grid',
189
- component: 'TekGrid',
190
- addButton: true,
191
- deleteButton: 'selection',
192
- filterButton: false,
193
- columnsButton: false,
194
- showReload: false,
195
- showLayoutOptions: false,
196
- showSearch: false,
197
- showExport: false,
198
- actions: [],
199
- });
200
- const instance = new TekGridController(grid);
201
-
202
- expect(instance.showDivider1).toBeFalsy();
203
- expect(instance.showActionsButton).toBeFalsy();
204
- expect(instance.showSearchInput).toBeFalsy();
205
- expect(instance.showColumnsButton).toBeFalsy();
206
- expect(instance.showExportButton).toBeFalsy();
207
- expect(instance.showReloadButton).toBeFalsy();
208
- });
209
- });
210
-
211
- describe('disableDeleteButton', () => {
212
- it('should return true when using selectAllPages and nothing is selected with except equal to 0', () => {
213
- const grid = {
214
- selectAllPages: true,
215
- deleteButton: 'selection',
216
- selectionState: { allSelected: false, except: [] },
217
- datasource: {
218
- total: 1,
219
- },
220
- } as any as TekGrid;
221
-
222
- const controller = new TekGridController(grid);
223
-
224
- expect(controller.disableDeleteButton).toBeTruthy();
225
- });
226
-
227
- it('should return true when using selectAllPages and nothing is selected', () => {
228
- const data = [{ id: '1' }];
229
- const grid = {
230
- selectAllPages: true,
231
- deleteButton: 'selection',
232
- selectionState: { allSelected: true, except: data },
233
- datasource: {
234
- total: 1,
235
- },
236
- } as any as TekGrid;
237
-
238
- const controller = new TekGridController(grid);
239
-
240
- expect(controller.disableDeleteButton).toBeTruthy();
241
- });
242
-
243
- it('should return false when deleteButton mode is none', () => {
244
- const grid = {
245
- deleteButton: 'none',
246
- } as any as TekGrid;
247
-
248
- const controller = new TekGridController(grid);
249
-
250
- expect(controller.disableDeleteButton).toBeFalsy();
251
- });
252
- });
253
- });
@@ -1,186 +0,0 @@
1
- import { ITekGrid, ITekGridSummary, TekGridColumn, TekGridEvents } from '../../../../src';
2
-
3
- describe('TekGridEvents', () => {
4
- let tekGridEvents: TekGridEvents;
5
- let mockTekGrid: jest.Mocked<ITekGrid>;
6
- const mockEvent = {} as Event;
7
- const mockElement = {} as HTMLElement;
8
- const mockRow = { id: 1, name: 'Test Row' };
9
- const mockGroupRow = { group: true, groupValue: 'Test Group' };
10
-
11
- beforeEach(() => {
12
- mockTekGrid = {
13
- datasource: { currentRow: null },
14
- callEvent: jest.fn(),
15
- } as unknown as jest.Mocked<ITekGrid>;
16
-
17
- tekGridEvents = new TekGridEvents(mockTekGrid);
18
- });
19
-
20
- describe('constructor', () => {
21
- it('should initialize with the provided tekGrid', () => {
22
- expect(tekGridEvents).toBeInstanceOf(TekGridEvents);
23
- // @ts-ignore - access protected property for testing
24
- expect(tekGridEvents.tekGrid).toBe(mockTekGrid);
25
- });
26
- });
27
-
28
- describe('calcSummary', () => {
29
- it('should call calcSummary event with correct parameters', () => {
30
- const mockColumn = { name: 'testColumn' } as TekGridColumn;
31
- const mockSummary: ITekGridSummary = { sum: 0, count: 0, avg: 0, min: 0, max: 0 };
32
- const mockRowWithValue = { testColumn: 100 };
33
-
34
- tekGridEvents.calcSummary(mockColumn, mockSummary, mockRowWithValue);
35
-
36
- expect(mockTekGrid.callEvent).toHaveBeenCalledWith('calcSummary', {
37
- component: mockTekGrid,
38
- column: mockColumn,
39
- columnName: 'testColumn',
40
- summary: mockSummary,
41
- row: mockRowWithValue,
42
- rowValue: 100,
43
- });
44
- });
45
- });
46
-
47
- describe('rowDoubleClick', () => {
48
- it('should set currentRow and dispatch event when not prevented', () => {
49
- tekGridEvents.rowDoubleClick(mockRow, mockEvent, mockElement);
50
-
51
- expect(mockTekGrid.datasource.currentRow).toBe(mockRow);
52
- expect(mockTekGrid.callEvent).toHaveBeenCalledWith('rowDoubleClick', {
53
- event: mockEvent,
54
- element: mockElement,
55
- row: mockRow,
56
- component: mockTekGrid,
57
- column: undefined,
58
- });
59
- });
60
-
61
- it('should not dispatch event when prevented', () => {
62
- // @ts-ignore - access protected property for testing
63
- tekGridEvents.preventRowDoubleClick = true;
64
- tekGridEvents.rowDoubleClick(mockRow, mockEvent, mockElement);
65
-
66
- expect(mockTekGrid.callEvent).not.toHaveBeenCalled();
67
- // Should still reset the flag
68
- // @ts-ignore - access protected property for testing
69
- expect(tekGridEvents.preventRowDoubleClick).toBe(false);
70
- });
71
- });
72
-
73
- describe('groupRowClick', () => {
74
- it('should dispatch groupRowClick event when not prevented', () => {
75
- tekGridEvents.groupRowClick(mockGroupRow, mockEvent, mockElement);
76
-
77
- expect(mockTekGrid.callEvent).toHaveBeenCalledWith('groupRowClick', {
78
- event: mockEvent,
79
- element: mockElement,
80
- row: mockGroupRow,
81
- component: mockTekGrid,
82
- column: undefined,
83
- });
84
- });
85
-
86
- it('should not dispatch event when prevented', () => {
87
- // @ts-ignore - access protected property for testing
88
- tekGridEvents.preventRowClick = true;
89
- tekGridEvents.groupRowClick(mockGroupRow, mockEvent, mockElement);
90
-
91
- expect(mockTekGrid.callEvent).not.toHaveBeenCalled();
92
- // Should still reset the flag
93
- // @ts-ignore - access protected property for testing
94
- expect(tekGridEvents.preventRowClick).toBe(false);
95
- });
96
- });
97
-
98
- describe('groupRowDoubleClick', () => {
99
- it('should dispatch groupRowDoubleClick event when not prevented', () => {
100
- tekGridEvents.groupRowDoubleClick(mockGroupRow, mockEvent, mockElement);
101
-
102
- expect(mockTekGrid.callEvent).toHaveBeenCalledWith('groupRowDoubleClick', {
103
- event: mockEvent,
104
- element: mockElement,
105
- row: mockGroupRow,
106
- component: mockTekGrid,
107
- column: undefined,
108
- });
109
- });
110
-
111
- it('should not dispatch event when prevented', () => {
112
- // @ts-ignore - access protected property for testing
113
- tekGridEvents.preventRowDoubleClick = true;
114
- tekGridEvents.groupRowDoubleClick(mockGroupRow, mockEvent, mockElement);
115
-
116
- expect(mockTekGrid.callEvent).not.toHaveBeenCalled();
117
- // Should still reset the flag
118
- // @ts-ignore - access protected property for testing
119
- expect(tekGridEvents.preventRowDoubleClick).toBe(false);
120
- });
121
- });
122
-
123
- describe('selectGroupClick', () => {
124
- it('should dispatch groupSelected event when isSelected is true', () => {
125
- tekGridEvents.selectGroupClick(mockGroupRow, true, mockEvent, mockElement);
126
-
127
- expect(mockTekGrid.callEvent).toHaveBeenCalledWith('groupSelected', {
128
- event: mockEvent,
129
- element: mockElement,
130
- row: mockGroupRow,
131
- component: mockTekGrid,
132
- column: undefined,
133
- });
134
- expect(mockTekGrid.callEvent).not.toHaveBeenCalledWith('groupUnselected', expect.anything());
135
- });
136
-
137
- it('should dispatch groupUnselected event when isSelected is false', () => {
138
- tekGridEvents.selectGroupClick(mockGroupRow, false, mockEvent, mockElement);
139
-
140
- expect(mockTekGrid.callEvent).toHaveBeenCalledWith('groupUnselected', {
141
- event: mockEvent,
142
- element: mockElement,
143
- row: mockGroupRow,
144
- component: mockTekGrid,
145
- column: undefined,
146
- });
147
- expect(mockTekGrid.callEvent).not.toHaveBeenCalledWith('groupSelected', expect.anything());
148
- });
149
-
150
- it('should pass through all parameters correctly', () => {
151
- const customEvent = { type: 'click' } as Event;
152
- const customElement = { tagName: 'DIV' } as HTMLElement;
153
- const customRow = { group: true, groupValue: 'Custom Group' };
154
-
155
- tekGridEvents.selectGroupClick(customRow, true, customEvent, customElement);
156
-
157
- expect(mockTekGrid.callEvent).toHaveBeenCalledWith('groupSelected', {
158
- event: customEvent,
159
- element: customElement,
160
- row: customRow,
161
- component: mockTekGrid,
162
- column: undefined,
163
- });
164
- });
165
- });
166
-
167
- describe('prevention flags', () => {
168
- it('should properly reset prevention flags after operations', () => {
169
- // Set flags to true
170
- // @ts-ignore - access protected properties for testing
171
- tekGridEvents.preventRowClick = true;
172
- // @ts-ignore - access protected properties for testing
173
- tekGridEvents.preventRowDoubleClick = true;
174
-
175
- // Trigger events that should reset them
176
- tekGridEvents.groupRowClick(mockGroupRow, mockEvent, mockElement);
177
- tekGridEvents.rowDoubleClick(mockRow, mockEvent, mockElement);
178
-
179
- // Verify flags were reset
180
- // @ts-ignore - access protected properties for testing
181
- expect(tekGridEvents.preventRowClick).toBe(false);
182
- // @ts-ignore - access protected properties for testing
183
- expect(tekGridEvents.preventRowDoubleClick).toBe(false);
184
- });
185
- });
186
- });
@@ -1,34 +0,0 @@
1
- import { Metadata } from '@zeedhi/core';
2
- import { TekGridToolbarProvider } from '../../../../src';
3
-
4
- describe('TekGridColumnsButton', () => {
5
- describe('getAtomInstance()', () => {
6
- it('when called, should call Metadata.getInstance passing the name of the atom', () => {
7
- const mockGrid = { name: 'name' } as any;
8
- const toolbarProvider = new TekGridToolbarProvider(mockGrid, 'show');
9
- const spy = jest.spyOn(Metadata, 'getInstance').mockImplementation(() => {});
10
- toolbarProvider.getAtomInstance('TITLE');
11
- expect(spy).toHaveBeenCalledWith('name_gridTitle');
12
- });
13
- });
14
-
15
- describe('reloadGrid()', () => {
16
- it('when called, should call grid.reload', () => {
17
- const mockGrid = { reload: jest.fn(), callEvent: jest.fn() } as any;
18
- const toolbarProvider = new TekGridToolbarProvider(mockGrid, 'show');
19
- toolbarProvider.reloadGrid({ event: { defaultPrevented: false } } as any);
20
-
21
- expect(mockGrid.callEvent).toHaveBeenCalled();
22
- expect(mockGrid.reload).toHaveBeenCalled();
23
- });
24
-
25
- it('when called with defaultPrevented, should not call grid.reload', () => {
26
- const mockGrid = { reload: jest.fn(), callEvent: jest.fn() } as any;
27
- const toolbarProvider = new TekGridToolbarProvider(mockGrid, 'show');
28
- toolbarProvider.reloadGrid({ event: { defaultPrevented: true } } as any);
29
-
30
- expect(mockGrid.callEvent).toHaveBeenCalled();
31
- expect(mockGrid.reload).not.toHaveBeenCalled();
32
- });
33
- });
34
- });