@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,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
+ });
@@ -1,165 +1,165 @@
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
+ 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
+ });