@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,91 +1,91 @@
1
- import { GridEditable } from '@zeedhi/common';
2
- import { CrudCancelButton, CrudForm } from '../../../../src';
3
-
4
- describe('CrudCancelButton', () => {
5
- describe('constructor', () => {
6
- it('should create new CrudCancelButton with default values', () => {
7
- const instance = new CrudCancelButton({
8
- name: 'button',
9
- component: 'TekCrudCancelButton',
10
- clickShortcutKey: 'esc',
11
- });
12
-
13
- expect(instance.clickShortcutKey).toBe('esc');
14
- expect(instance.label).toBe('CANCEL');
15
- expect(instance.outline).toBeTruthy();
16
- });
17
-
18
- it('should create new CrudCancelButton replace default values', () => {
19
- const instance = new CrudCancelButton({
20
- name: 'button',
21
- component: 'TekCrudCancelButton',
22
- clickShortcutKey: '',
23
- label: 'cancelar',
24
- outline: false,
25
- });
26
-
27
- expect(instance.clickShortcutKey).toBe('esc');
28
- expect(instance.label).toBe('cancelar');
29
- expect(instance.outline).toBeFalsy();
30
- });
31
-
32
- it('click() CrudForm', () => {
33
- const method = jest.fn();
34
- const instance = new CrudCancelButton({
35
- name: 'cancelButton',
36
- component: 'TekCrudCancelButton',
37
- clickShortcutKey: 'esc',
38
- events: { click: method },
39
- });
40
-
41
- instance.click({} as Event, {} as HTMLElement);
42
- expect(method).not.toHaveBeenCalled();
43
- const crudForm = new CrudForm({ name: 'form', component: 'CrudForm' });
44
- instance.parent = crudForm;
45
- instance.click({} as Event, {} as HTMLElement);
46
- expect(method).toHaveBeenCalled();
47
- });
48
-
49
- it('click() CrudForm with defaultPrevent false', () => {
50
- const instance = new CrudCancelButton({
51
- name: 'cancelButton',
52
- component: 'TekCrudCancelButton',
53
- });
54
-
55
- instance.click({ defaultPrevented: false } as Event, {} as HTMLElement);
56
- const crudForm = new CrudForm({ name: 'form', component: 'CrudForm' });
57
- instance.parent = crudForm;
58
- instance.click({ defaultPrevented: true } as Event, {} as HTMLElement);
59
- expect(instance.parent).toBeInstanceOf(CrudForm);
60
- });
61
-
62
- it('click() GridEditable', () => {
63
- const method = jest.fn();
64
- const instance = new CrudCancelButton({
65
- name: 'cancelButton',
66
- component: 'TekCrudCancelButton',
67
- clickShortcutKey: 'esc',
68
- events: { click: method },
69
- });
70
- instance.click({} as Event, {} as HTMLElement);
71
- expect(method).not.toHaveBeenCalled();
72
- const gridEditable = new GridEditable({ name: 'form', component: 'GridEditable' });
73
- instance.parent = gridEditable;
74
- instance.click({} as Event, {} as HTMLElement);
75
- expect(method).toHaveBeenCalled();
76
- });
77
-
78
- it('click() GridEditable with defaultPrevent false', () => {
79
- const instance = new CrudCancelButton({
80
- name: 'cancelButton',
81
- component: 'TekCrudCancelButton',
82
- });
83
-
84
- instance.click({ defaultPrevented: false } as Event, {} as HTMLElement);
85
- const grid = new GridEditable({ name: 'form', component: 'GridEditable' });
86
- instance.parent = grid;
87
- instance.click({ defaultPrevented: true } as Event, {} as HTMLElement);
88
- expect(instance.parent).toBeInstanceOf(GridEditable);
89
- });
90
- });
91
- });
1
+ import { GridEditable } from '@zeedhi/common';
2
+ import { CrudCancelButton, CrudForm } from '../../../../src';
3
+
4
+ describe('CrudCancelButton', () => {
5
+ describe('constructor', () => {
6
+ it('should create new CrudCancelButton with default values', () => {
7
+ const instance = new CrudCancelButton({
8
+ name: 'button',
9
+ component: 'TekCrudCancelButton',
10
+ clickShortcutKey: 'esc',
11
+ });
12
+
13
+ expect(instance.clickShortcutKey).toBe('esc');
14
+ expect(instance.label).toBe('CANCEL');
15
+ expect(instance.outline).toBeTruthy();
16
+ });
17
+
18
+ it('should create new CrudCancelButton replace default values', () => {
19
+ const instance = new CrudCancelButton({
20
+ name: 'button',
21
+ component: 'TekCrudCancelButton',
22
+ clickShortcutKey: '',
23
+ label: 'cancelar',
24
+ outline: false,
25
+ });
26
+
27
+ expect(instance.clickShortcutKey).toBe('esc');
28
+ expect(instance.label).toBe('cancelar');
29
+ expect(instance.outline).toBeFalsy();
30
+ });
31
+
32
+ it('click() CrudForm', () => {
33
+ const method = jest.fn();
34
+ const instance = new CrudCancelButton({
35
+ name: 'cancelButton',
36
+ component: 'TekCrudCancelButton',
37
+ clickShortcutKey: 'esc',
38
+ events: { click: method },
39
+ });
40
+
41
+ instance.click({} as Event, {} as HTMLElement);
42
+ expect(method).not.toHaveBeenCalled();
43
+ const crudForm = new CrudForm({ name: 'form', component: 'CrudForm' });
44
+ instance.parent = crudForm;
45
+ instance.click({} as Event, {} as HTMLElement);
46
+ expect(method).toHaveBeenCalled();
47
+ });
48
+
49
+ it('click() CrudForm with defaultPrevent false', () => {
50
+ const instance = new CrudCancelButton({
51
+ name: 'cancelButton',
52
+ component: 'TekCrudCancelButton',
53
+ });
54
+
55
+ instance.click({ defaultPrevented: false } as Event, {} as HTMLElement);
56
+ const crudForm = new CrudForm({ name: 'form', component: 'CrudForm' });
57
+ instance.parent = crudForm;
58
+ instance.click({ defaultPrevented: true } as Event, {} as HTMLElement);
59
+ expect(instance.parent).toBeInstanceOf(CrudForm);
60
+ });
61
+
62
+ it('click() GridEditable', () => {
63
+ const method = jest.fn();
64
+ const instance = new CrudCancelButton({
65
+ name: 'cancelButton',
66
+ component: 'TekCrudCancelButton',
67
+ clickShortcutKey: 'esc',
68
+ events: { click: method },
69
+ });
70
+ instance.click({} as Event, {} as HTMLElement);
71
+ expect(method).not.toHaveBeenCalled();
72
+ const gridEditable = new GridEditable({ name: 'form', component: 'GridEditable' });
73
+ instance.parent = gridEditable;
74
+ instance.click({} as Event, {} as HTMLElement);
75
+ expect(method).toHaveBeenCalled();
76
+ });
77
+
78
+ it('click() GridEditable with defaultPrevent false', () => {
79
+ const instance = new CrudCancelButton({
80
+ name: 'cancelButton',
81
+ component: 'TekCrudCancelButton',
82
+ });
83
+
84
+ instance.click({ defaultPrevented: false } as Event, {} as HTMLElement);
85
+ const grid = new GridEditable({ name: 'form', component: 'GridEditable' });
86
+ instance.parent = grid;
87
+ instance.click({ defaultPrevented: true } as Event, {} as HTMLElement);
88
+ expect(instance.parent).toBeInstanceOf(GridEditable);
89
+ });
90
+ });
91
+ });
@@ -1,122 +1,122 @@
1
- import { GridEditable } from '@zeedhi/common';
2
- import { CrudDeleteButton } from '../../../../src';
3
-
4
- describe('Crud', () => {
5
- describe('constructor()', () => {
6
- it('should create new CrudDeleteButton with default values', () => {
7
- const instance = new CrudDeleteButton({
8
- name: 'saveButton',
9
- component: 'TekCrudDeleteButton',
10
- });
11
- expect(instance.clickShortcutKey).toBe('ctrl+d');
12
- expect(instance.dark).toBeFalsy();
13
- expect(instance.disabled).toBeTruthy();
14
- expect(instance.fab).toBeFalsy();
15
- expect(instance.fixed).toBeFalsy();
16
- expect(instance.flat).toBeTruthy();
17
- expect(instance.href).toBe('');
18
- expect(instance.icon).toBeTruthy();
19
- expect(instance.iconName).toBe('trashCanOutline');
20
- expect(instance.label).toBe('');
21
- });
22
-
23
- it('should create new CrudDeleteButton replace default values', () => {
24
- const instance = new CrudDeleteButton({
25
- name: 'saveButton',
26
- component: 'TekCrudDeleteButton',
27
- clickShortcutKey: 'f1',
28
- flat: false,
29
- icon: false,
30
- iconName: 'clear',
31
- color: '#ddd',
32
- });
33
- expect(instance.clickShortcutKey).toBe('f1');
34
- expect(instance.flat).toBeFalsy();
35
- expect(instance.icon).toBeFalsy();
36
- expect(instance.iconName).toBe('clear');
37
- expect(instance.color).toBe('#ddd');
38
- });
39
-
40
- it('click()', () => {
41
- const method = () => undefined;
42
- const instance = new CrudDeleteButton({
43
- name: 'delete',
44
- component: 'TekCrudDeleteButton',
45
- clickShortcutKey: 'ctrl+d',
46
- events: { click: method },
47
- });
48
- const spy = jest.spyOn((instance.events as any), 'click');
49
- instance.click({} as Event, {} as HTMLElement);
50
- expect(spy).toHaveBeenCalledWith({ component: instance, event: {}, element: {} });
51
- spy.mockClear();
52
- });
53
-
54
- it('instance parent is GridEditable', () => {
55
- const instance = new CrudDeleteButton({
56
- name: 'cancelButton',
57
- component: 'TekCrudDeleteButton',
58
- });
59
- const grid = new GridEditable({ name: 'grid', component: 'GridEditable' });
60
- instance.parent = grid;
61
- expect(instance.parentHasSelectedRows).toBeFalsy();
62
- expect(instance.parent).toBeInstanceOf(GridEditable);
63
- });
64
-
65
- it('should return parentHasCurrentRow and parentHasSelectedRows false', () => {
66
- const method = jest.fn();
67
- const instance = new CrudDeleteButton({
68
- name: 'cancelButton',
69
- component: 'TekCrudDeleteButton',
70
- events: { click: method },
71
- });
72
- const gridEditable = new GridEditable({ name: 'form', component: 'GridEditable' });
73
- instance.parent = gridEditable;
74
- expect(instance.parentHasCurrentRow).toBeFalsy();
75
- expect(instance.parentHasSelectedRows).toBeFalsy();
76
- instance.click({} as Event, {} as HTMLElement);
77
- expect(method).toHaveBeenCalled();
78
- instance.click({ defaultPrevented: false } as Event, {} as HTMLElement);
79
- expect(method).toHaveBeenCalled();
80
- });
81
-
82
- it('should return parentHasSelectedRows with selectedRows true', () => {
83
- const method = jest.fn();
84
- const instance = new CrudDeleteButton({
85
- name: 'cancelButton',
86
- component: 'TekCrudDeleteButton',
87
- events: { click: method },
88
- });
89
- const gridEditable = new GridEditable({ name: 'form', component: 'GridEditable', selectable: true });
90
- instance.parent = gridEditable;
91
- expect(instance.parentHasSelectedRows).toBeFalsy();
92
- instance.click({} as Event, {} as HTMLElement);
93
- expect(method).toHaveBeenCalled();
94
- instance.click({ defaultPrevented: false } as Event, {} as HTMLElement);
95
- expect(method).toHaveBeenCalled();
96
- });
97
-
98
- it('should call cellClick event', () => {
99
- const instance = new CrudDeleteButton({
100
- name: 'cancelButton',
101
- component: 'TekCrudDeleteButton',
102
- });
103
- const grid = new GridEditable({
104
- name: 'Grid',
105
- component: 'ZdGridEditable',
106
- columns: [
107
- { name: 'id' },
108
- ],
109
- datasource: {
110
- limit: 2,
111
- page: 1,
112
- data: [
113
- { id: 1 },
114
- ],
115
- },
116
- });
117
-
118
- expect(grid.selectedRows).toEqual([]);
119
- expect(instance.parentHasSelectedRows).toBeFalsy();
120
- });
121
- });
122
- });
1
+ import { GridEditable } from '@zeedhi/common';
2
+ import { CrudDeleteButton } from '../../../../src';
3
+
4
+ describe('Crud', () => {
5
+ describe('constructor()', () => {
6
+ it('should create new CrudDeleteButton with default values', () => {
7
+ const instance = new CrudDeleteButton({
8
+ name: 'saveButton',
9
+ component: 'TekCrudDeleteButton',
10
+ });
11
+ expect(instance.clickShortcutKey).toBe('ctrl+d');
12
+ expect(instance.dark).toBeFalsy();
13
+ expect(instance.disabled).toBeTruthy();
14
+ expect(instance.fab).toBeFalsy();
15
+ expect(instance.fixed).toBeFalsy();
16
+ expect(instance.flat).toBeTruthy();
17
+ expect(instance.href).toBe('');
18
+ expect(instance.icon).toBeTruthy();
19
+ expect(instance.iconName).toBe('trashCanOutline');
20
+ expect(instance.label).toBe('');
21
+ });
22
+
23
+ it('should create new CrudDeleteButton replace default values', () => {
24
+ const instance = new CrudDeleteButton({
25
+ name: 'saveButton',
26
+ component: 'TekCrudDeleteButton',
27
+ clickShortcutKey: 'f1',
28
+ flat: false,
29
+ icon: false,
30
+ iconName: 'clear',
31
+ color: '#ddd',
32
+ });
33
+ expect(instance.clickShortcutKey).toBe('f1');
34
+ expect(instance.flat).toBeFalsy();
35
+ expect(instance.icon).toBeFalsy();
36
+ expect(instance.iconName).toBe('clear');
37
+ expect(instance.color).toBe('#ddd');
38
+ });
39
+
40
+ it('click()', () => {
41
+ const method = () => undefined;
42
+ const instance = new CrudDeleteButton({
43
+ name: 'delete',
44
+ component: 'TekCrudDeleteButton',
45
+ clickShortcutKey: 'ctrl+d',
46
+ events: { click: method },
47
+ });
48
+ const spy = jest.spyOn((instance.events as any), 'click');
49
+ instance.click({} as Event, {} as HTMLElement);
50
+ expect(spy).toHaveBeenCalledWith({ component: instance, event: {}, element: {} });
51
+ spy.mockClear();
52
+ });
53
+
54
+ it('instance parent is GridEditable', () => {
55
+ const instance = new CrudDeleteButton({
56
+ name: 'cancelButton',
57
+ component: 'TekCrudDeleteButton',
58
+ });
59
+ const grid = new GridEditable({ name: 'grid', component: 'GridEditable' });
60
+ instance.parent = grid;
61
+ expect(instance.parentHasSelectedRows).toBeFalsy();
62
+ expect(instance.parent).toBeInstanceOf(GridEditable);
63
+ });
64
+
65
+ it('should return parentHasCurrentRow and parentHasSelectedRows false', () => {
66
+ const method = jest.fn();
67
+ const instance = new CrudDeleteButton({
68
+ name: 'cancelButton',
69
+ component: 'TekCrudDeleteButton',
70
+ events: { click: method },
71
+ });
72
+ const gridEditable = new GridEditable({ name: 'form', component: 'GridEditable' });
73
+ instance.parent = gridEditable;
74
+ expect(instance.parentHasCurrentRow).toBeFalsy();
75
+ expect(instance.parentHasSelectedRows).toBeFalsy();
76
+ instance.click({} as Event, {} as HTMLElement);
77
+ expect(method).toHaveBeenCalled();
78
+ instance.click({ defaultPrevented: false } as Event, {} as HTMLElement);
79
+ expect(method).toHaveBeenCalled();
80
+ });
81
+
82
+ it('should return parentHasSelectedRows with selectedRows true', () => {
83
+ const method = jest.fn();
84
+ const instance = new CrudDeleteButton({
85
+ name: 'cancelButton',
86
+ component: 'TekCrudDeleteButton',
87
+ events: { click: method },
88
+ });
89
+ const gridEditable = new GridEditable({ name: 'form', component: 'GridEditable', selectable: true });
90
+ instance.parent = gridEditable;
91
+ expect(instance.parentHasSelectedRows).toBeFalsy();
92
+ instance.click({} as Event, {} as HTMLElement);
93
+ expect(method).toHaveBeenCalled();
94
+ instance.click({ defaultPrevented: false } as Event, {} as HTMLElement);
95
+ expect(method).toHaveBeenCalled();
96
+ });
97
+
98
+ it('should call cellClick event', () => {
99
+ const instance = new CrudDeleteButton({
100
+ name: 'cancelButton',
101
+ component: 'TekCrudDeleteButton',
102
+ });
103
+ const grid = new GridEditable({
104
+ name: 'Grid',
105
+ component: 'ZdGridEditable',
106
+ columns: [
107
+ { name: 'id' },
108
+ ],
109
+ datasource: {
110
+ limit: 2,
111
+ page: 1,
112
+ data: [
113
+ { id: 1 },
114
+ ],
115
+ },
116
+ });
117
+
118
+ expect(grid.selectedRows).toEqual([]);
119
+ expect(instance.parentHasSelectedRows).toBeFalsy();
120
+ });
121
+ });
122
+ });