@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,5 +0,0 @@
1
- const core = jest.requireActual('@zeedhi/core');
2
-
3
- core.I18n = require('./core/i18n');
4
-
5
- module.exports = core;
@@ -1,56 +0,0 @@
1
- import { CrudAddButton } from '../../../../src';
2
-
3
- describe('CrudAddButton', () => {
4
- describe('constructor()', () => {
5
- it('should create new CrudAddButton with default values', () => {
6
- const instance = new CrudAddButton({
7
- name: 'saveButton',
8
- component: 'TekCrudSaveButton',
9
- });
10
-
11
- expect(instance.clickShortcutKey).toBe('f2');
12
- expect(instance.dark).toBeFalsy();
13
- expect(instance.disabled).toBeFalsy();
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('plus');
20
- expect(instance.label).toBe('');
21
- expect(instance.color).toBe('#666');
22
- });
23
-
24
- it('should create new CrudAddButton replace default values', () => {
25
- const instance = new CrudAddButton({
26
- name: 'saveButton',
27
- component: 'TekCrudSaveButton',
28
- clickShortcutKey: 'f3',
29
- flat: true,
30
- icon: false,
31
- color: '#ddd',
32
- iconName: 'complete',
33
- });
34
- expect(instance.clickShortcutKey).toBe('f3');
35
- expect(instance.color).toBe('#ddd');
36
- expect(instance.fixed).toBeFalsy();
37
- expect(instance.flat).toBeTruthy();
38
- expect(instance.icon).toBeFalsy();
39
- expect(instance.iconName).toBe('complete');
40
- });
41
-
42
- it('click()', () => {
43
- const method = () => undefined;
44
- const instance = new CrudAddButton({
45
- name: 'saveButton',
46
- component: 'TekCrudSaveButton',
47
- clickShortcutKey: 'f2',
48
- events: { click: method },
49
- });
50
- const spy = jest.spyOn((instance.events as any), 'click');
51
- instance.click({} as Event, {} as HTMLElement);
52
- expect(spy).toHaveBeenCalledWith({ component: instance, event: {}, element: {} });
53
- spy.mockClear();
54
- });
55
- });
56
- });
@@ -1,94 +0,0 @@
1
- import { GridEditable } from '@zeedhi/common';
2
- import { KeyMap } from '@zeedhi/core';
3
- import { CrudButton, CrudForm } from '../../../../src';
4
-
5
- const dispatchEvent = (key: string, modifiers: any, repeated = false) => {
6
- let prevented = false;
7
- const event = new KeyboardEvent('keydown', modifiers);
8
- delete (event as any).key;
9
- Object.defineProperty(event, 'key', { value: key });
10
- delete (event as any).code;
11
- Object.defineProperty(event, 'code', { value: key });
12
-
13
- if (repeated) {
14
- delete (event as any).repeat;
15
- Object.defineProperty(event, 'repeat', { value: true });
16
- }
17
-
18
- delete (event as any).preventDefault;
19
- Object.defineProperty(event, 'preventDefault', {
20
- value: () => {
21
- prevented = true;
22
- },
23
- });
24
- document.dispatchEvent(event);
25
- return prevented;
26
- };
27
-
28
- describe('CrudButton', () => {
29
- describe('constructor()', () => {
30
- it('should init KeyMap', () => {
31
- const instance = new CrudButton({ name: 'button', component: 'tekCrudButton' });
32
- const element = document.createElement('div');
33
- expect(instance.initKeyMap(element)).toBe(undefined);
34
- });
35
-
36
- it('should init shortcutClick', () => {
37
- let called = false;
38
- const method = () => { called = true; };
39
- const keyMap = {
40
- a: {
41
- event: method,
42
- },
43
- };
44
- const instance = new CrudButton({
45
- name: 'button',
46
- component: 'tekCrudButton',
47
- clickShortcutKey: 'a',
48
- keyMap,
49
-
50
- });
51
-
52
- KeyMap.bind(instance.keyMap);
53
- dispatchEvent('a', {});
54
- expect(called).toBeFalsy();
55
- KeyMap.unbind(instance.keyMap);
56
- });
57
-
58
- it('should init shortcutClick disabled', () => {
59
- let called = false;
60
- const method = () => { called = true; };
61
- const keyMap = {
62
- a: {
63
- event: method,
64
- },
65
- };
66
- const instance = new CrudButton({
67
- name: 'button',
68
- component: 'tekCrudButton',
69
- clickShortcutKey: 'a',
70
- disabled: true,
71
- keyMap,
72
-
73
- });
74
-
75
- KeyMap.bind(instance.keyMap);
76
- dispatchEvent('a', {});
77
- expect(called).toBeFalsy();
78
- });
79
-
80
- it('parent instanceof CrudForm', () => {
81
- const instance = new CrudButton({ name: 'button', component: 'tekCrudButton' });
82
- const crudForm = new CrudForm({ name: 'grid', component: 'CrudForm' });
83
- instance.parent = crudForm;
84
- expect(instance.parentIsEditing).toBeFalsy();
85
- });
86
-
87
- it('parent instanceof GridEditable', () => {
88
- const instance = new CrudButton({ name: 'button', component: 'tekCrudButton' });
89
- const crudForm = new GridEditable({ name: 'grid', component: 'CrudForm' });
90
- instance.parent = crudForm;
91
- expect(instance.parentIsEditing).toBeFalsy();
92
- });
93
- });
94
- });
@@ -1,91 +0,0 @@
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 +0,0 @@
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,165 +0,0 @@
1
- import { CrudForm } from '../../../../src';
2
-
3
- describe('TekCrudForm', () => {
4
- describe('constructor', () => {
5
- it('should create new TekCrudForm with default values', () => {
6
- const instance = new CrudForm({
7
- name: 'form',
8
- component: 'TekCrudForm',
9
- });
10
- expect(instance.children).toStrictEqual([]);
11
- expect(instance.justify).toBe(undefined);
12
- expect(instance.editing).toBeFalsy();
13
- expect(instance.isVisible).toBeTruthy();
14
- });
15
-
16
- it('should create new TekCrudForm with value prop', () => {
17
- const instance = new CrudForm({
18
- name: 'form',
19
- component: 'TekCrudForm',
20
- value: { input: '1' },
21
- });
22
- expect(instance.value).toEqual({ input: '1' });
23
- });
24
- });
25
-
26
- describe('TekCrudForm methods returns', () => {
27
- it('cancelEdit method', () => {
28
- const eventFn = jest.fn();
29
- const instance = new CrudForm({
30
- name: 'form',
31
- component: 'TekCrudForm',
32
- });
33
- expect(eventFn).not.toHaveBeenCalled();
34
-
35
- instance.events = {
36
- focus: eventFn,
37
- };
38
- instance.focus();
39
- expect(instance.cancelEdit()).toBe(undefined);
40
- });
41
-
42
- it('saveEdit method', () => {
43
- const eventFn = jest.fn();
44
- const instance = new CrudForm({
45
- name: 'form',
46
- component: 'TekCrudForm',
47
- events: {
48
- saveEdit: eventFn,
49
- },
50
- });
51
- const event = new Event('click');
52
- instance.click(event, {} as HTMLElement);
53
- expect(eventFn).not.toHaveBeenCalled();
54
- });
55
-
56
- it('focus method', () => {
57
- const eventFn = jest.fn();
58
- const instance = new CrudForm({
59
- name: 'form',
60
- component: 'TekCrudForm',
61
- });
62
- expect(eventFn).not.toHaveBeenCalled();
63
-
64
- instance.events = {
65
- focus: eventFn,
66
- };
67
- instance.focus();
68
-
69
- expect(instance.focus()).toBe(undefined);
70
- });
71
- });
72
-
73
- describe('onMounted()', () => {
74
- it('should call event', () => {
75
- const method = () => undefined;
76
- const instance = new CrudForm({
77
- name: 'form',
78
- component: 'TekCrudForm',
79
- events: { onMounted: method },
80
- });
81
- const spy = jest.spyOn((instance.events as any), 'onMounted');
82
- const element = document.createElement('div');
83
- instance.onMounted(element as HTMLElement);
84
- expect(spy).toHaveBeenCalledWith({ component: instance, element });
85
- spy.mockClear();
86
- });
87
-
88
- it('should not throw when event is undefined', () => {
89
- const instance = new CrudForm({
90
- name: 'form',
91
- component: 'TekCrudForm',
92
- });
93
- const element = document.createElement('div');
94
- expect(() => { instance.onMounted(element as HTMLElement); }).not.toThrow();
95
- });
96
- });
97
-
98
- describe('updateChild()', () => {
99
- it('should call event', () => {
100
- const instance = new CrudForm({
101
- name: 'form',
102
- component: 'TekCrudForm',
103
- children: [
104
- {
105
- name: 'input',
106
- component: 'Input',
107
- },
108
- ],
109
- });
110
- const child = instance.children[0].component;
111
- expect(instance.updateChild(child as any, 'test')).toBe(undefined);
112
- });
113
-
114
- it('should not throw when event is undefined', () => {
115
- const instance = new CrudForm({
116
- name: 'form',
117
- component: 'TekCrudForm',
118
- });
119
- const element = document.createElement('div');
120
- expect(() => { instance.onMounted(element as HTMLElement); }).not.toThrow();
121
- });
122
- });
123
-
124
- describe('setValue()', () => {
125
- it('when called, should set the form value', () => {
126
- const instance = new CrudForm({
127
- name: 'form',
128
- component: 'TekCrudForm',
129
- children: [
130
- {
131
- name: 'input',
132
- component: 'Input',
133
- },
134
- ],
135
- });
136
-
137
- const newValue = 'new value';
138
- instance.setValue({ input: newValue });
139
- instance.updateChild({ name: 'input' } as any, newValue);
140
-
141
- expect(instance.value).toEqual({ input: 'new value' });
142
- expect(instance.editing).toBeFalsy();
143
- });
144
-
145
- it('when called without autoSave, should set the form value and set editing as true', () => {
146
- const instance = new CrudForm({
147
- name: 'form',
148
- component: 'TekCrudForm',
149
- children: [
150
- {
151
- name: 'input',
152
- component: 'Input',
153
- },
154
- ],
155
- });
156
-
157
- const newValue = 'new value';
158
- instance.setValue({ input: newValue }, false);
159
- instance.updateChild({ name: 'input' } as any, newValue);
160
-
161
- expect(instance.value).toEqual({ input: 'new value' });
162
- expect(instance.editing).toBeTruthy();
163
- });
164
- });
165
- });
@@ -1,118 +0,0 @@
1
- import { GridEditable } from '@zeedhi/common';
2
- import { CrudForm, CrudSaveButton } from '../../../../src';
3
-
4
- describe('CrudSaveButton', () => {
5
- describe('constructor()', () => {
6
- it('should create new CrudSaveButton with default values', () => {
7
- const instance = new CrudSaveButton({
8
- name: 'button',
9
- component: 'TekCrudSaveButton',
10
- clickShortcutKey: 'ctrl+enter',
11
- });
12
-
13
- expect(instance.clickShortcutKey).toBe('ctrl+enter');
14
- expect(instance.label).toBe('SAVE');
15
- });
16
-
17
- it('should create new CrudSaveButton replace default values', () => {
18
- const instance = new CrudSaveButton({
19
- name: 'button',
20
- component: 'TekCrudSaveButton',
21
- clickShortcutKey: '',
22
- label: 'Salvar',
23
- });
24
-
25
- expect(instance.clickShortcutKey).toBe('ctrl+enter');
26
- expect(instance.label).toBe('Salvar');
27
- });
28
-
29
- it('CrudSaveButton click()', () => {
30
- const method = jest.fn();
31
- const instance = new CrudSaveButton({
32
- name: 'button',
33
- component: 'TekCrudSaveButton',
34
- events: { click: method },
35
- });
36
-
37
- instance.click({} as Event, {} as HTMLElement);
38
- expect(method).not.toHaveBeenCalled();
39
- const crudForm = new CrudForm({ name: 'form', component: 'CrudForm' });
40
- instance.parent = crudForm;
41
-
42
- instance.click({} as Event, {} as HTMLElement);
43
- expect(method).toHaveBeenCalled();
44
- });
45
-
46
- it('click() CrudForm with defaultPrevent false', () => {
47
- const instance = new CrudSaveButton({
48
- name: 'cancelButton',
49
- component: 'TekCrudCancelButton',
50
- });
51
-
52
- instance.click({ defaultPrevented: false } as Event, {} as HTMLElement);
53
- const crudForm = new CrudForm({ name: 'form', component: 'CrudForm' });
54
- instance.parent = crudForm;
55
- instance.click({ defaultPrevented: true } as Event, {} as HTMLElement);
56
- expect(instance.parent).toBeInstanceOf(CrudForm);
57
- });
58
-
59
- it('CrudSaveButton click() no validate', () => {
60
- const method = jest.fn();
61
- const instance = new CrudSaveButton({
62
- name: 'button',
63
- component: 'TekCrudSaveButton',
64
- events: { click: method },
65
- });
66
-
67
- const crudForm = new CrudForm({ name: 'form', component: 'CrudForm' });
68
- crudForm.validate = () => false;
69
- instance.parent = crudForm;
70
- instance.click({} as Event, {} as HTMLElement);
71
- expect(method).not.toHaveBeenCalled();
72
- });
73
-
74
- it('CrudSaveButton click() when event is not prevented', () => {
75
- const instance = new CrudSaveButton({
76
- name: 'button',
77
- component: 'TekCrudSaveButton',
78
- });
79
-
80
- const crudForm = new CrudForm({ name: 'form', component: 'CrudForm' });
81
- instance.parent = crudForm;
82
- instance.click({ defaultPrevented: false } as Event, {} as HTMLElement);
83
- expect(crudForm.saveEdit).toBeTruthy();
84
- instance.click({ defaultPrevented: false } as Event, {} as HTMLElement);
85
- expect(crudForm.editing).toBeFalsy();
86
- instance.click({ defaultPrevented: false } as Event, {} as HTMLElement);
87
- expect(crudForm.editing).toBeFalsy();
88
- });
89
-
90
- it('click() GridEditable', () => {
91
- const method = jest.fn();
92
- const instance = new CrudSaveButton({
93
- name: 'button',
94
- component: 'TekCrudSaveButton',
95
- events: { click: method },
96
- });
97
- const gridEditable = new GridEditable({ name: 'form', component: 'GridEditable' });
98
- instance.click({} as Event, {} as HTMLElement);
99
- expect(method).not.toHaveBeenCalled();
100
- instance.parent = gridEditable;
101
- instance.click({} as Event, {} as HTMLElement);
102
- expect(method).toHaveBeenCalled();
103
- });
104
-
105
- it('click() GridEditable with defaultPrevent false', () => {
106
- const instance = new CrudSaveButton({
107
- name: 'cancelButton',
108
- component: 'TekCrudCancelButton',
109
- });
110
-
111
- instance.click({ defaultPrevented: false } as Event, {} as HTMLElement);
112
- const grid = new GridEditable({ name: 'form', component: 'GridEditable' });
113
- instance.parent = grid;
114
- instance.click({ defaultPrevented: true } as Event, {} as HTMLElement);
115
- expect(instance.parent).toBeInstanceOf(GridEditable);
116
- });
117
- });
118
- });
@@ -1,42 +0,0 @@
1
- import { BreadcrumbHeader, Image } from '../../../../src';
2
-
3
- describe('BreadcrumbHeader', () => {
4
- describe('constructor()', () => {
5
- it('should create new BreadcrumbHeader with default values', () => {
6
- const instance = new BreadcrumbHeader({
7
- name: 'BreadcrumbHeader',
8
- component: 'TekBreadcrumbHeader',
9
- title: '',
10
- breadcrumb: {
11
- name: 'breadcrumb',
12
- component: 'ZdBreadcrumb',
13
- divider: '>',
14
- },
15
- });
16
- expect(instance.title).toBe('');
17
- expect(instance.rightSlot).toStrictEqual([]);
18
- });
19
-
20
- it('should create new BreadcrumbHeader with rightSlot values', () => {
21
- const image = new Image({
22
- name: 'image',
23
- component: 'tekImage',
24
- src: '/img/zeedhi.svg',
25
- to: 'google.com.br',
26
- });
27
- const instance = new BreadcrumbHeader({
28
- name: 'BreadcrumbHeader',
29
- component: 'TekBreadcrumbHeader',
30
- title: '',
31
- breadcrumb: {
32
- name: 'breadcrumb',
33
- component: 'ZdBreadcrumb',
34
- divider: '>',
35
- },
36
- rightSlot: [image],
37
- });
38
- expect(instance.title).toBe('');
39
- expect(instance.rightSlot).toEqual([image]);
40
- });
41
- });
42
- });