@hosterai/types 0.0.28 → 0.0.30
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.d.ts +2 -2
- package/dist/dtos/product/product-info.dto.js +12 -6
- package/dist/dtos/product/product-item-data.dto.d.ts +3 -3
- package/dist/dtos/product/product-item-data.dto.js +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/enums/item-actions.enum.d.ts +10 -10
- package/dist/enums/item-actions.enum.js +13 -14
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/openapi/schemas/components.schemas.d.ts +1 -31
- package/dist/openapi/schemas/components.schemas.js +19 -49
- 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 +28 -20
- package/dist/validators/product-info-validator.spec.js +59 -45
- package/dist/validators/product-info.validator.d.ts +1 -1
- package/dist/validators/product-item-data-validator.spec.js +15 -7
- 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
|
@@ -9,54 +9,54 @@ const product_info_validator_1 = require("./product-info.validator");
|
|
|
9
9
|
describe('ProductInfoDto Validator', () => {
|
|
10
10
|
const field = {
|
|
11
11
|
id: 'field',
|
|
12
|
-
label: [{ language: language_enum_1.LanguageEnum.ENGLISH, text:
|
|
12
|
+
label: [{ language: language_enum_1.LanguageEnum.ENGLISH, text: 'label' }],
|
|
13
13
|
value: 'string',
|
|
14
14
|
type: field_type_enum_1.FieldTypeEnum.TEXT_BOX,
|
|
15
15
|
required: false,
|
|
16
16
|
disabled: false,
|
|
17
17
|
hidden: false,
|
|
18
|
-
upgradable: false
|
|
18
|
+
upgradable: false,
|
|
19
19
|
};
|
|
20
20
|
const invalidField = {
|
|
21
21
|
id: 'field',
|
|
22
|
-
label: [{ language: language_enum_1.LanguageEnum.ENGLISH, text:
|
|
22
|
+
label: [{ language: language_enum_1.LanguageEnum.ENGLISH, text: 'label' }],
|
|
23
23
|
value: 'string',
|
|
24
24
|
type: field_type_enum_1.FieldTypeEnum.TEXT_BOX,
|
|
25
25
|
disabled: false,
|
|
26
|
-
upgradable: false
|
|
26
|
+
upgradable: false,
|
|
27
27
|
};
|
|
28
28
|
const testCases = [
|
|
29
29
|
{
|
|
30
30
|
description: 'should return no errors for valid DTO',
|
|
31
31
|
dto: {
|
|
32
32
|
title: 'Test',
|
|
33
|
-
supportedActions: [item_actions_enum_1.
|
|
33
|
+
supportedActions: [item_actions_enum_1.ProductActionsEnum.CREATE],
|
|
34
34
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
35
35
|
productAttributes: [field],
|
|
36
|
-
itemAttributes: [field]
|
|
36
|
+
itemAttributes: [field],
|
|
37
37
|
},
|
|
38
|
-
expectedErrorsLength: 0
|
|
38
|
+
expectedErrorsLength: 0,
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
41
|
description: 'should return error for invalid required and hidden',
|
|
42
42
|
dto: {
|
|
43
43
|
title: 'Test',
|
|
44
|
-
supportedActions: [item_actions_enum_1.
|
|
44
|
+
supportedActions: [item_actions_enum_1.ProductActionsEnum.CREATE],
|
|
45
45
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
46
|
-
itemAttributes: [invalidField]
|
|
46
|
+
itemAttributes: [invalidField],
|
|
47
47
|
},
|
|
48
|
-
expectedErrorsLength: 1
|
|
48
|
+
expectedErrorsLength: 1,
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
description: 'should return error for invalid title',
|
|
52
52
|
dto: {
|
|
53
53
|
title: '',
|
|
54
|
-
supportedActions: [item_actions_enum_1.
|
|
54
|
+
supportedActions: [item_actions_enum_1.ProductActionsEnum.CREATE],
|
|
55
55
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
56
56
|
productAttributes: [field],
|
|
57
|
-
itemAttributes: [field]
|
|
57
|
+
itemAttributes: [field],
|
|
58
58
|
},
|
|
59
|
-
expectedErrorsLength: 1
|
|
59
|
+
expectedErrorsLength: 1,
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
62
|
description: 'should return error for unsupported action',
|
|
@@ -65,71 +65,85 @@ describe('ProductInfoDto Validator', () => {
|
|
|
65
65
|
supportedActions: ['update'],
|
|
66
66
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
67
67
|
productAttributes: [field],
|
|
68
|
-
itemAttributes: [field]
|
|
68
|
+
itemAttributes: [field],
|
|
69
69
|
},
|
|
70
|
-
expectedErrorsLength: 1
|
|
70
|
+
expectedErrorsLength: 1,
|
|
71
71
|
},
|
|
72
72
|
{
|
|
73
73
|
description: 'should return error for unsupported language',
|
|
74
74
|
dto: {
|
|
75
75
|
title: 'Test',
|
|
76
|
-
supportedActions: [item_actions_enum_1.
|
|
76
|
+
supportedActions: [item_actions_enum_1.ProductActionsEnum.CREATE],
|
|
77
77
|
supportedLanguages: [],
|
|
78
78
|
productAttributes: [field],
|
|
79
|
-
itemAttributes: [field]
|
|
79
|
+
itemAttributes: [field],
|
|
80
80
|
},
|
|
81
|
-
expectedErrorsLength: 1
|
|
81
|
+
expectedErrorsLength: 1,
|
|
82
82
|
},
|
|
83
83
|
{
|
|
84
84
|
description: 'should return no errors for valid DTO with adminPanel and clientPanel',
|
|
85
85
|
dto: {
|
|
86
86
|
title: 'Test',
|
|
87
|
-
supportedActions: [item_actions_enum_1.
|
|
87
|
+
supportedActions: [item_actions_enum_1.ProductActionsEnum.CREATE],
|
|
88
88
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
89
89
|
productAttributes: [field],
|
|
90
90
|
itemAttributes: [field],
|
|
91
|
-
adminPanel: {
|
|
92
|
-
|
|
91
|
+
adminPanel: {
|
|
92
|
+
tabs: {
|
|
93
|
+
product: [{ label: 'Product', url: 'https://example.com/product' }],
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
clientPanel: {
|
|
97
|
+
tabs: { item: [{ label: 'Item', url: 'https://example.com/item' }] },
|
|
98
|
+
},
|
|
93
99
|
},
|
|
94
|
-
expectedErrorsLength: 0
|
|
100
|
+
expectedErrorsLength: 0,
|
|
95
101
|
},
|
|
96
102
|
{
|
|
97
103
|
description: 'should return error for invalid DTO with adminPanel and clientPanel',
|
|
98
104
|
dto: {
|
|
99
105
|
title: '',
|
|
100
|
-
supportedActions: [item_actions_enum_1.
|
|
106
|
+
supportedActions: [item_actions_enum_1.ProductActionsEnum.CREATE],
|
|
101
107
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
102
108
|
productAttributes: [field],
|
|
103
109
|
itemAttributes: [field],
|
|
104
|
-
adminPanel: {
|
|
105
|
-
|
|
110
|
+
adminPanel: {
|
|
111
|
+
/* invalid admin panel data */
|
|
112
|
+
},
|
|
113
|
+
clientPanel: {
|
|
114
|
+
/* invalid client panel data */
|
|
115
|
+
},
|
|
106
116
|
},
|
|
107
|
-
expectedErrorsLength: 3
|
|
117
|
+
expectedErrorsLength: 3,
|
|
108
118
|
},
|
|
109
119
|
{
|
|
110
120
|
description: 'should return no errors for valid DTO with payPerUseUnits',
|
|
111
121
|
dto: {
|
|
112
122
|
title: 'Test',
|
|
113
|
-
supportedActions: [item_actions_enum_1.
|
|
123
|
+
supportedActions: [item_actions_enum_1.ProductActionsEnum.CREATE],
|
|
114
124
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
115
125
|
productAttributes: [field],
|
|
116
126
|
itemAttributes: [field],
|
|
117
|
-
payPerUseUnits: [
|
|
127
|
+
payPerUseUnits: [
|
|
128
|
+
{ id: 'ram', unitDescription: 'MB', intervalDescription: 'month' },
|
|
129
|
+
],
|
|
118
130
|
},
|
|
119
|
-
expectedErrorsLength: 0
|
|
131
|
+
expectedErrorsLength: 0,
|
|
120
132
|
},
|
|
121
133
|
{
|
|
122
134
|
description: 'should return error for invalid DTO with payPerUseUnits',
|
|
123
135
|
dto: {
|
|
124
136
|
title: 'Test',
|
|
125
|
-
supportedActions: [item_actions_enum_1.
|
|
137
|
+
supportedActions: [item_actions_enum_1.ProductActionsEnum.CREATE],
|
|
126
138
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
127
139
|
productAttributes: [field],
|
|
128
140
|
itemAttributes: [field],
|
|
129
|
-
payPerUseUnits: [
|
|
141
|
+
payPerUseUnits: [
|
|
142
|
+
{ id: '', unitDescription: '', intervalDescription: '' },
|
|
143
|
+
],
|
|
130
144
|
},
|
|
131
|
-
expectedErrorsLength: 1
|
|
132
|
-
}
|
|
145
|
+
expectedErrorsLength: 1,
|
|
146
|
+
},
|
|
133
147
|
];
|
|
134
148
|
testCases.forEach(({ description, dto, expectedErrorsLength }) => {
|
|
135
149
|
it(description, () => {
|
|
@@ -141,12 +155,12 @@ describe('ProductInfoDto Validator', () => {
|
|
|
141
155
|
{
|
|
142
156
|
description: 'should return ValidationError for missing title',
|
|
143
157
|
dto: {
|
|
144
|
-
supportedActions: [item_actions_enum_1.
|
|
158
|
+
supportedActions: [item_actions_enum_1.ProductActionsEnum.CREATE],
|
|
145
159
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
146
160
|
productAttributes: [field],
|
|
147
|
-
itemAttributes: [field]
|
|
161
|
+
itemAttributes: [field],
|
|
148
162
|
},
|
|
149
|
-
expectedErrors: ['title']
|
|
163
|
+
expectedErrors: ['title'],
|
|
150
164
|
},
|
|
151
165
|
{
|
|
152
166
|
description: 'should return ValidationError for unsupported action',
|
|
@@ -155,16 +169,16 @@ describe('ProductInfoDto Validator', () => {
|
|
|
155
169
|
supportedActions: ['update'],
|
|
156
170
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
157
171
|
productAttributes: [field],
|
|
158
|
-
itemAttributes: [field]
|
|
172
|
+
itemAttributes: [field],
|
|
159
173
|
},
|
|
160
|
-
expectedErrors: ['supportedActions']
|
|
161
|
-
}
|
|
174
|
+
expectedErrors: ['supportedActions'],
|
|
175
|
+
},
|
|
162
176
|
];
|
|
163
177
|
validationErrorTestCases.forEach(({ description, dto, expectedErrors }) => {
|
|
164
178
|
it(description, async () => {
|
|
165
179
|
const errors = await (0, product_info_validator_1.validateProductInfoDto)(dto);
|
|
166
|
-
const errorProperties = errors.map(error => error.property);
|
|
167
|
-
expectedErrors.forEach(expectedError => {
|
|
180
|
+
const errorProperties = errors.map((error) => error.property);
|
|
181
|
+
expectedErrors.forEach((expectedError) => {
|
|
168
182
|
expect(errorProperties).toContain(expectedError);
|
|
169
183
|
});
|
|
170
184
|
});
|
|
@@ -184,7 +198,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
184
198
|
};
|
|
185
199
|
const dto = {
|
|
186
200
|
title: 'Test',
|
|
187
|
-
supportedActions: [item_actions_enum_1.
|
|
201
|
+
supportedActions: [item_actions_enum_1.ProductActionsEnum.CREATE],
|
|
188
202
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
189
203
|
productAttributes: [fieldWithOnlyMin],
|
|
190
204
|
};
|
|
@@ -205,7 +219,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
205
219
|
};
|
|
206
220
|
const dto = {
|
|
207
221
|
title: 'Test',
|
|
208
|
-
supportedActions: [item_actions_enum_1.
|
|
222
|
+
supportedActions: [item_actions_enum_1.ProductActionsEnum.CREATE],
|
|
209
223
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
210
224
|
itemAttributes: [fieldWithOnlyMax],
|
|
211
225
|
};
|
|
@@ -224,7 +238,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
224
238
|
};
|
|
225
239
|
const dto = {
|
|
226
240
|
title: 'Test',
|
|
227
|
-
supportedActions: [item_actions_enum_1.
|
|
241
|
+
supportedActions: [item_actions_enum_1.ProductActionsEnum.CREATE],
|
|
228
242
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
229
243
|
productAttributes: [fieldOk],
|
|
230
244
|
};
|
|
@@ -245,7 +259,7 @@ describe('ProductInfoDto Validator', () => {
|
|
|
245
259
|
};
|
|
246
260
|
const dto = {
|
|
247
261
|
title: 'Test',
|
|
248
|
-
supportedActions: [item_actions_enum_1.
|
|
262
|
+
supportedActions: [item_actions_enum_1.ProductActionsEnum.CREATE],
|
|
249
263
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
250
264
|
itemAttributes: [fieldBad],
|
|
251
265
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ValidationError } from
|
|
1
|
+
import { ValidationError } from 'class-validator';
|
|
2
2
|
export declare function validateProductInfoDto(data: object): ValidationError[];
|
|
@@ -18,10 +18,10 @@ describe('ProductItemDataDto Validator', () => {
|
|
|
18
18
|
expect((0, product_item_data_validator_1.validateProductItemDataDto)(baseValidDto)).toHaveLength(0);
|
|
19
19
|
});
|
|
20
20
|
it('should return no errors with a valid action', () => {
|
|
21
|
-
const dto = { ...baseValidDto, action: item_actions_enum_1.
|
|
21
|
+
const dto = { ...baseValidDto, action: item_actions_enum_1.ProductActionsEnum.CREATE };
|
|
22
22
|
expect((0, product_item_data_validator_1.validateProductItemDataDto)(dto)).toHaveLength(0);
|
|
23
23
|
});
|
|
24
|
-
it.each(Object.values(item_actions_enum_1.
|
|
24
|
+
it.each(Object.values(item_actions_enum_1.ProductActionsEnum))('should accept action %s', (action) => {
|
|
25
25
|
const dto = { ...baseValidDto, action };
|
|
26
26
|
expect((0, product_item_data_validator_1.validateProductItemDataDto)(dto)).toHaveLength(0);
|
|
27
27
|
});
|
|
@@ -31,7 +31,7 @@ describe('ProductItemDataDto Validator', () => {
|
|
|
31
31
|
itemId: 'item-456',
|
|
32
32
|
price: 9.99,
|
|
33
33
|
discountPrice: 7.99,
|
|
34
|
-
action: item_actions_enum_1.
|
|
34
|
+
action: item_actions_enum_1.ProductActionsEnum.RENEW,
|
|
35
35
|
};
|
|
36
36
|
expect((0, product_item_data_validator_1.validateProductItemDataDto)(dto)).toHaveLength(0);
|
|
37
37
|
});
|
|
@@ -39,9 +39,17 @@ describe('ProductItemDataDto Validator', () => {
|
|
|
39
39
|
describe('Missing inherited required fields', () => {
|
|
40
40
|
it('should return errors when all fields are missing', () => {
|
|
41
41
|
const errors = (0, product_item_data_validator_1.validateProductItemDataDto)({});
|
|
42
|
-
const requiredProps = [
|
|
42
|
+
const requiredProps = [
|
|
43
|
+
'productId',
|
|
44
|
+
'productName',
|
|
45
|
+
'resourceName',
|
|
46
|
+
'productAttributes',
|
|
47
|
+
'itemAttributes',
|
|
48
|
+
'startDate',
|
|
49
|
+
'endDate',
|
|
50
|
+
];
|
|
43
51
|
for (const prop of requiredProps) {
|
|
44
|
-
expect(errors.some(e => e.property === prop)).toBe(true);
|
|
52
|
+
expect(errors.some((e) => e.property === prop)).toBe(true);
|
|
45
53
|
}
|
|
46
54
|
});
|
|
47
55
|
});
|
|
@@ -49,12 +57,12 @@ describe('ProductItemDataDto Validator', () => {
|
|
|
49
57
|
it('should return error for invalid action enum', () => {
|
|
50
58
|
const dto = { ...baseValidDto, action: 'invalid-action' };
|
|
51
59
|
const errors = (0, product_item_data_validator_1.validateProductItemDataDto)(dto);
|
|
52
|
-
expect(errors.some(e => e.property === 'action')).toBe(true);
|
|
60
|
+
expect(errors.some((e) => e.property === 'action')).toBe(true);
|
|
53
61
|
});
|
|
54
62
|
it('should return error for non-string action', () => {
|
|
55
63
|
const dto = { ...baseValidDto, action: 123 };
|
|
56
64
|
const errors = (0, product_item_data_validator_1.validateProductItemDataDto)(dto);
|
|
57
|
-
expect(errors.some(e => e.property === 'action')).toBe(true);
|
|
65
|
+
expect(errors.some((e) => e.property === 'action')).toBe(true);
|
|
58
66
|
});
|
|
59
67
|
});
|
|
60
68
|
});
|
|
@@ -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
|
});
|