@zeedhi/teknisa-components-common 1.108.0 → 1.109.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 (70) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +7 -7
  3. package/coverage/clover.xml +49 -49
  4. package/coverage/coverage-final.json +47 -47
  5. package/coverage/lcov-report/index.html +1 -1
  6. package/coverage/lcov-report/tests/__helpers__/component-event-helper.ts.html +1 -1
  7. package/coverage/lcov-report/tests/__helpers__/flush-promises-helper.ts.html +1 -1
  8. package/coverage/lcov-report/tests/__helpers__/get-child-helper.ts.html +1 -1
  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 +47 -47
  13. package/jest.config.js +1 -1
  14. package/package.json +2 -2
  15. package/tests/__helpers__/component-event-helper.ts +5 -5
  16. package/tests/__helpers__/flush-promises-helper.ts +3 -3
  17. package/tests/__helpers__/get-child-helper.ts +27 -27
  18. package/tests/__helpers__/index.ts +3 -3
  19. package/tests/__helpers__/mock-created-helper.ts +12 -12
  20. package/tests/__mocks__/@zeedhi/core/i18n.js +74 -74
  21. package/tests/__mocks__/@zeedhi/core.js +4 -4
  22. package/tests/unit/components/crud/crud-add-button.spec.ts +56 -56
  23. package/tests/unit/components/crud/crud-button.spec.ts +94 -94
  24. package/tests/unit/components/crud/crud-cancel-button.spec.ts +91 -91
  25. package/tests/unit/components/crud/crud-delete-button.spec.ts +122 -122
  26. package/tests/unit/components/crud/crud-form.spec.ts +165 -165
  27. package/tests/unit/components/crud/crud-save-button.spec.ts +118 -118
  28. package/tests/unit/components/tek-breadcrumb-header/tek-breadcrumb-header.spec.ts +42 -42
  29. package/tests/unit/components/tek-card-title/CardTitle.spec.ts +34 -34
  30. package/tests/unit/components/tek-datasource/memory-datasource.spec.ts +470 -470
  31. package/tests/unit/components/tek-datasource/rest-datasource.spec.ts +364 -364
  32. package/tests/unit/components/tek-drag-grid/tek-drag-grid.spec.ts +112 -112
  33. package/tests/unit/components/tek-grid/filter-helper.spec.ts +148 -148
  34. package/tests/unit/components/tek-grid/grid-column.spec.ts +270 -270
  35. package/tests/unit/components/tek-grid/grid-columns-button.spec.ts +195 -195
  36. package/tests/unit/components/tek-grid/grid-filter-button.spec.ts +967 -967
  37. package/tests/unit/components/tek-grid/grid.spec.ts +3340 -3340
  38. package/tests/unit/components/tek-grid/layout_options.spec.ts +980 -980
  39. package/tests/unit/components/tek-image/Image.spec.ts +67 -67
  40. package/tests/unit/components/tek-iterable-carousel/iterable-carousel.spec.ts +37 -37
  41. package/tests/unit/components/tek-iterable-component-render/iterable-component-render.spec.ts +200 -200
  42. package/tests/unit/components/tek-loading/Loading.spec.ts +30 -30
  43. package/tests/unit/components/tek-notifications/notifications.spec.ts +201 -201
  44. package/tests/unit/components/tek-product-card/product-card.spec.ts +61 -61
  45. package/tests/unit/components/tek-user-info/TekUserInfoContoller.spec.ts +220 -220
  46. package/tests/unit/components/tek-user-info/tek-user-info-list.spec.ts +86 -86
  47. package/tests/unit/components/tek-user-info/tek-user-info.spec.ts +430 -430
  48. package/tests/unit/components/tree-grid/tree-grid.spec.ts +776 -776
  49. package/tests/unit/utils/grid-base/delete-rows-error.spec.ts +24 -24
  50. package/tests/unit/utils/grid-base/export-options/button-option.spec.ts +44 -44
  51. package/tests/unit/utils/grid-base/export-options/multi-option.spec.ts +135 -135
  52. package/tests/unit/utils/grid-base/grid-controller.spec.ts +267 -267
  53. package/tests/unit/utils/report-filter/report-filter.spec.ts +66 -66
  54. package/tsconfig.eslint.json +8 -8
  55. package/types/components/tek-ag-grid/default-icons.d.ts +53 -0
  56. package/types/components/tek-ag-grid/interfaces.d.ts +9 -0
  57. package/types/components/tek-ag-grid/tek-ag-grid.d.ts +35 -0
  58. package/types/components/tek-datasource/datasource.d.ts +94 -0
  59. package/types/components/tek-datasource/memory-datasource.d.ts +4 -2
  60. package/types/components/tek-datasource/rest-datasource.d.ts +3 -6
  61. package/types/components/tek-grid/default-icons.d.ts +53 -0
  62. package/types/components/tek-grid/filter-dynamic-values.d.ts +9 -0
  63. package/types/components/tek-grid/grid-controller.d.ts +19 -0
  64. package/types/components/tek-grid/grid_column.d.ts +14 -0
  65. package/types/components/tek-grid/grid_controller.d.ts +15 -0
  66. package/types/components/tek-grid/tek-grid.d.ts +35 -0
  67. package/types/components/tek-login/interfaces.d.ts +3 -0
  68. package/types/components/tek-login/login-children.d.ts +3 -0
  69. package/types/components/tek-login/login.d.ts +58 -0
  70. package/types/components/tek-login/login_children.d.ts +3 -0
@@ -1,75 +1,75 @@
1
- /**
2
- * Mock for @zeedhi/core I18n API
3
- */
4
-
5
- const words = {
6
- TEKGRID_CONTAINS: 'contains',
7
- TEKGRID_NOT_CONTAINS: 'does not contain',
8
- TEKGRID_EQUALS: 'is equal to',
9
- TEKGRID_NOT_EQUALS: 'is different from',
10
- TEKGRID_GREATER_THAN: 'is greater than',
11
- TEKGRID_LESS_THAN: 'is less than',
12
- TEKGRID_GREATER_THAN_EQUALS: 'is greater or equals to',
13
- TEKGRID_LESS_THAN_EQUALS: 'is less or equals to',
14
- TEKGRID_IN: 'is in',
15
- TEKGRID_NOT_IN: 'is not in',
16
- TEKGRID_BETWEEN: 'is between',
17
- TEKGRID_AND: 'and',
18
- TEKGRID_OR: 'or',
19
- TEKGRID_ADD: 'Add',
20
- TEKGRID_DELETE: 'Delete',
21
- TEKGRID_REFRESH: 'Refresh',
22
- TEKGRID_COLUMNS: 'Columns',
23
- TEKGRID_SAVE: 'Save',
24
- TEKGRID_CANCEL: 'Cancel',
25
- TEKGRID_FILTER: 'Filter',
26
- TEKGRID_MULTIPLE_VALUE_HINT: 'Separate values using ";"',
27
- TEKGRID_EXPORT: 'Export',
28
- TEKGRID_EXPORT_AS: 'Export as {{type}}',
29
- TEKGRID_COLUMN_VISIBLE: 'Visible',
30
- TEKGRID_COLUMN_GROUPED: 'Grouped',
31
- TEKGRID_COLUMN_AGGREGATION: 'Aggregation',
32
- TEKGRID_AGGREGATION_SUM: 'Sum',
33
- TEKGRID_AGGREGATION_AVG: 'Average',
34
- TEKGRID_AGGREGATION_MAX: 'Maximum',
35
- TEKGRID_AGGREGATION_MIN: 'Minimum',
36
- TEKGRID_AGGREGATION_COUNT: 'Count',
37
- NO_NOTIFICATIONS: 'No Notifications',
38
- MARK_ALL_AS_READ: 'Mark all as read',
39
- NOTIFICATIONS: 'Notifications',
40
- SEE_ALL_NOTIFICATIONS: 'See all notifications',
41
- UNAVAILABLE_IMAGE: 'Unavailable image',
42
- REFRESH: 'Refresh',
43
- ACTIONS: 'Actions',
44
- FILTER: 'Filter',
45
- LAYOUT: 'Layout: ',
46
- NEW_LAYOUT: 'New layout',
47
- DEFAULT_LAYOUT: 'Default',
48
- };
49
-
50
- const notImplemented = (name, isMethod = true) => {
51
- const member = isMethod ? `I18n.${name}() method` : `I18n.${name} property`;
52
- throw new Error(`The ${member} is not yet implemented/mocked by the mock in 'tests/__mocks__/@zeedhi/core/i18n.ts'.`);
53
- }
54
-
55
- const mock = {
56
- translate: (value, variables) => {
57
- let result = words[value] || value;
58
- const keys = variables ? Object.keys(variables) : undefined;
59
- if (keys) {
60
- keys.forEach((key) => {
61
- result = result.replace(`{{${key}}}`, variables[key]);
62
- });
63
- }
64
-
65
- return result;
66
- },
67
- registerChangeListener: () => notImplemented('registerChangeListener'),
68
- unregisterChangeListener: () => notImplemented('unregisterChangeListener'),
69
- init: () => notImplemented('init'),
70
- changeLanguage: () => notImplemented('changeLanguage'),
71
- get instance() { return { language: 'en-US'} },
72
- set instance(_value) { notImplemented('instance setter') },
73
- }
74
-
1
+ /**
2
+ * Mock for @zeedhi/core I18n API
3
+ */
4
+
5
+ const words = {
6
+ TEKGRID_CONTAINS: 'contains',
7
+ TEKGRID_NOT_CONTAINS: 'does not contain',
8
+ TEKGRID_EQUALS: 'is equal to',
9
+ TEKGRID_NOT_EQUALS: 'is different from',
10
+ TEKGRID_GREATER_THAN: 'is greater than',
11
+ TEKGRID_LESS_THAN: 'is less than',
12
+ TEKGRID_GREATER_THAN_EQUALS: 'is greater or equals to',
13
+ TEKGRID_LESS_THAN_EQUALS: 'is less or equals to',
14
+ TEKGRID_IN: 'is in',
15
+ TEKGRID_NOT_IN: 'is not in',
16
+ TEKGRID_BETWEEN: 'is between',
17
+ TEKGRID_AND: 'and',
18
+ TEKGRID_OR: 'or',
19
+ TEKGRID_ADD: 'Add',
20
+ TEKGRID_DELETE: 'Delete',
21
+ TEKGRID_REFRESH: 'Refresh',
22
+ TEKGRID_COLUMNS: 'Columns',
23
+ TEKGRID_SAVE: 'Save',
24
+ TEKGRID_CANCEL: 'Cancel',
25
+ TEKGRID_FILTER: 'Filter',
26
+ TEKGRID_MULTIPLE_VALUE_HINT: 'Separate values using ";"',
27
+ TEKGRID_EXPORT: 'Export',
28
+ TEKGRID_EXPORT_AS: 'Export as {{type}}',
29
+ TEKGRID_COLUMN_VISIBLE: 'Visible',
30
+ TEKGRID_COLUMN_GROUPED: 'Grouped',
31
+ TEKGRID_COLUMN_AGGREGATION: 'Aggregation',
32
+ TEKGRID_AGGREGATION_SUM: 'Sum',
33
+ TEKGRID_AGGREGATION_AVG: 'Average',
34
+ TEKGRID_AGGREGATION_MAX: 'Maximum',
35
+ TEKGRID_AGGREGATION_MIN: 'Minimum',
36
+ TEKGRID_AGGREGATION_COUNT: 'Count',
37
+ NO_NOTIFICATIONS: 'No Notifications',
38
+ MARK_ALL_AS_READ: 'Mark all as read',
39
+ NOTIFICATIONS: 'Notifications',
40
+ SEE_ALL_NOTIFICATIONS: 'See all notifications',
41
+ UNAVAILABLE_IMAGE: 'Unavailable image',
42
+ REFRESH: 'Refresh',
43
+ ACTIONS: 'Actions',
44
+ FILTER: 'Filter',
45
+ LAYOUT: 'Layout: ',
46
+ NEW_LAYOUT: 'New layout',
47
+ DEFAULT_LAYOUT: 'Default',
48
+ };
49
+
50
+ const notImplemented = (name, isMethod = true) => {
51
+ const member = isMethod ? `I18n.${name}() method` : `I18n.${name} property`;
52
+ throw new Error(`The ${member} is not yet implemented/mocked by the mock in 'tests/__mocks__/@zeedhi/core/i18n.ts'.`);
53
+ }
54
+
55
+ const mock = {
56
+ translate: (value, variables) => {
57
+ let result = words[value] || value;
58
+ const keys = variables ? Object.keys(variables) : undefined;
59
+ if (keys) {
60
+ keys.forEach((key) => {
61
+ result = result.replace(`{{${key}}}`, variables[key]);
62
+ });
63
+ }
64
+
65
+ return result;
66
+ },
67
+ registerChangeListener: () => notImplemented('registerChangeListener'),
68
+ unregisterChangeListener: () => notImplemented('unregisterChangeListener'),
69
+ init: () => notImplemented('init'),
70
+ changeLanguage: () => notImplemented('changeLanguage'),
71
+ get instance() { return { language: 'en-US'} },
72
+ set instance(_value) { notImplemented('instance setter') },
73
+ }
74
+
75
75
  module.exports = mock;
@@ -1,5 +1,5 @@
1
- const core = jest.requireActual('@zeedhi/core');
2
-
3
- core.I18n = require('./core/i18n');
4
-
1
+ const core = jest.requireActual('@zeedhi/core');
2
+
3
+ core.I18n = require('./core/i18n');
4
+
5
5
  module.exports = core;
@@ -1,56 +1,56 @@
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
+ 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 +1,94 @@
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: boolean = 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
+ 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: boolean = 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 +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
+ });