@hosterai/types 0.0.28 → 0.0.29
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/README.md +5 -1
- package/dist/decorators/all-or-none-validator.spec.js +9 -3
- package/dist/decorators/at-least-one-non-empty-validator.spec.js +1 -1
- package/dist/decorators/at-least-one-non-empty.validator.js +2 -2
- package/dist/decorators/is-of-allowed-types-validator.spec.js +10 -8
- package/dist/decorators/is-of-allowed-types.validator.js +4 -2
- package/dist/decorators/is-one-of.validator.d.ts +2 -2
- package/dist/decorators/is-one-of.validator.js +1 -1
- package/dist/decorators/is-plain-object.validator.d.ts +1 -1
- package/dist/decorators/is-plain-object.validator.js +3 -1
- package/dist/decorators/is-property-forbidden-validator.spec.js +12 -4
- package/dist/decorators/is-property-forbidden.validator.d.ts +1 -1
- package/dist/decorators/is-regex.validator.d.ts +1 -1
- package/dist/decorators/min-less-or-equal-validator.spec.js +6 -2
- package/dist/dtos/action.dto.js +5 -5
- package/dist/dtos/addon-field.dto.d.ts +1 -1
- package/dist/dtos/admin-panel.dto.js +16 -18
- package/dist/dtos/attribute-field.dto.d.ts +1 -1
- package/dist/dtos/client-panel.dto.d.ts +3 -3
- package/dist/dtos/client-panel.dto.js +11 -10
- package/dist/dtos/company-data.dto.d.ts +4 -0
- package/dist/dtos/company-data.dto.js +19 -8
- package/dist/dtos/error-response.dto.js +1 -4
- package/dist/dtos/field-option.dto.js +3 -3
- package/dist/dtos/info.dto.js +10 -10
- package/dist/dtos/invoice/invoice-info.dto.d.ts +3 -3
- package/dist/dtos/invoice/invoice-info.dto.js +1 -1
- package/dist/dtos/invoice/invoice-item-data.dto.d.ts +2 -2
- package/dist/dtos/invoice/requests/base-invoice-request.dto.d.ts +30 -0
- package/dist/dtos/invoice/requests/base-invoice-request.dto.js +108 -0
- package/dist/dtos/invoice/requests/credit-note-request.dto.d.ts +2 -2
- package/dist/dtos/invoice/requests/credit-note-request.dto.js +2 -2
- package/dist/dtos/invoice/requests/invoice-request.dto.d.ts +2 -2
- package/dist/dtos/invoice/requests/invoice-request.dto.js +2 -2
- package/dist/dtos/invoice/requests/proforma-invoice-request.dto.d.ts +2 -19
- package/dist/dtos/invoice/requests/proforma-invoice-request.dto.js +2 -95
- package/dist/dtos/invoice/responses/credit-note-response.dto.d.ts +1 -1
- package/dist/dtos/invoice/responses/invoice-response.dto.d.ts +1 -1
- package/dist/dtos/invoice/responses/tax-details-response.dto.js +1 -1
- package/dist/dtos/invoice-contact-data.dto.d.ts +2 -2
- package/dist/dtos/invoice-contact-data.dto.js +5 -5
- package/dist/dtos/menu.dto.js +8 -4
- package/dist/dtos/notification/responses/notification-send-response.dto.d.ts +1 -1
- package/dist/dtos/notification/sender/sender-sms.dto.js +1 -1
- package/dist/dtos/product/product-info.dto.js +11 -5
- package/dist/dtos/product/product-item-data.dto.d.ts +2 -2
- package/dist/dtos/product/requests/product-create-request.dto.js +1 -1
- package/dist/dtos/product/requests/product-delete-request.dto.js +3 -3
- package/dist/dtos/product/requests/product-downgradable-request.dto.js +1 -1
- package/dist/dtos/product/requests/product-downgrade-request.dto.js +1 -1
- package/dist/dtos/product/requests/product-renew-request.dto.js +1 -1
- package/dist/dtos/product/requests/product-suspend-request.dto.js +1 -1
- package/dist/dtos/product/requests/product-unsuspend-request.dto.js +1 -1
- package/dist/dtos/product/requests/product-upgradable-request.dto.js +1 -1
- package/dist/dtos/product/requests/product-upgrade-request.dto.js +1 -1
- package/dist/dtos/product/responses/product-info-response.dto.js +1 -1
- package/dist/dtos/responses/validate-attributes-response.dto.d.ts +2 -2
- package/dist/dtos/tab.dto.js +2 -2
- package/dist/dtos/tax-manager/tax-details-request.dto.d.ts +31 -0
- package/dist/dtos/tax-manager/tax-details-request.dto.js +84 -0
- package/dist/dtos/unit.dto.js +3 -3
- package/dist/enums/country.enum.d.ts +1 -1
- package/dist/enums/country.enum.js +312 -78
- package/dist/enums/currency.enum.d.ts +43 -0
- package/dist/enums/currency.enum.js +47 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/openapi/schemas/components.schemas.d.ts +0 -30
- package/dist/openapi/schemas/components.schemas.js +10 -40
- package/dist/validators/action-validator.spec.js +3 -3
- package/dist/validators/addon-field-validator.spec.js +10 -3
- package/dist/validators/admin-panel-more-actions-validator.spec.js +12 -8
- package/dist/validators/admin-panel-more-actions.validator.d.ts +1 -1
- package/dist/validators/admin-panel-tabs-validator.spec.js +74 -10
- package/dist/validators/admin-panel-tabs.validator.d.ts +1 -1
- package/dist/validators/admin-panel-validator.spec.js +164 -32
- package/dist/validators/attachment-validator.spec.js +8 -8
- package/dist/validators/attribute-field-validator.spec.js +18 -7
- package/dist/validators/client-panel-validator.spec.js +57 -9
- package/dist/validators/country-validator.spec.js +7 -7
- package/dist/validators/field-validator.spec.js +35 -10
- package/dist/validators/info-validator.spec.js +10 -10
- package/dist/validators/invoice-contact-data-validator.spec.js +18 -10
- package/dist/validators/invoice-info-validator.spec.js +14 -10
- package/dist/validators/invoice-item-data-validator.spec.js +4 -4
- package/dist/validators/item-data-validator.spec.js +17 -9
- package/dist/validators/menu-with-submenu-validator.spec.js +13 -11
- package/dist/validators/menu-with-url-validator.spec.js +15 -5
- package/dist/validators/notification-info-validator.spec.js +23 -15
- package/dist/validators/product-info-validator.spec.js +46 -32
- package/dist/validators/product-info.validator.d.ts +1 -1
- package/dist/validators/product-item-data-validator.spec.js +12 -4
- package/dist/validators/sender-sms-validator.spec.js +5 -2
- package/dist/validators/settings-with-tabs-validator.spec.js +176 -12
- package/dist/validators/settings-with-url-validator.spec.js +89 -11
- package/dist/validators/tab-validator.spec.js +7 -7
- package/dist/validators/tin-validation-details-validator.spec.js +8 -8
- package/dist/validators/transaction-data-validator.spec.js +13 -8
- package/dist/validators/unit-validator.spec.js +13 -4
- package/package.json +1 -1
|
@@ -11,12 +11,15 @@ describe('SmsSenderDto Validator', () => {
|
|
|
11
11
|
expect((0, sender_sms_validator_1.validateSmsSenderDto)(validDto)).toHaveLength(0);
|
|
12
12
|
});
|
|
13
13
|
it.each([
|
|
14
|
-
[
|
|
14
|
+
[
|
|
15
|
+
{ senderPhone: 'not-a-phone-number', message: 'Test Message' },
|
|
16
|
+
'senderPhone',
|
|
17
|
+
],
|
|
15
18
|
[{ senderPhone: '+11234567890' }, 'message'],
|
|
16
19
|
[{ message: 'Test Message' }, 'senderPhone'],
|
|
17
20
|
])('should return error for invalid %s', (dto, expectedProp) => {
|
|
18
21
|
const errors = (0, sender_sms_validator_1.validateSmsSenderDto)(dto);
|
|
19
22
|
expect(errors.length).toBeGreaterThan(0);
|
|
20
|
-
expect(errors.some(e => e.property === expectedProp)).toBe(true);
|
|
23
|
+
expect(errors.some((e) => e.property === expectedProp)).toBe(true);
|
|
21
24
|
});
|
|
22
25
|
});
|
|
@@ -5,24 +5,188 @@ const settings_with_tabs_validator_1 = require("./settings-with-tabs.validator")
|
|
|
5
5
|
describe('SettingsWithTabsDto', () => {
|
|
6
6
|
it.each([
|
|
7
7
|
// valid
|
|
8
|
-
[
|
|
8
|
+
[
|
|
9
|
+
{
|
|
10
|
+
tabs: [
|
|
11
|
+
{
|
|
12
|
+
label: 'Tab 1',
|
|
13
|
+
icon: 'https://icon.com',
|
|
14
|
+
description: 'Test',
|
|
15
|
+
url: 'https://valid.com',
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
label: 'Test',
|
|
19
|
+
icon: 'https://icon.com',
|
|
20
|
+
description: 'Test',
|
|
21
|
+
},
|
|
22
|
+
0,
|
|
23
|
+
],
|
|
9
24
|
// invalid URL
|
|
10
|
-
[
|
|
11
|
-
|
|
25
|
+
[
|
|
26
|
+
{
|
|
27
|
+
tabs: [
|
|
28
|
+
{
|
|
29
|
+
label: 'Tab 1',
|
|
30
|
+
icon: 'https://icon.com',
|
|
31
|
+
description: 'Test',
|
|
32
|
+
url: 'not-a-url',
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
label: 'Test',
|
|
36
|
+
icon: 'https://icon.com',
|
|
37
|
+
description: 'Test',
|
|
38
|
+
},
|
|
39
|
+
1,
|
|
40
|
+
],
|
|
41
|
+
[
|
|
42
|
+
{
|
|
43
|
+
tabs: [
|
|
44
|
+
{
|
|
45
|
+
label: 'Tab 1',
|
|
46
|
+
icon: 'https://icon.com',
|
|
47
|
+
description: 'Test',
|
|
48
|
+
url: 'ftp://wrongprotocol.com',
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
label: 'Test',
|
|
52
|
+
icon: 'https://icon.com',
|
|
53
|
+
description: 'Test',
|
|
54
|
+
},
|
|
55
|
+
1,
|
|
56
|
+
],
|
|
12
57
|
// missing URL
|
|
13
|
-
[
|
|
14
|
-
|
|
15
|
-
|
|
58
|
+
[
|
|
59
|
+
{
|
|
60
|
+
tabs: [
|
|
61
|
+
{ label: 'Tab 1', icon: 'https://icon.com', description: 'Test' },
|
|
62
|
+
],
|
|
63
|
+
label: 'Missing URL',
|
|
64
|
+
icon: 'https://icon.com',
|
|
65
|
+
description: 'Test',
|
|
66
|
+
},
|
|
67
|
+
1,
|
|
68
|
+
],
|
|
69
|
+
[
|
|
70
|
+
{
|
|
71
|
+
tabs: [
|
|
72
|
+
{ label: 'Tab 1', icon: 'https://icon.com', description: 'Test' },
|
|
73
|
+
],
|
|
74
|
+
label: 'Empty URL',
|
|
75
|
+
icon: 'https://icon.com',
|
|
76
|
+
description: 'Test',
|
|
77
|
+
},
|
|
78
|
+
1,
|
|
79
|
+
],
|
|
80
|
+
[
|
|
81
|
+
{
|
|
82
|
+
tabs: [
|
|
83
|
+
{ label: 'Tab 1', icon: 'https://icon.com', description: 'Test' },
|
|
84
|
+
],
|
|
85
|
+
label: 'Null URL',
|
|
86
|
+
icon: 'https://icon.com',
|
|
87
|
+
description: 'Test',
|
|
88
|
+
},
|
|
89
|
+
1,
|
|
90
|
+
],
|
|
16
91
|
// missing Name
|
|
17
|
-
[
|
|
18
|
-
|
|
19
|
-
|
|
92
|
+
[
|
|
93
|
+
{
|
|
94
|
+
tabs: [
|
|
95
|
+
{
|
|
96
|
+
label: 'Tab 1',
|
|
97
|
+
icon: 'https://icon.com',
|
|
98
|
+
description: 'Test',
|
|
99
|
+
url: 'https://valid.com',
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
icon: 'https://icon.com',
|
|
103
|
+
description: 'Test',
|
|
104
|
+
},
|
|
105
|
+
1,
|
|
106
|
+
],
|
|
107
|
+
[
|
|
108
|
+
{
|
|
109
|
+
tabs: [
|
|
110
|
+
{
|
|
111
|
+
label: 'Tab 1',
|
|
112
|
+
icon: 'https://icon.com',
|
|
113
|
+
description: 'Test',
|
|
114
|
+
url: 'https://valid.com',
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
label: '',
|
|
118
|
+
icon: 'https://icon.com',
|
|
119
|
+
description: 'Test',
|
|
120
|
+
},
|
|
121
|
+
1,
|
|
122
|
+
],
|
|
123
|
+
[
|
|
124
|
+
{
|
|
125
|
+
tabs: [
|
|
126
|
+
{
|
|
127
|
+
label: 'Tab 1',
|
|
128
|
+
icon: 'https://icon.com',
|
|
129
|
+
description: 'Test',
|
|
130
|
+
url: 'https://valid.com',
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
label: null,
|
|
134
|
+
icon: 'https://icon.com',
|
|
135
|
+
description: 'Test',
|
|
136
|
+
},
|
|
137
|
+
1,
|
|
138
|
+
],
|
|
20
139
|
// missing both link and icon
|
|
21
|
-
[
|
|
140
|
+
[
|
|
141
|
+
{
|
|
142
|
+
tabs: [
|
|
143
|
+
{
|
|
144
|
+
label: 'Tab 1',
|
|
145
|
+
icon: 'https://icon.com',
|
|
146
|
+
description: 'Test',
|
|
147
|
+
url: 'https://valid.com',
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
label: 'Missing URL',
|
|
151
|
+
description: 'Test',
|
|
152
|
+
},
|
|
153
|
+
1,
|
|
154
|
+
],
|
|
22
155
|
// null both
|
|
23
|
-
[
|
|
156
|
+
[
|
|
157
|
+
{
|
|
158
|
+
tabs: [
|
|
159
|
+
{
|
|
160
|
+
label: 'Tab 1',
|
|
161
|
+
icon: 'https://icon.com',
|
|
162
|
+
description: 'Test',
|
|
163
|
+
url: 'https://valid.com',
|
|
164
|
+
},
|
|
165
|
+
],
|
|
166
|
+
label: null,
|
|
167
|
+
icon: null,
|
|
168
|
+
description: 'Test',
|
|
169
|
+
},
|
|
170
|
+
2,
|
|
171
|
+
],
|
|
24
172
|
// extra unexpected field should still pass base validation?
|
|
25
|
-
[
|
|
173
|
+
[
|
|
174
|
+
{
|
|
175
|
+
tabs: [
|
|
176
|
+
{
|
|
177
|
+
label: 'Tab 1',
|
|
178
|
+
icon: 'https://icon.com',
|
|
179
|
+
description: 'Test',
|
|
180
|
+
url: 'https://valid.com',
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
label: 'Test',
|
|
184
|
+
icon: 'https://icon.com',
|
|
185
|
+
description: 'Test',
|
|
186
|
+
extra: 'field',
|
|
187
|
+
},
|
|
188
|
+
0,
|
|
189
|
+
],
|
|
26
190
|
])('validates %# -> %s errors', (input, expectedCount) => {
|
|
27
191
|
expect((0, settings_with_tabs_validator_1.validateSettingsWithTabsDto)(input)).toHaveLength(expectedCount);
|
|
28
192
|
});
|
|
@@ -5,24 +5,102 @@ const settings_with_url_validator_1 = require("./settings-with-url.validator");
|
|
|
5
5
|
describe('SettingsWithUrlDto', () => {
|
|
6
6
|
it.each([
|
|
7
7
|
// valid
|
|
8
|
-
[
|
|
8
|
+
[
|
|
9
|
+
{
|
|
10
|
+
url: 'https://valid.com',
|
|
11
|
+
label: 'Test',
|
|
12
|
+
icon: 'https://icon.com',
|
|
13
|
+
description: 'Test',
|
|
14
|
+
},
|
|
15
|
+
0,
|
|
16
|
+
],
|
|
9
17
|
// invalid URL
|
|
10
|
-
[
|
|
11
|
-
|
|
18
|
+
[
|
|
19
|
+
{
|
|
20
|
+
url: 'not-a-url',
|
|
21
|
+
label: 'Test',
|
|
22
|
+
icon: 'https://icon.com',
|
|
23
|
+
description: 'Test',
|
|
24
|
+
},
|
|
25
|
+
1,
|
|
26
|
+
],
|
|
27
|
+
[
|
|
28
|
+
{
|
|
29
|
+
url: 'ftp://wrongprotocol.com',
|
|
30
|
+
label: 'Test',
|
|
31
|
+
icon: 'https://icon.com',
|
|
32
|
+
description: 'Test',
|
|
33
|
+
},
|
|
34
|
+
1,
|
|
35
|
+
],
|
|
12
36
|
// missing URL
|
|
13
|
-
[
|
|
14
|
-
|
|
15
|
-
|
|
37
|
+
[
|
|
38
|
+
{ label: 'Missing URL', icon: 'https://icon.com', description: 'Test' },
|
|
39
|
+
1,
|
|
40
|
+
],
|
|
41
|
+
[
|
|
42
|
+
{
|
|
43
|
+
url: '',
|
|
44
|
+
label: 'Empty URL',
|
|
45
|
+
icon: 'https://icon.com',
|
|
46
|
+
description: 'Test',
|
|
47
|
+
},
|
|
48
|
+
1,
|
|
49
|
+
],
|
|
50
|
+
[
|
|
51
|
+
{
|
|
52
|
+
url: null,
|
|
53
|
+
label: 'Null URL',
|
|
54
|
+
icon: 'https://icon.com',
|
|
55
|
+
description: 'Test',
|
|
56
|
+
},
|
|
57
|
+
1,
|
|
58
|
+
],
|
|
16
59
|
// missing Name
|
|
17
|
-
[
|
|
18
|
-
|
|
19
|
-
|
|
60
|
+
[
|
|
61
|
+
{
|
|
62
|
+
url: 'https://valid.com',
|
|
63
|
+
icon: 'https://icon.com',
|
|
64
|
+
description: 'Test',
|
|
65
|
+
},
|
|
66
|
+
1,
|
|
67
|
+
],
|
|
68
|
+
[
|
|
69
|
+
{
|
|
70
|
+
url: 'https://valid.com',
|
|
71
|
+
label: '',
|
|
72
|
+
icon: 'https://icon.com',
|
|
73
|
+
description: 'Test',
|
|
74
|
+
},
|
|
75
|
+
1,
|
|
76
|
+
],
|
|
77
|
+
[
|
|
78
|
+
{
|
|
79
|
+
url: 'https://valid.com',
|
|
80
|
+
label: null,
|
|
81
|
+
icon: 'https://icon.com',
|
|
82
|
+
description: 'Test',
|
|
83
|
+
},
|
|
84
|
+
1,
|
|
85
|
+
],
|
|
20
86
|
// missing both link and icon
|
|
21
87
|
[{ label: 'Missing URL', description: 'Test' }, 2],
|
|
22
88
|
// null both
|
|
23
|
-
[
|
|
89
|
+
[
|
|
90
|
+
{ url: null, label: null, icon: 'https://icon.com', description: 'Test' },
|
|
91
|
+
2,
|
|
92
|
+
],
|
|
24
93
|
// extra unexpected field should still pass base validation?
|
|
25
|
-
[
|
|
94
|
+
[
|
|
95
|
+
{
|
|
96
|
+
url: 'https://valid.com',
|
|
97
|
+
label: 'Test',
|
|
98
|
+
icon: 'https://icon.com',
|
|
99
|
+
description: 'Test',
|
|
100
|
+
extra: 'field',
|
|
101
|
+
},
|
|
102
|
+
0,
|
|
103
|
+
],
|
|
26
104
|
])('validates %# -> %s errors', (input, expectedCount) => {
|
|
27
105
|
expect((0, settings_with_url_validator_1.validateSettingsWithUrlDto)(input)).toHaveLength(expectedCount);
|
|
28
106
|
});
|
|
@@ -15,35 +15,35 @@ describe('TabDto Validator', () => {
|
|
|
15
15
|
describe('Missing required fields', () => {
|
|
16
16
|
it('should return errors when all fields are missing', () => {
|
|
17
17
|
const errors = (0, tab_validator_1.validateTabDto)({});
|
|
18
|
-
expect(errors.some(e => e.property === 'label')).toBe(true);
|
|
19
|
-
expect(errors.some(e => e.property === 'url')).toBe(true);
|
|
18
|
+
expect(errors.some((e) => e.property === 'label')).toBe(true);
|
|
19
|
+
expect(errors.some((e) => e.property === 'url')).toBe(true);
|
|
20
20
|
});
|
|
21
21
|
it('should return error when label is missing', () => {
|
|
22
22
|
const dto = { url: 'https://example.com/settings' };
|
|
23
23
|
const errors = (0, tab_validator_1.validateTabDto)(dto);
|
|
24
|
-
expect(errors.some(e => e.property === 'label')).toBe(true);
|
|
24
|
+
expect(errors.some((e) => e.property === 'label')).toBe(true);
|
|
25
25
|
});
|
|
26
26
|
it('should return error when url is missing', () => {
|
|
27
27
|
const dto = { label: 'Settings' };
|
|
28
28
|
const errors = (0, tab_validator_1.validateTabDto)(dto);
|
|
29
|
-
expect(errors.some(e => e.property === 'url')).toBe(true);
|
|
29
|
+
expect(errors.some((e) => e.property === 'url')).toBe(true);
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
32
|
describe('Invalid field values', () => {
|
|
33
33
|
it('should return error for empty label', () => {
|
|
34
34
|
const dto = { ...baseValidDto, label: '' };
|
|
35
35
|
const errors = (0, tab_validator_1.validateTabDto)(dto);
|
|
36
|
-
expect(errors.some(e => e.property === 'label')).toBe(true);
|
|
36
|
+
expect(errors.some((e) => e.property === 'label')).toBe(true);
|
|
37
37
|
});
|
|
38
38
|
it('should return error for non-https URL', () => {
|
|
39
39
|
const dto = { ...baseValidDto, url: 'http://example.com/settings' };
|
|
40
40
|
const errors = (0, tab_validator_1.validateTabDto)(dto);
|
|
41
|
-
expect(errors.some(e => e.property === 'url')).toBe(true);
|
|
41
|
+
expect(errors.some((e) => e.property === 'url')).toBe(true);
|
|
42
42
|
});
|
|
43
43
|
it('should return error for invalid URL', () => {
|
|
44
44
|
const dto = { ...baseValidDto, url: 'not-a-url' };
|
|
45
45
|
const errors = (0, tab_validator_1.validateTabDto)(dto);
|
|
46
|
-
expect(errors.some(e => e.property === 'url')).toBe(true);
|
|
46
|
+
expect(errors.some((e) => e.property === 'url')).toBe(true);
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
49
|
});
|
|
@@ -33,45 +33,45 @@ describe('TINValidationDetails Validator', () => {
|
|
|
33
33
|
const errors = (0, tin_validation_details_validator_1.validateTINValidationDetailsDto)({});
|
|
34
34
|
const requiredProps = ['address1', 'postcode', 'city', 'country'];
|
|
35
35
|
for (const prop of requiredProps) {
|
|
36
|
-
expect(errors.some(e => e.property === prop)).toBe(true);
|
|
36
|
+
expect(errors.some((e) => e.property === prop)).toBe(true);
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
it('should return error when address1 is missing', () => {
|
|
40
40
|
const { address1, ...dto } = baseValidDto;
|
|
41
41
|
const errors = (0, tin_validation_details_validator_1.validateTINValidationDetailsDto)(dto);
|
|
42
|
-
expect(errors.some(e => e.property === 'address1')).toBe(true);
|
|
42
|
+
expect(errors.some((e) => e.property === 'address1')).toBe(true);
|
|
43
43
|
});
|
|
44
44
|
it('should return error when country is missing', () => {
|
|
45
45
|
const { country, ...dto } = baseValidDto;
|
|
46
46
|
const errors = (0, tin_validation_details_validator_1.validateTINValidationDetailsDto)(dto);
|
|
47
|
-
expect(errors.some(e => e.property === 'country')).toBe(true);
|
|
47
|
+
expect(errors.some((e) => e.property === 'country')).toBe(true);
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
50
|
describe('Invalid field values', () => {
|
|
51
51
|
it('should return error for invalid country code', () => {
|
|
52
52
|
const dto = { ...baseValidDto, country: 'INVALID' };
|
|
53
53
|
const errors = (0, tin_validation_details_validator_1.validateTINValidationDetailsDto)(dto);
|
|
54
|
-
expect(errors.some(e => e.property === 'country')).toBe(true);
|
|
54
|
+
expect(errors.some((e) => e.property === 'country')).toBe(true);
|
|
55
55
|
});
|
|
56
56
|
it('should return error for postcode exceeding max length', () => {
|
|
57
57
|
const dto = { ...baseValidDto, postcode: '1'.repeat(17) };
|
|
58
58
|
const errors = (0, tin_validation_details_validator_1.validateTINValidationDetailsDto)(dto);
|
|
59
|
-
expect(errors.some(e => e.property === 'postcode')).toBe(true);
|
|
59
|
+
expect(errors.some((e) => e.property === 'postcode')).toBe(true);
|
|
60
60
|
});
|
|
61
61
|
it('should return error for city exceeding max length', () => {
|
|
62
62
|
const dto = { ...baseValidDto, city: 'a'.repeat(251) };
|
|
63
63
|
const errors = (0, tin_validation_details_validator_1.validateTINValidationDetailsDto)(dto);
|
|
64
|
-
expect(errors.some(e => e.property === 'city')).toBe(true);
|
|
64
|
+
expect(errors.some((e) => e.property === 'city')).toBe(true);
|
|
65
65
|
});
|
|
66
66
|
it('should return error for companyName exceeding max length', () => {
|
|
67
67
|
const dto = { ...baseValidDto, companyName: 'a'.repeat(251) };
|
|
68
68
|
const errors = (0, tin_validation_details_validator_1.validateTINValidationDetailsDto)(dto);
|
|
69
|
-
expect(errors.some(e => e.property === 'companyName')).toBe(true);
|
|
69
|
+
expect(errors.some((e) => e.property === 'companyName')).toBe(true);
|
|
70
70
|
});
|
|
71
71
|
it('should return error for tin exceeding max length', () => {
|
|
72
72
|
const dto = { ...baseValidDto, tin: 'X'.repeat(21) };
|
|
73
73
|
const errors = (0, tin_validation_details_validator_1.validateTINValidationDetailsDto)(dto);
|
|
74
|
-
expect(errors.some(e => e.property === 'tin')).toBe(true);
|
|
74
|
+
expect(errors.some((e) => e.property === 'tin')).toBe(true);
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
77
|
});
|
|
@@ -21,42 +21,47 @@ describe('TransactionData Validator', () => {
|
|
|
21
21
|
describe('Missing required fields', () => {
|
|
22
22
|
it('should return errors when all fields are missing', () => {
|
|
23
23
|
const errors = (0, transaction_data_validator_1.validateTransactionDataDto)({});
|
|
24
|
-
const requiredProps = [
|
|
24
|
+
const requiredProps = [
|
|
25
|
+
'transactionId',
|
|
26
|
+
'amount',
|
|
27
|
+
'paymentMethod',
|
|
28
|
+
'date',
|
|
29
|
+
];
|
|
25
30
|
for (const prop of requiredProps) {
|
|
26
|
-
expect(errors.some(e => e.property === prop)).toBe(true);
|
|
31
|
+
expect(errors.some((e) => e.property === prop)).toBe(true);
|
|
27
32
|
}
|
|
28
33
|
});
|
|
29
34
|
it('should return error when transactionId is missing', () => {
|
|
30
35
|
const { transactionId, ...dto } = baseValidDto;
|
|
31
36
|
const errors = (0, transaction_data_validator_1.validateTransactionDataDto)(dto);
|
|
32
|
-
expect(errors.some(e => e.property === 'transactionId')).toBe(true);
|
|
37
|
+
expect(errors.some((e) => e.property === 'transactionId')).toBe(true);
|
|
33
38
|
});
|
|
34
39
|
it('should return error when amount is missing', () => {
|
|
35
40
|
const { amount, ...dto } = baseValidDto;
|
|
36
41
|
const errors = (0, transaction_data_validator_1.validateTransactionDataDto)(dto);
|
|
37
|
-
expect(errors.some(e => e.property === 'amount')).toBe(true);
|
|
42
|
+
expect(errors.some((e) => e.property === 'amount')).toBe(true);
|
|
38
43
|
});
|
|
39
44
|
});
|
|
40
45
|
describe('Invalid field values', () => {
|
|
41
46
|
it('should return error for empty transactionId', () => {
|
|
42
47
|
const dto = { ...baseValidDto, transactionId: '' };
|
|
43
48
|
const errors = (0, transaction_data_validator_1.validateTransactionDataDto)(dto);
|
|
44
|
-
expect(errors.some(e => e.property === 'transactionId')).toBe(true);
|
|
49
|
+
expect(errors.some((e) => e.property === 'transactionId')).toBe(true);
|
|
45
50
|
});
|
|
46
51
|
it('should return error for non-number amount', () => {
|
|
47
52
|
const dto = { ...baseValidDto, amount: 'free' };
|
|
48
53
|
const errors = (0, transaction_data_validator_1.validateTransactionDataDto)(dto);
|
|
49
|
-
expect(errors.some(e => e.property === 'amount')).toBe(true);
|
|
54
|
+
expect(errors.some((e) => e.property === 'amount')).toBe(true);
|
|
50
55
|
});
|
|
51
56
|
it('should return error for empty paymentMethod', () => {
|
|
52
57
|
const dto = { ...baseValidDto, paymentMethod: '' };
|
|
53
58
|
const errors = (0, transaction_data_validator_1.validateTransactionDataDto)(dto);
|
|
54
|
-
expect(errors.some(e => e.property === 'paymentMethod')).toBe(true);
|
|
59
|
+
expect(errors.some((e) => e.property === 'paymentMethod')).toBe(true);
|
|
55
60
|
});
|
|
56
61
|
it('should return error for invalid date', () => {
|
|
57
62
|
const dto = { ...baseValidDto, date: 'not-a-date' };
|
|
58
63
|
const errors = (0, transaction_data_validator_1.validateTransactionDataDto)(dto);
|
|
59
|
-
expect(errors.some(e => e.property === 'date')).toBe(true);
|
|
64
|
+
expect(errors.some((e) => e.property === 'date')).toBe(true);
|
|
60
65
|
});
|
|
61
66
|
});
|
|
62
67
|
});
|
|
@@ -16,12 +16,21 @@ describe('UnitDto Validator', () => {
|
|
|
16
16
|
[{ ...validDto, unitDescription: undefined }, 'unitDescription'],
|
|
17
17
|
[{ ...validDto, intervalDescription: undefined }, 'intervalDescription'],
|
|
18
18
|
[{ unitDescription: 'MB', intervalDescription: 'month' }, 'id'],
|
|
19
|
-
[
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
[
|
|
20
|
+
{ id: 6979466666, unitDescription: 'MB', intervalDescription: 'month' },
|
|
21
|
+
'id',
|
|
22
|
+
],
|
|
23
|
+
[
|
|
24
|
+
{ id: 'ram', unitDescription: 123, intervalDescription: 'month' },
|
|
25
|
+
'unitDescription',
|
|
26
|
+
],
|
|
27
|
+
[
|
|
28
|
+
{ id: 'ram', unitDescription: 'MB', intervalDescription: 123 },
|
|
29
|
+
'intervalDescription',
|
|
30
|
+
],
|
|
22
31
|
])('should return error for invalid %s', (dto, expectedErrorProp) => {
|
|
23
32
|
const errors = (0, unit_validator_1.validateUnitDto)(dto);
|
|
24
33
|
expect(errors.length).toBeGreaterThan(0);
|
|
25
|
-
expect(errors.some(e => e.property === expectedErrorProp)).toBe(true);
|
|
34
|
+
expect(errors.some((e) => e.property === expectedErrorProp)).toBe(true);
|
|
26
35
|
});
|
|
27
36
|
});
|