@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.
- package/LICENSE +21 -21
- package/README.md +7 -7
- package/coverage/clover.xml +772 -692
- package/coverage/coverage-final.json +47 -47
- package/coverage/lcov-report/index.html +15 -15
- package/coverage/lcov-report/tests/__helpers__/component-event-helper.ts.html +2 -2
- package/coverage/lcov-report/tests/__helpers__/flush-promises-helper.ts.html +2 -2
- package/coverage/lcov-report/tests/__helpers__/get-child-helper.ts.html +7 -7
- package/coverage/lcov-report/tests/__helpers__/index.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/index.ts.html +1 -1
- package/coverage/lcov-report/tests/__helpers__/mock-created-helper.ts.html +1 -1
- package/coverage/lcov.info +1459 -1275
- package/dist/tek-components-common.esm.js +375 -252
- package/dist/tek-components-common.umd.js +375 -252
- package/jest.config.js +1 -1
- package/package.json +2 -2
- package/tests/__helpers__/component-event-helper.ts +5 -5
- package/tests/__helpers__/flush-promises-helper.ts +3 -3
- package/tests/__helpers__/get-child-helper.ts +27 -27
- package/tests/__helpers__/index.ts +3 -3
- package/tests/__helpers__/mock-created-helper.ts +12 -12
- package/tests/__mocks__/@zeedhi/core/i18n.js +74 -74
- package/tests/__mocks__/@zeedhi/core.js +4 -4
- package/tests/unit/components/crud/crud-add-button.spec.ts +56 -56
- package/tests/unit/components/crud/crud-button.spec.ts +94 -94
- package/tests/unit/components/crud/crud-cancel-button.spec.ts +91 -91
- package/tests/unit/components/crud/crud-delete-button.spec.ts +122 -122
- package/tests/unit/components/crud/crud-form.spec.ts +165 -165
- package/tests/unit/components/crud/crud-save-button.spec.ts +118 -118
- package/tests/unit/components/tek-breadcrumb-header/tek-breadcrumb-header.spec.ts +42 -42
- package/tests/unit/components/tek-card-title/CardTitle.spec.ts +34 -34
- package/tests/unit/components/tek-datasource/memory-datasource.spec.ts +470 -470
- package/tests/unit/components/tek-datasource/rest-datasource.spec.ts +364 -364
- package/tests/unit/components/tek-drag-grid/tek-drag-grid.spec.ts +112 -112
- package/tests/unit/components/tek-grid/filter-helper.spec.ts +148 -148
- package/tests/unit/components/tek-grid/grid-column.spec.ts +270 -270
- package/tests/unit/components/tek-grid/grid-columns-button.spec.ts +195 -195
- package/tests/unit/components/tek-grid/grid-filter-button.spec.ts +967 -967
- package/tests/unit/components/tek-grid/grid.spec.ts +3340 -3116
- package/tests/unit/components/tek-grid/layout_options.spec.ts +980 -980
- package/tests/unit/components/tek-image/Image.spec.ts +67 -67
- package/tests/unit/components/tek-iterable-carousel/iterable-carousel.spec.ts +37 -37
- package/tests/unit/components/tek-iterable-component-render/iterable-component-render.spec.ts +200 -200
- package/tests/unit/components/tek-loading/Loading.spec.ts +30 -30
- package/tests/unit/components/tek-notifications/notifications.spec.ts +201 -201
- package/tests/unit/components/tek-product-card/product-card.spec.ts +61 -61
- package/tests/unit/components/tek-user-info/TekUserInfoContoller.spec.ts +220 -220
- package/tests/unit/components/tek-user-info/tek-user-info-list.spec.ts +86 -86
- package/tests/unit/components/tek-user-info/tek-user-info.spec.ts +430 -430
- package/tests/unit/components/tree-grid/tree-grid.spec.ts +776 -776
- package/tests/unit/utils/grid-base/delete-rows-error.spec.ts +24 -0
- package/tests/unit/utils/grid-base/export-options/button-option.spec.ts +44 -44
- package/tests/unit/utils/grid-base/export-options/multi-option.spec.ts +135 -135
- package/tests/unit/utils/grid-base/grid-controller.spec.ts +267 -174
- package/tests/unit/utils/report-filter/report-filter.spec.ts +66 -66
- package/tsconfig.eslint.json +8 -8
- package/types/components/tek-datasource/memory-datasource.d.ts +2 -4
- package/types/components/tek-datasource/rest-datasource.d.ts +6 -3
- package/types/components/tek-grid/grid.d.ts +50 -6
- package/types/components/tek-grid/interfaces.d.ts +5 -3
- package/types/components/tek-tree-grid/tree-grid.d.ts +5 -1
- package/types/utils/grid-base/grid-base.d.ts +12 -229
- package/types/utils/grid-base/grid-controller.d.ts +1 -3
- package/types/components/tek-ag-grid/default-icons.d.ts +0 -53
- package/types/components/tek-ag-grid/interfaces.d.ts +0 -9
- package/types/components/tek-ag-grid/tek-ag-grid.d.ts +0 -35
- package/types/components/tek-datasource/datasource.d.ts +0 -94
- package/types/components/tek-grid/default-icons.d.ts +0 -53
- package/types/components/tek-grid/filter-dynamic-values.d.ts +0 -9
- package/types/components/tek-grid/grid-controller.d.ts +0 -19
- package/types/components/tek-grid/grid_column.d.ts +0 -14
- package/types/components/tek-grid/grid_controller.d.ts +0 -15
- package/types/components/tek-grid/tek-grid.d.ts +0 -35
- package/types/components/tek-login/interfaces.d.ts +0 -3
- package/types/components/tek-login/login-children.d.ts +0 -3
- package/types/components/tek-login/login.d.ts +0 -58
- package/types/components/tek-login/login_children.d.ts +0 -3
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
import { Image } from '../../../../src';
|
|
2
|
-
|
|
3
|
-
describe('Image', () => {
|
|
4
|
-
describe('constructor()', () => {
|
|
5
|
-
it('should create new Image with default values', () => {
|
|
6
|
-
const instance = new Image({
|
|
7
|
-
name: 'image',
|
|
8
|
-
component: 'Image',
|
|
9
|
-
});
|
|
10
|
-
expect(instance.src).toBe('');
|
|
11
|
-
expect(instance.to).toBe('');
|
|
12
|
-
expect(instance.height).toBe('auto');
|
|
13
|
-
expect(instance.minHeight).toBe('auto');
|
|
14
|
-
expect(instance.maxHeight).toBe('none');
|
|
15
|
-
expect(instance.fillHeight).toBeFalsy();
|
|
16
|
-
expect(instance.width).toBe('auto');
|
|
17
|
-
expect(instance.minWidth).toBe('auto');
|
|
18
|
-
expect(instance.maxWidth).toBe('none');
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('should create new image replacing default values', () => {
|
|
22
|
-
const instance = new Image({
|
|
23
|
-
name: 'image',
|
|
24
|
-
component: 'Image',
|
|
25
|
-
src: '/img/zeedhi.svg',
|
|
26
|
-
to: 'google.com.br',
|
|
27
|
-
height: '400px',
|
|
28
|
-
maxHeight: '500px',
|
|
29
|
-
minHeight: '500px',
|
|
30
|
-
width: '400px',
|
|
31
|
-
maxWidth: '500px',
|
|
32
|
-
minWidth: '500px',
|
|
33
|
-
fillHeight: true,
|
|
34
|
-
});
|
|
35
|
-
expect(instance.src).toBe('/img/zeedhi.svg');
|
|
36
|
-
expect(instance.to).toBe('google.com.br');
|
|
37
|
-
expect(instance.height).toBe('400px');
|
|
38
|
-
expect(instance.maxHeight).toBe('500px');
|
|
39
|
-
expect(instance.minHeight).toBe('500px');
|
|
40
|
-
expect(instance.width).toBe('400px');
|
|
41
|
-
expect(instance.maxWidth).toBe('500px');
|
|
42
|
-
expect(instance.minWidth).toBe('500px');
|
|
43
|
-
expect(instance.fillHeight).toBeTruthy();
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
describe('load event', () => {
|
|
48
|
-
it('should call load event', () => {
|
|
49
|
-
const load = jest.fn();
|
|
50
|
-
const instance = new Image({
|
|
51
|
-
name: 'image',
|
|
52
|
-
component: 'TekImage',
|
|
53
|
-
events: {
|
|
54
|
-
load,
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
const event = {} as Event;
|
|
59
|
-
const element = {} as HTMLElement;
|
|
60
|
-
instance.load(event, element);
|
|
61
|
-
|
|
62
|
-
expect(load).toHaveBeenCalledWith({
|
|
63
|
-
event, element, component: instance,
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
});
|
|
1
|
+
import { Image } from '../../../../src';
|
|
2
|
+
|
|
3
|
+
describe('Image', () => {
|
|
4
|
+
describe('constructor()', () => {
|
|
5
|
+
it('should create new Image with default values', () => {
|
|
6
|
+
const instance = new Image({
|
|
7
|
+
name: 'image',
|
|
8
|
+
component: 'Image',
|
|
9
|
+
});
|
|
10
|
+
expect(instance.src).toBe('');
|
|
11
|
+
expect(instance.to).toBe('');
|
|
12
|
+
expect(instance.height).toBe('auto');
|
|
13
|
+
expect(instance.minHeight).toBe('auto');
|
|
14
|
+
expect(instance.maxHeight).toBe('none');
|
|
15
|
+
expect(instance.fillHeight).toBeFalsy();
|
|
16
|
+
expect(instance.width).toBe('auto');
|
|
17
|
+
expect(instance.minWidth).toBe('auto');
|
|
18
|
+
expect(instance.maxWidth).toBe('none');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should create new image replacing default values', () => {
|
|
22
|
+
const instance = new Image({
|
|
23
|
+
name: 'image',
|
|
24
|
+
component: 'Image',
|
|
25
|
+
src: '/img/zeedhi.svg',
|
|
26
|
+
to: 'google.com.br',
|
|
27
|
+
height: '400px',
|
|
28
|
+
maxHeight: '500px',
|
|
29
|
+
minHeight: '500px',
|
|
30
|
+
width: '400px',
|
|
31
|
+
maxWidth: '500px',
|
|
32
|
+
minWidth: '500px',
|
|
33
|
+
fillHeight: true,
|
|
34
|
+
});
|
|
35
|
+
expect(instance.src).toBe('/img/zeedhi.svg');
|
|
36
|
+
expect(instance.to).toBe('google.com.br');
|
|
37
|
+
expect(instance.height).toBe('400px');
|
|
38
|
+
expect(instance.maxHeight).toBe('500px');
|
|
39
|
+
expect(instance.minHeight).toBe('500px');
|
|
40
|
+
expect(instance.width).toBe('400px');
|
|
41
|
+
expect(instance.maxWidth).toBe('500px');
|
|
42
|
+
expect(instance.minWidth).toBe('500px');
|
|
43
|
+
expect(instance.fillHeight).toBeTruthy();
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe('load event', () => {
|
|
48
|
+
it('should call load event', () => {
|
|
49
|
+
const load = jest.fn();
|
|
50
|
+
const instance = new Image({
|
|
51
|
+
name: 'image',
|
|
52
|
+
component: 'TekImage',
|
|
53
|
+
events: {
|
|
54
|
+
load,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const event = {} as Event;
|
|
59
|
+
const element = {} as HTMLElement;
|
|
60
|
+
instance.load(event, element);
|
|
61
|
+
|
|
62
|
+
expect(load).toHaveBeenCalledWith({
|
|
63
|
+
event, element, component: instance,
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { IterableComponentRender } from '@zeedhi/common';
|
|
2
|
-
import { IterableCarousel } from '../../../../src';
|
|
3
|
-
|
|
4
|
-
describe('IterableCarousel', () => {
|
|
5
|
-
describe('constructor()', () => {
|
|
6
|
-
it('should create new IterableCarousel with default values', () => {
|
|
7
|
-
const instance = new IterableCarousel({
|
|
8
|
-
name: 'iterable',
|
|
9
|
-
component: 'TekIterableCarousel',
|
|
10
|
-
});
|
|
11
|
-
expect(instance.iterable).toBeInstanceOf(IterableComponentRender);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('should create new IterableCarousel replace default values', () => {
|
|
15
|
-
const instance = new IterableCarousel({
|
|
16
|
-
name: 'iterable',
|
|
17
|
-
component: 'TekIterableCarousel',
|
|
18
|
-
iterable: {
|
|
19
|
-
cssClass: 'test',
|
|
20
|
-
},
|
|
21
|
-
children: [],
|
|
22
|
-
});
|
|
23
|
-
expect(instance.iterable.cssClass).toBe('test');
|
|
24
|
-
expect(instance.children).toEqual([]);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('Throw error', () => {
|
|
28
|
-
const instance = new IterableCarousel({
|
|
29
|
-
name: 'iterable',
|
|
30
|
-
component: 'TekIterableCarousel',
|
|
31
|
-
});
|
|
32
|
-
expect(() => {
|
|
33
|
-
instance.children = [{ name: 'childrenItem', component: 'Text' }];
|
|
34
|
-
}).toThrow('You should not change children when using IterableCarousel');
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
});
|
|
1
|
+
import { IterableComponentRender } from '@zeedhi/common';
|
|
2
|
+
import { IterableCarousel } from '../../../../src';
|
|
3
|
+
|
|
4
|
+
describe('IterableCarousel', () => {
|
|
5
|
+
describe('constructor()', () => {
|
|
6
|
+
it('should create new IterableCarousel with default values', () => {
|
|
7
|
+
const instance = new IterableCarousel({
|
|
8
|
+
name: 'iterable',
|
|
9
|
+
component: 'TekIterableCarousel',
|
|
10
|
+
});
|
|
11
|
+
expect(instance.iterable).toBeInstanceOf(IterableComponentRender);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('should create new IterableCarousel replace default values', () => {
|
|
15
|
+
const instance = new IterableCarousel({
|
|
16
|
+
name: 'iterable',
|
|
17
|
+
component: 'TekIterableCarousel',
|
|
18
|
+
iterable: {
|
|
19
|
+
cssClass: 'test',
|
|
20
|
+
},
|
|
21
|
+
children: [],
|
|
22
|
+
});
|
|
23
|
+
expect(instance.iterable.cssClass).toBe('test');
|
|
24
|
+
expect(instance.children).toEqual([]);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('Throw error', () => {
|
|
28
|
+
const instance = new IterableCarousel({
|
|
29
|
+
name: 'iterable',
|
|
30
|
+
component: 'TekIterableCarousel',
|
|
31
|
+
});
|
|
32
|
+
expect(() => {
|
|
33
|
+
instance.children = [{ name: 'childrenItem', component: 'Text' }];
|
|
34
|
+
}).toThrow('You should not change children when using IterableCarousel');
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
package/tests/unit/components/tek-iterable-component-render/iterable-component-render.spec.ts
CHANGED
|
@@ -1,200 +1,200 @@
|
|
|
1
|
-
import { IterableComponentRender } from '@zeedhi/common';
|
|
2
|
-
|
|
3
|
-
describe('IterableComponentRender', () => {
|
|
4
|
-
describe('constructor()', () => {
|
|
5
|
-
it('should create new IterableComponentRender with default values', () => {
|
|
6
|
-
const instance = new IterableComponentRender({
|
|
7
|
-
name: 'IterableComponent',
|
|
8
|
-
component: 'TekIterableComponentRender',
|
|
9
|
-
});
|
|
10
|
-
expect(instance.rowPropName).toBe('row');
|
|
11
|
-
expect(instance.componentMetadata).toEqual(undefined);
|
|
12
|
-
expect(instance.footerSlot).toEqual([]);
|
|
13
|
-
expect(instance.toolbarSlot).toEqual([]);
|
|
14
|
-
expect(instance.errorSlot).toEqual([]);
|
|
15
|
-
expect(instance.noDataSlot).toEqual([{
|
|
16
|
-
name: 'IterableComponent_no-data',
|
|
17
|
-
component: 'ZdText',
|
|
18
|
-
cssClass: 'no-data',
|
|
19
|
-
text: 'NO_DATA',
|
|
20
|
-
}]);
|
|
21
|
-
expect(instance.noResultSlot).toEqual([
|
|
22
|
-
{
|
|
23
|
-
name: 'IterableComponent_no-result',
|
|
24
|
-
component: 'ZdText',
|
|
25
|
-
cssClass: 'no-result',
|
|
26
|
-
text: 'NO_RESULT',
|
|
27
|
-
},
|
|
28
|
-
]);
|
|
29
|
-
expect(instance.height).toBe('auto');
|
|
30
|
-
expect(instance.maxHeight).toBe('none');
|
|
31
|
-
expect(instance.minHeight).toBe('auto');
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('should create new IterableComponentRender replacing default values', () => {
|
|
35
|
-
const instance = new IterableComponentRender({
|
|
36
|
-
name: 'IterableComponent',
|
|
37
|
-
component: 'TekIterableComponentRender',
|
|
38
|
-
rowPropName: 'div',
|
|
39
|
-
noDataSlot: [{
|
|
40
|
-
name: 'noData',
|
|
41
|
-
component: 'ZdText',
|
|
42
|
-
cssClass: 'noData',
|
|
43
|
-
text: 'Sem dados',
|
|
44
|
-
}],
|
|
45
|
-
noResultSlot: [{
|
|
46
|
-
name: 'noResult',
|
|
47
|
-
component: 'ZdText',
|
|
48
|
-
cssClass: 'noResult',
|
|
49
|
-
text: 'Sem resultado',
|
|
50
|
-
}],
|
|
51
|
-
errorSlot: [{
|
|
52
|
-
name: 'error',
|
|
53
|
-
component: 'ZdText',
|
|
54
|
-
cssClass: 'error',
|
|
55
|
-
text: 'Error',
|
|
56
|
-
}],
|
|
57
|
-
toolbarSlot: [{
|
|
58
|
-
name: 'toolbar',
|
|
59
|
-
component: 'ZdText',
|
|
60
|
-
text: 'toolbar',
|
|
61
|
-
}],
|
|
62
|
-
footerSlot: [{
|
|
63
|
-
name: 'footer',
|
|
64
|
-
component: 'ZdText',
|
|
65
|
-
text: 'footer',
|
|
66
|
-
}],
|
|
67
|
-
height: '400px',
|
|
68
|
-
minHeight: '300px',
|
|
69
|
-
maxHeight: '500px',
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
expect(instance.height).toBe('400px');
|
|
73
|
-
expect(instance.minHeight).toBe('300px');
|
|
74
|
-
expect(instance.maxHeight).toBe('500px');
|
|
75
|
-
expect(instance.rowPropName).toBe('div');
|
|
76
|
-
expect(instance.componentMetadata).toStrictEqual(undefined);
|
|
77
|
-
expect(instance.footerSlot).toEqual([
|
|
78
|
-
{
|
|
79
|
-
name: 'footer',
|
|
80
|
-
component: 'ZdText',
|
|
81
|
-
text: 'footer',
|
|
82
|
-
},
|
|
83
|
-
]);
|
|
84
|
-
expect(instance.toolbarSlot).toEqual([
|
|
85
|
-
{
|
|
86
|
-
name: 'toolbar',
|
|
87
|
-
component: 'ZdText',
|
|
88
|
-
text: 'toolbar',
|
|
89
|
-
},
|
|
90
|
-
]);
|
|
91
|
-
expect(instance.errorSlot).toEqual([
|
|
92
|
-
{
|
|
93
|
-
name: 'error',
|
|
94
|
-
component: 'ZdText',
|
|
95
|
-
cssClass: 'error',
|
|
96
|
-
text: 'Error',
|
|
97
|
-
},
|
|
98
|
-
]);
|
|
99
|
-
expect(instance.noDataSlot).toEqual([
|
|
100
|
-
{
|
|
101
|
-
name: 'noData',
|
|
102
|
-
component: 'ZdText',
|
|
103
|
-
cssClass: 'noData',
|
|
104
|
-
text: 'Sem dados',
|
|
105
|
-
},
|
|
106
|
-
]);
|
|
107
|
-
expect(instance.noResultSlot).toEqual([
|
|
108
|
-
{
|
|
109
|
-
name: 'noResult',
|
|
110
|
-
component: 'ZdText',
|
|
111
|
-
cssClass: 'noResult',
|
|
112
|
-
text: 'Sem resultado',
|
|
113
|
-
},
|
|
114
|
-
]);
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
describe('getComponentMetaData()', () => {
|
|
119
|
-
it('call getComponentMetaData()', () => {
|
|
120
|
-
const instance = new IterableComponentRender({
|
|
121
|
-
name: 'IterableComponent',
|
|
122
|
-
component: 'TekIterableComponentRender',
|
|
123
|
-
datasource: {
|
|
124
|
-
uniqueKey: 'id',
|
|
125
|
-
data: [{ id: 'id1', name: 'Item 1' }],
|
|
126
|
-
},
|
|
127
|
-
componentMetadata: {
|
|
128
|
-
name: 'name-<<row.id>>',
|
|
129
|
-
component: 'Col',
|
|
130
|
-
children: [
|
|
131
|
-
{
|
|
132
|
-
name: 'name-<<row.id>>-button',
|
|
133
|
-
component: 'Button',
|
|
134
|
-
label: '<<row.name>>-button',
|
|
135
|
-
value: '<<row.value>>',
|
|
136
|
-
},
|
|
137
|
-
],
|
|
138
|
-
},
|
|
139
|
-
});
|
|
140
|
-
expect(instance.getComponentMetadata({ id: 'id1', name: 'Item 1', value: true })).toEqual({
|
|
141
|
-
name: 'name-id1',
|
|
142
|
-
component: 'Col',
|
|
143
|
-
children: [
|
|
144
|
-
{
|
|
145
|
-
name: 'name-id1-button',
|
|
146
|
-
component: 'Button',
|
|
147
|
-
label: 'Item 1-button',
|
|
148
|
-
value: true,
|
|
149
|
-
},
|
|
150
|
-
],
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
describe('addSlashes()', () => {
|
|
156
|
-
it('add regexp slashes', () => {
|
|
157
|
-
const instance = new IterableComponentRender({
|
|
158
|
-
name: 'IterableComponent',
|
|
159
|
-
component: 'TekIterableComponentRender',
|
|
160
|
-
componentMetadata: {
|
|
161
|
-
name: 'name-<<row.id>>',
|
|
162
|
-
component: 'Col',
|
|
163
|
-
children: [
|
|
164
|
-
{
|
|
165
|
-
name: 'name-<<row.id>>-button',
|
|
166
|
-
component: 'Button',
|
|
167
|
-
label: '<<row.name>>',
|
|
168
|
-
},
|
|
169
|
-
],
|
|
170
|
-
},
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
const metadata1: any = instance.getComponentMetadata({ id: 'id1', name: 'It \t em \n 1' });
|
|
174
|
-
expect(metadata1).toEqual({
|
|
175
|
-
name: 'name-id1',
|
|
176
|
-
component: 'Col',
|
|
177
|
-
children: [
|
|
178
|
-
{
|
|
179
|
-
name: 'name-id1-button',
|
|
180
|
-
component: 'Button',
|
|
181
|
-
label: 'It \t em \n 1',
|
|
182
|
-
},
|
|
183
|
-
],
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
const metadata2: any = instance.getComponentMetadata({ id: 'id2', name: 'It \r em \f \x22 2' });
|
|
187
|
-
expect(metadata2).toEqual({
|
|
188
|
-
name: 'name-id2',
|
|
189
|
-
component: 'Col',
|
|
190
|
-
children: [
|
|
191
|
-
{
|
|
192
|
-
name: 'name-id2-button',
|
|
193
|
-
component: 'Button',
|
|
194
|
-
label: 'It \r em \f \x22 2',
|
|
195
|
-
},
|
|
196
|
-
],
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
});
|
|
1
|
+
import { IterableComponentRender } from '@zeedhi/common';
|
|
2
|
+
|
|
3
|
+
describe('IterableComponentRender', () => {
|
|
4
|
+
describe('constructor()', () => {
|
|
5
|
+
it('should create new IterableComponentRender with default values', () => {
|
|
6
|
+
const instance = new IterableComponentRender({
|
|
7
|
+
name: 'IterableComponent',
|
|
8
|
+
component: 'TekIterableComponentRender',
|
|
9
|
+
});
|
|
10
|
+
expect(instance.rowPropName).toBe('row');
|
|
11
|
+
expect(instance.componentMetadata).toEqual(undefined);
|
|
12
|
+
expect(instance.footerSlot).toEqual([]);
|
|
13
|
+
expect(instance.toolbarSlot).toEqual([]);
|
|
14
|
+
expect(instance.errorSlot).toEqual([]);
|
|
15
|
+
expect(instance.noDataSlot).toEqual([{
|
|
16
|
+
name: 'IterableComponent_no-data',
|
|
17
|
+
component: 'ZdText',
|
|
18
|
+
cssClass: 'no-data',
|
|
19
|
+
text: 'NO_DATA',
|
|
20
|
+
}]);
|
|
21
|
+
expect(instance.noResultSlot).toEqual([
|
|
22
|
+
{
|
|
23
|
+
name: 'IterableComponent_no-result',
|
|
24
|
+
component: 'ZdText',
|
|
25
|
+
cssClass: 'no-result',
|
|
26
|
+
text: 'NO_RESULT',
|
|
27
|
+
},
|
|
28
|
+
]);
|
|
29
|
+
expect(instance.height).toBe('auto');
|
|
30
|
+
expect(instance.maxHeight).toBe('none');
|
|
31
|
+
expect(instance.minHeight).toBe('auto');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should create new IterableComponentRender replacing default values', () => {
|
|
35
|
+
const instance = new IterableComponentRender({
|
|
36
|
+
name: 'IterableComponent',
|
|
37
|
+
component: 'TekIterableComponentRender',
|
|
38
|
+
rowPropName: 'div',
|
|
39
|
+
noDataSlot: [{
|
|
40
|
+
name: 'noData',
|
|
41
|
+
component: 'ZdText',
|
|
42
|
+
cssClass: 'noData',
|
|
43
|
+
text: 'Sem dados',
|
|
44
|
+
}],
|
|
45
|
+
noResultSlot: [{
|
|
46
|
+
name: 'noResult',
|
|
47
|
+
component: 'ZdText',
|
|
48
|
+
cssClass: 'noResult',
|
|
49
|
+
text: 'Sem resultado',
|
|
50
|
+
}],
|
|
51
|
+
errorSlot: [{
|
|
52
|
+
name: 'error',
|
|
53
|
+
component: 'ZdText',
|
|
54
|
+
cssClass: 'error',
|
|
55
|
+
text: 'Error',
|
|
56
|
+
}],
|
|
57
|
+
toolbarSlot: [{
|
|
58
|
+
name: 'toolbar',
|
|
59
|
+
component: 'ZdText',
|
|
60
|
+
text: 'toolbar',
|
|
61
|
+
}],
|
|
62
|
+
footerSlot: [{
|
|
63
|
+
name: 'footer',
|
|
64
|
+
component: 'ZdText',
|
|
65
|
+
text: 'footer',
|
|
66
|
+
}],
|
|
67
|
+
height: '400px',
|
|
68
|
+
minHeight: '300px',
|
|
69
|
+
maxHeight: '500px',
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
expect(instance.height).toBe('400px');
|
|
73
|
+
expect(instance.minHeight).toBe('300px');
|
|
74
|
+
expect(instance.maxHeight).toBe('500px');
|
|
75
|
+
expect(instance.rowPropName).toBe('div');
|
|
76
|
+
expect(instance.componentMetadata).toStrictEqual(undefined);
|
|
77
|
+
expect(instance.footerSlot).toEqual([
|
|
78
|
+
{
|
|
79
|
+
name: 'footer',
|
|
80
|
+
component: 'ZdText',
|
|
81
|
+
text: 'footer',
|
|
82
|
+
},
|
|
83
|
+
]);
|
|
84
|
+
expect(instance.toolbarSlot).toEqual([
|
|
85
|
+
{
|
|
86
|
+
name: 'toolbar',
|
|
87
|
+
component: 'ZdText',
|
|
88
|
+
text: 'toolbar',
|
|
89
|
+
},
|
|
90
|
+
]);
|
|
91
|
+
expect(instance.errorSlot).toEqual([
|
|
92
|
+
{
|
|
93
|
+
name: 'error',
|
|
94
|
+
component: 'ZdText',
|
|
95
|
+
cssClass: 'error',
|
|
96
|
+
text: 'Error',
|
|
97
|
+
},
|
|
98
|
+
]);
|
|
99
|
+
expect(instance.noDataSlot).toEqual([
|
|
100
|
+
{
|
|
101
|
+
name: 'noData',
|
|
102
|
+
component: 'ZdText',
|
|
103
|
+
cssClass: 'noData',
|
|
104
|
+
text: 'Sem dados',
|
|
105
|
+
},
|
|
106
|
+
]);
|
|
107
|
+
expect(instance.noResultSlot).toEqual([
|
|
108
|
+
{
|
|
109
|
+
name: 'noResult',
|
|
110
|
+
component: 'ZdText',
|
|
111
|
+
cssClass: 'noResult',
|
|
112
|
+
text: 'Sem resultado',
|
|
113
|
+
},
|
|
114
|
+
]);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
describe('getComponentMetaData()', () => {
|
|
119
|
+
it('call getComponentMetaData()', () => {
|
|
120
|
+
const instance = new IterableComponentRender({
|
|
121
|
+
name: 'IterableComponent',
|
|
122
|
+
component: 'TekIterableComponentRender',
|
|
123
|
+
datasource: {
|
|
124
|
+
uniqueKey: 'id',
|
|
125
|
+
data: [{ id: 'id1', name: 'Item 1' }],
|
|
126
|
+
},
|
|
127
|
+
componentMetadata: {
|
|
128
|
+
name: 'name-<<row.id>>',
|
|
129
|
+
component: 'Col',
|
|
130
|
+
children: [
|
|
131
|
+
{
|
|
132
|
+
name: 'name-<<row.id>>-button',
|
|
133
|
+
component: 'Button',
|
|
134
|
+
label: '<<row.name>>-button',
|
|
135
|
+
value: '<<row.value>>',
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
expect(instance.getComponentMetadata({ id: 'id1', name: 'Item 1', value: true })).toEqual({
|
|
141
|
+
name: 'name-id1',
|
|
142
|
+
component: 'Col',
|
|
143
|
+
children: [
|
|
144
|
+
{
|
|
145
|
+
name: 'name-id1-button',
|
|
146
|
+
component: 'Button',
|
|
147
|
+
label: 'Item 1-button',
|
|
148
|
+
value: true,
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
describe('addSlashes()', () => {
|
|
156
|
+
it('add regexp slashes', () => {
|
|
157
|
+
const instance = new IterableComponentRender({
|
|
158
|
+
name: 'IterableComponent',
|
|
159
|
+
component: 'TekIterableComponentRender',
|
|
160
|
+
componentMetadata: {
|
|
161
|
+
name: 'name-<<row.id>>',
|
|
162
|
+
component: 'Col',
|
|
163
|
+
children: [
|
|
164
|
+
{
|
|
165
|
+
name: 'name-<<row.id>>-button',
|
|
166
|
+
component: 'Button',
|
|
167
|
+
label: '<<row.name>>',
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
},
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
const metadata1: any = instance.getComponentMetadata({ id: 'id1', name: 'It \t em \n 1' });
|
|
174
|
+
expect(metadata1).toEqual({
|
|
175
|
+
name: 'name-id1',
|
|
176
|
+
component: 'Col',
|
|
177
|
+
children: [
|
|
178
|
+
{
|
|
179
|
+
name: 'name-id1-button',
|
|
180
|
+
component: 'Button',
|
|
181
|
+
label: 'It \t em \n 1',
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
const metadata2: any = instance.getComponentMetadata({ id: 'id2', name: 'It \r em \f \x22 2' });
|
|
187
|
+
expect(metadata2).toEqual({
|
|
188
|
+
name: 'name-id2',
|
|
189
|
+
component: 'Col',
|
|
190
|
+
children: [
|
|
191
|
+
{
|
|
192
|
+
name: 'name-id2-button',
|
|
193
|
+
component: 'Button',
|
|
194
|
+
label: 'It \r em \f \x22 2',
|
|
195
|
+
},
|
|
196
|
+
],
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
});
|