@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
|
@@ -40,49 +40,57 @@ describe('InvoiceContactData Validator', () => {
|
|
|
40
40
|
it('should return errors when all fields are missing', () => {
|
|
41
41
|
const errors = (0, invoice_contact_data_validator_1.validateInvoiceContactDataDto)({});
|
|
42
42
|
const requiredProps = [
|
|
43
|
-
'invoiceContactId',
|
|
44
|
-
'
|
|
43
|
+
'invoiceContactId',
|
|
44
|
+
'isBusinessContact',
|
|
45
|
+
'firstName',
|
|
46
|
+
'lastName',
|
|
47
|
+
'email',
|
|
48
|
+
'telephone',
|
|
49
|
+
'address1',
|
|
50
|
+
'postcode',
|
|
51
|
+
'city',
|
|
52
|
+
'country',
|
|
45
53
|
];
|
|
46
54
|
for (const prop of requiredProps) {
|
|
47
|
-
expect(errors.some(e => e.property === prop)).toBe(true);
|
|
55
|
+
expect(errors.some((e) => e.property === prop)).toBe(true);
|
|
48
56
|
}
|
|
49
57
|
});
|
|
50
58
|
it('should return error when invoiceContactId is missing', () => {
|
|
51
59
|
const { invoiceContactId, ...dto } = baseValidDto;
|
|
52
60
|
const errors = (0, invoice_contact_data_validator_1.validateInvoiceContactDataDto)(dto);
|
|
53
|
-
expect(errors.some(e => e.property === 'invoiceContactId')).toBe(true);
|
|
61
|
+
expect(errors.some((e) => e.property === 'invoiceContactId')).toBe(true);
|
|
54
62
|
});
|
|
55
63
|
});
|
|
56
64
|
describe('Invalid field values', () => {
|
|
57
65
|
it('should return error for invalid email', () => {
|
|
58
66
|
const dto = { ...baseValidDto, email: 'not-an-email' };
|
|
59
67
|
const errors = (0, invoice_contact_data_validator_1.validateInvoiceContactDataDto)(dto);
|
|
60
|
-
expect(errors.some(e => e.property === 'email')).toBe(true);
|
|
68
|
+
expect(errors.some((e) => e.property === 'email')).toBe(true);
|
|
61
69
|
});
|
|
62
70
|
it('should return error for invalid telephone', () => {
|
|
63
71
|
const dto = { ...baseValidDto, telephone: '123' };
|
|
64
72
|
const errors = (0, invoice_contact_data_validator_1.validateInvoiceContactDataDto)(dto);
|
|
65
|
-
expect(errors.some(e => e.property === 'telephone')).toBe(true);
|
|
73
|
+
expect(errors.some((e) => e.property === 'telephone')).toBe(true);
|
|
66
74
|
});
|
|
67
75
|
it('should return error for invalid country code', () => {
|
|
68
76
|
const dto = { ...baseValidDto, country: 'INVALID' };
|
|
69
77
|
const errors = (0, invoice_contact_data_validator_1.validateInvoiceContactDataDto)(dto);
|
|
70
|
-
expect(errors.some(e => e.property === 'country')).toBe(true);
|
|
78
|
+
expect(errors.some((e) => e.property === 'country')).toBe(true);
|
|
71
79
|
});
|
|
72
80
|
it('should return error for address1 exceeding max length', () => {
|
|
73
81
|
const dto = { ...baseValidDto, address1: 'a'.repeat(251) };
|
|
74
82
|
const errors = (0, invoice_contact_data_validator_1.validateInvoiceContactDataDto)(dto);
|
|
75
|
-
expect(errors.some(e => e.property === 'address1')).toBe(true);
|
|
83
|
+
expect(errors.some((e) => e.property === 'address1')).toBe(true);
|
|
76
84
|
});
|
|
77
85
|
it('should return error for postcode exceeding max length', () => {
|
|
78
86
|
const dto = { ...baseValidDto, postcode: '1'.repeat(17) };
|
|
79
87
|
const errors = (0, invoice_contact_data_validator_1.validateInvoiceContactDataDto)(dto);
|
|
80
|
-
expect(errors.some(e => e.property === 'postcode')).toBe(true);
|
|
88
|
+
expect(errors.some((e) => e.property === 'postcode')).toBe(true);
|
|
81
89
|
});
|
|
82
90
|
it('should return error for invalid mobile phone', () => {
|
|
83
91
|
const dto = { ...baseValidDto, mobile: 'not-a-phone' };
|
|
84
92
|
const errors = (0, invoice_contact_data_validator_1.validateInvoiceContactDataDto)(dto);
|
|
85
|
-
expect(errors.some(e => e.property === 'mobile')).toBe(true);
|
|
93
|
+
expect(errors.some((e) => e.property === 'mobile')).toBe(true);
|
|
86
94
|
});
|
|
87
95
|
});
|
|
88
96
|
});
|
|
@@ -20,7 +20,11 @@ describe('InvoiceInfoDto Validator', () => {
|
|
|
20
20
|
it('should return no errors with all supported types', () => {
|
|
21
21
|
const dto = {
|
|
22
22
|
...baseValidDto,
|
|
23
|
-
supportedTypes: [
|
|
23
|
+
supportedTypes: [
|
|
24
|
+
invoice_types_enum_1.InvoiceTypesEnum.INVOICE,
|
|
25
|
+
invoice_types_enum_1.InvoiceTypesEnum.CREDIT_NOTE,
|
|
26
|
+
invoice_types_enum_1.InvoiceTypesEnum.PROFORMA,
|
|
27
|
+
],
|
|
24
28
|
};
|
|
25
29
|
expect((0, invoice_info_validator_1.validateInvoiceInfoDto)(dto)).toHaveLength(0);
|
|
26
30
|
});
|
|
@@ -37,45 +41,45 @@ describe('InvoiceInfoDto Validator', () => {
|
|
|
37
41
|
describe('Missing required fields', () => {
|
|
38
42
|
it('should return errors when all fields are missing', () => {
|
|
39
43
|
const errors = (0, invoice_info_validator_1.validateInvoiceInfoDto)({});
|
|
40
|
-
expect(errors.some(e => e.property === 'title')).toBe(true);
|
|
41
|
-
expect(errors.some(e => e.property === 'supportedLanguages')).toBe(true);
|
|
44
|
+
expect(errors.some((e) => e.property === 'title')).toBe(true);
|
|
45
|
+
expect(errors.some((e) => e.property === 'supportedLanguages')).toBe(true);
|
|
42
46
|
});
|
|
43
47
|
it('should return error when title is missing', () => {
|
|
44
48
|
const { title, ...dto } = baseValidDto;
|
|
45
49
|
const errors = (0, invoice_info_validator_1.validateInvoiceInfoDto)(dto);
|
|
46
|
-
expect(errors.some(e => e.property === 'title')).toBe(true);
|
|
50
|
+
expect(errors.some((e) => e.property === 'title')).toBe(true);
|
|
47
51
|
});
|
|
48
52
|
it('should return error when supportedLanguages is missing', () => {
|
|
49
53
|
const { supportedLanguages, ...dto } = baseValidDto;
|
|
50
54
|
const errors = (0, invoice_info_validator_1.validateInvoiceInfoDto)(dto);
|
|
51
|
-
expect(errors.some(e => e.property === 'supportedLanguages')).toBe(true);
|
|
55
|
+
expect(errors.some((e) => e.property === 'supportedLanguages')).toBe(true);
|
|
52
56
|
});
|
|
53
57
|
});
|
|
54
58
|
describe('Invalid field values', () => {
|
|
55
59
|
it('should return error for invalid supportedTypes enum', () => {
|
|
56
60
|
const dto = { ...baseValidDto, supportedTypes: ['invalid-type'] };
|
|
57
61
|
const errors = (0, invoice_info_validator_1.validateInvoiceInfoDto)(dto);
|
|
58
|
-
expect(errors.some(e => e.property === 'supportedTypes')).toBe(true);
|
|
62
|
+
expect(errors.some((e) => e.property === 'supportedTypes')).toBe(true);
|
|
59
63
|
});
|
|
60
64
|
it('should return error for empty title', () => {
|
|
61
65
|
const dto = { ...baseValidDto, title: '' };
|
|
62
66
|
const errors = (0, invoice_info_validator_1.validateInvoiceInfoDto)(dto);
|
|
63
|
-
expect(errors.some(e => e.property === 'title')).toBe(true);
|
|
67
|
+
expect(errors.some((e) => e.property === 'title')).toBe(true);
|
|
64
68
|
});
|
|
65
69
|
it('should return error for empty supportedLanguages array', () => {
|
|
66
70
|
const dto = { ...baseValidDto, supportedLanguages: [] };
|
|
67
71
|
const errors = (0, invoice_info_validator_1.validateInvoiceInfoDto)(dto);
|
|
68
|
-
expect(errors.some(e => e.property === 'supportedLanguages')).toBe(true);
|
|
72
|
+
expect(errors.some((e) => e.property === 'supportedLanguages')).toBe(true);
|
|
69
73
|
});
|
|
70
74
|
it('should return error for invalid language enum', () => {
|
|
71
75
|
const dto = { ...baseValidDto, supportedLanguages: ['INVALID'] };
|
|
72
76
|
const errors = (0, invoice_info_validator_1.validateInvoiceInfoDto)(dto);
|
|
73
|
-
expect(errors.some(e => e.property === 'supportedLanguages')).toBe(true);
|
|
77
|
+
expect(errors.some((e) => e.property === 'supportedLanguages')).toBe(true);
|
|
74
78
|
});
|
|
75
79
|
it('should return error for invalid logo URL', () => {
|
|
76
80
|
const dto = { ...baseValidDto, logo: 'not-a-url' };
|
|
77
81
|
const errors = (0, invoice_info_validator_1.validateInvoiceInfoDto)(dto);
|
|
78
|
-
expect(errors.some(e => e.property === 'logo')).toBe(true);
|
|
82
|
+
expect(errors.some((e) => e.property === 'logo')).toBe(true);
|
|
79
83
|
});
|
|
80
84
|
});
|
|
81
85
|
});
|
|
@@ -27,19 +27,19 @@ describe('InvoiceItemDataDto Validator', () => {
|
|
|
27
27
|
it('should return error when action is missing', () => {
|
|
28
28
|
const { action, ...dto } = baseValidDto;
|
|
29
29
|
const errors = (0, invoice_item_data_validator_1.validateInvoiceItemDataDto)(dto);
|
|
30
|
-
expect(errors.some(e => e.property === 'action')).toBe(true);
|
|
30
|
+
expect(errors.some((e) => e.property === 'action')).toBe(true);
|
|
31
31
|
});
|
|
32
32
|
it('should return errors for inherited required fields when missing', () => {
|
|
33
33
|
const errors = (0, invoice_item_data_validator_1.validateInvoiceItemDataDto)({});
|
|
34
|
-
expect(errors.some(e => e.property === 'action')).toBe(true);
|
|
35
|
-
expect(errors.some(e => e.property === 'productId')).toBe(true);
|
|
34
|
+
expect(errors.some((e) => e.property === 'action')).toBe(true);
|
|
35
|
+
expect(errors.some((e) => e.property === 'productId')).toBe(true);
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
38
|
describe('Invalid field values', () => {
|
|
39
39
|
it('should return error for invalid action enum', () => {
|
|
40
40
|
const dto = { ...baseValidDto, action: 'invalid-action' };
|
|
41
41
|
const errors = (0, invoice_item_data_validator_1.validateInvoiceItemDataDto)(dto);
|
|
42
|
-
expect(errors.some(e => e.property === 'action')).toBe(true);
|
|
42
|
+
expect(errors.some((e) => e.property === 'action')).toBe(true);
|
|
43
43
|
});
|
|
44
44
|
});
|
|
45
45
|
});
|
|
@@ -33,47 +33,55 @@ describe('ItemDataDto Validator', () => {
|
|
|
33
33
|
describe('Missing required fields', () => {
|
|
34
34
|
it('should return errors when all fields are missing', () => {
|
|
35
35
|
const errors = (0, item_data_validator_1.validateItemDataDto)({});
|
|
36
|
-
const requiredProps = [
|
|
36
|
+
const requiredProps = [
|
|
37
|
+
'productId',
|
|
38
|
+
'productName',
|
|
39
|
+
'resourceName',
|
|
40
|
+
'productAttributes',
|
|
41
|
+
'itemAttributes',
|
|
42
|
+
'startDate',
|
|
43
|
+
'endDate',
|
|
44
|
+
];
|
|
37
45
|
for (const prop of requiredProps) {
|
|
38
|
-
expect(errors.some(e => e.property === prop)).toBe(true);
|
|
46
|
+
expect(errors.some((e) => e.property === prop)).toBe(true);
|
|
39
47
|
}
|
|
40
48
|
});
|
|
41
49
|
it('should return error when productId is missing', () => {
|
|
42
50
|
const { productId, ...dto } = baseValidDto;
|
|
43
51
|
const errors = (0, item_data_validator_1.validateItemDataDto)(dto);
|
|
44
|
-
expect(errors.some(e => e.property === 'productId')).toBe(true);
|
|
52
|
+
expect(errors.some((e) => e.property === 'productId')).toBe(true);
|
|
45
53
|
});
|
|
46
54
|
it('should return error when productAttributes is missing', () => {
|
|
47
55
|
const { productAttributes, ...dto } = baseValidDto;
|
|
48
56
|
const errors = (0, item_data_validator_1.validateItemDataDto)(dto);
|
|
49
|
-
expect(errors.some(e => e.property === 'productAttributes')).toBe(true);
|
|
57
|
+
expect(errors.some((e) => e.property === 'productAttributes')).toBe(true);
|
|
50
58
|
});
|
|
51
59
|
it('should return error when itemAttributes is missing', () => {
|
|
52
60
|
const { itemAttributes, ...dto } = baseValidDto;
|
|
53
61
|
const errors = (0, item_data_validator_1.validateItemDataDto)(dto);
|
|
54
|
-
expect(errors.some(e => e.property === 'itemAttributes')).toBe(true);
|
|
62
|
+
expect(errors.some((e) => e.property === 'itemAttributes')).toBe(true);
|
|
55
63
|
});
|
|
56
64
|
});
|
|
57
65
|
describe('Invalid field values', () => {
|
|
58
66
|
it('should return error for empty productId', () => {
|
|
59
67
|
const dto = { ...baseValidDto, productId: '' };
|
|
60
68
|
const errors = (0, item_data_validator_1.validateItemDataDto)(dto);
|
|
61
|
-
expect(errors.some(e => e.property === 'productId')).toBe(true);
|
|
69
|
+
expect(errors.some((e) => e.property === 'productId')).toBe(true);
|
|
62
70
|
});
|
|
63
71
|
it('should return error for empty startDate', () => {
|
|
64
72
|
const dto = { ...baseValidDto, startDate: '' };
|
|
65
73
|
const errors = (0, item_data_validator_1.validateItemDataDto)(dto);
|
|
66
|
-
expect(errors.some(e => e.property === 'startDate')).toBe(true);
|
|
74
|
+
expect(errors.some((e) => e.property === 'startDate')).toBe(true);
|
|
67
75
|
});
|
|
68
76
|
it('should return error for non-number price', () => {
|
|
69
77
|
const dto = { ...baseValidDto, price: 'free' };
|
|
70
78
|
const errors = (0, item_data_validator_1.validateItemDataDto)(dto);
|
|
71
|
-
expect(errors.some(e => e.property === 'price')).toBe(true);
|
|
79
|
+
expect(errors.some((e) => e.property === 'price')).toBe(true);
|
|
72
80
|
});
|
|
73
81
|
it('should return error for non-number discountPrice', () => {
|
|
74
82
|
const dto = { ...baseValidDto, discountPrice: 'half-off' };
|
|
75
83
|
const errors = (0, item_data_validator_1.validateItemDataDto)(dto);
|
|
76
|
-
expect(errors.some(e => e.property === 'discountPrice')).toBe(true);
|
|
84
|
+
expect(errors.some((e) => e.property === 'discountPrice')).toBe(true);
|
|
77
85
|
});
|
|
78
86
|
});
|
|
79
87
|
});
|
|
@@ -4,41 +4,43 @@ require("reflect-metadata");
|
|
|
4
4
|
const menu_with_submenu_validator_1 = require("./menu-with-submenu.validator");
|
|
5
5
|
describe('validateMenuDto', () => {
|
|
6
6
|
test.each([
|
|
7
|
-
[
|
|
7
|
+
[
|
|
8
|
+
'valid data with submenu',
|
|
8
9
|
{
|
|
9
10
|
type: 'with-submenu',
|
|
10
11
|
icon: 'https://example.com/icon.png',
|
|
11
12
|
label: 'Menu Label',
|
|
12
|
-
submenu: [
|
|
13
|
-
{ label: 'Submenu 1', url: 'https://example.com/sub1' }
|
|
14
|
-
],
|
|
13
|
+
submenu: [{ label: 'Submenu 1', url: 'https://example.com/sub1' }],
|
|
15
14
|
},
|
|
16
|
-
true
|
|
15
|
+
true,
|
|
17
16
|
],
|
|
18
|
-
[
|
|
17
|
+
[
|
|
18
|
+
'missing required icon',
|
|
19
19
|
{
|
|
20
20
|
type: 'with-submenu',
|
|
21
21
|
label: 'Menu Label',
|
|
22
22
|
submenu: [{ label: 'Submenu 1', url: 'https://example.com/sub1' }],
|
|
23
23
|
},
|
|
24
|
-
false
|
|
24
|
+
false,
|
|
25
25
|
],
|
|
26
|
-
[
|
|
26
|
+
[
|
|
27
|
+
'missing submenu',
|
|
27
28
|
{
|
|
28
29
|
type: 'with-submenu',
|
|
29
30
|
icon: 'https://example.com/icon.png',
|
|
30
31
|
label: 'Menu Label',
|
|
31
32
|
},
|
|
32
|
-
false
|
|
33
|
+
false,
|
|
33
34
|
],
|
|
34
|
-
[
|
|
35
|
+
[
|
|
36
|
+
'submenu with missing label',
|
|
35
37
|
{
|
|
36
38
|
type: 'with-submenu',
|
|
37
39
|
icon: 'https://example.com/icon.png',
|
|
38
40
|
label: 'Menu Label',
|
|
39
41
|
submenu: [{ url: 'https://example.com/sub1' }],
|
|
40
42
|
},
|
|
41
|
-
false
|
|
43
|
+
false,
|
|
42
44
|
],
|
|
43
45
|
])('%s', (_, input, expectedValid) => {
|
|
44
46
|
const errors = (0, menu_with_submenu_validator_1.validateMenuWithSubmenuDto)(input);
|
|
@@ -22,7 +22,7 @@ describe('validateMenuWithUrlDto', () => {
|
|
|
22
22
|
};
|
|
23
23
|
const errors = (0, menu_with_url_validator_1.validateMenuWithUrlDto)(data);
|
|
24
24
|
expect(errors.length).toBeGreaterThan(0);
|
|
25
|
-
expect(errors.some(e => { var _a; return (_a = e.constraints) === null || _a === void 0 ? void 0 : _a.isIn; })).toBe(true);
|
|
25
|
+
expect(errors.some((e) => { var _a; return (_a = e.constraints) === null || _a === void 0 ? void 0 : _a.isIn; })).toBe(true);
|
|
26
26
|
});
|
|
27
27
|
it('fails if icon is not a string', () => {
|
|
28
28
|
const data = {
|
|
@@ -33,7 +33,7 @@ describe('validateMenuWithUrlDto', () => {
|
|
|
33
33
|
};
|
|
34
34
|
const errors = (0, menu_with_url_validator_1.validateMenuWithUrlDto)(data);
|
|
35
35
|
expect(errors.length).toBeGreaterThan(0);
|
|
36
|
-
expect(errors.some(e => { var _a; return (_a = e.constraints) === null || _a === void 0 ? void 0 : _a.isString; })).toBe(true);
|
|
36
|
+
expect(errors.some((e) => { var _a; return (_a = e.constraints) === null || _a === void 0 ? void 0 : _a.isString; })).toBe(true);
|
|
37
37
|
});
|
|
38
38
|
it('fails if label is missing', () => {
|
|
39
39
|
const data = {
|
|
@@ -43,17 +43,27 @@ describe('validateMenuWithUrlDto', () => {
|
|
|
43
43
|
};
|
|
44
44
|
const errors = (0, menu_with_url_validator_1.validateMenuWithUrlDto)(data);
|
|
45
45
|
expect(errors.length).toBeGreaterThan(0);
|
|
46
|
-
expect(errors.some(e => { var _a; return (_a = e.constraints) === null || _a === void 0 ? void 0 : _a.isNotEmpty; })).toBe(true);
|
|
46
|
+
expect(errors.some((e) => { var _a; return (_a = e.constraints) === null || _a === void 0 ? void 0 : _a.isNotEmpty; })).toBe(true);
|
|
47
47
|
});
|
|
48
48
|
it('fails if url is missing or invalid', () => {
|
|
49
49
|
const invalids = [
|
|
50
50
|
{ type: 'only-url', icon: 12345, label: 'Dashboard' }, // icon not a string
|
|
51
|
-
{
|
|
51
|
+
{
|
|
52
|
+
type: 'only-url',
|
|
53
|
+
icon: 'https://example.com/icon.png',
|
|
54
|
+
label: 'Dashboard',
|
|
55
|
+
url: 'invalid-url',
|
|
56
|
+
},
|
|
52
57
|
];
|
|
53
58
|
for (const data of invalids) {
|
|
54
59
|
const errors = (0, menu_with_url_validator_1.validateMenuWithUrlDto)(data);
|
|
55
60
|
expect(errors.length).toBeGreaterThan(0);
|
|
56
|
-
expect(errors.some(e => {
|
|
61
|
+
expect(errors.some((e) => {
|
|
62
|
+
var _a, _b, _c;
|
|
63
|
+
return ((_a = e.constraints) === null || _a === void 0 ? void 0 : _a.isUrl) ||
|
|
64
|
+
((_b = e.constraints) === null || _b === void 0 ? void 0 : _b.isString) ||
|
|
65
|
+
((_c = e.constraints) === null || _c === void 0 ? void 0 : _c.isDefined);
|
|
66
|
+
})).toBe(true);
|
|
57
67
|
}
|
|
58
68
|
});
|
|
59
69
|
it('fails if submenu is present', () => {
|
|
@@ -6,40 +6,46 @@ const notification_message_type_enum_1 = require("../enums/notification/notifica
|
|
|
6
6
|
const item_actions_enum_1 = require("../enums/item-actions.enum");
|
|
7
7
|
const language_enum_1 = require("../enums/language.enum");
|
|
8
8
|
describe('NotificationInfoDto Validator', () => {
|
|
9
|
-
const validUnit = {
|
|
9
|
+
const validUnit = {
|
|
10
|
+
id: 'ram',
|
|
11
|
+
unitDescription: 'MB',
|
|
12
|
+
intervalDescription: 'month',
|
|
13
|
+
};
|
|
10
14
|
const testCases = [
|
|
11
15
|
{
|
|
12
16
|
description: 'should return no errors for valid DTO',
|
|
13
17
|
dto: {
|
|
14
18
|
type: notification_message_type_enum_1.NotificationMessageTypeEnum.EMAIL,
|
|
15
19
|
title: 'Valid Title',
|
|
16
|
-
supportedActions: [item_actions_enum_1.
|
|
20
|
+
supportedActions: [item_actions_enum_1.ProductActionsEnum.CREATE],
|
|
17
21
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
18
|
-
payPerUseUnits: [validUnit]
|
|
22
|
+
payPerUseUnits: [validUnit],
|
|
19
23
|
},
|
|
20
|
-
expectedErrorsLength: 0
|
|
24
|
+
expectedErrorsLength: 0,
|
|
21
25
|
},
|
|
22
26
|
{
|
|
23
27
|
description: 'should return error for missing type',
|
|
24
28
|
dto: {
|
|
25
29
|
title: 'Valid Title',
|
|
26
|
-
supportedActions: [item_actions_enum_1.
|
|
30
|
+
supportedActions: [item_actions_enum_1.ProductActionsEnum.CREATE],
|
|
27
31
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
28
|
-
payPerUseUnits: [validUnit]
|
|
32
|
+
payPerUseUnits: [validUnit],
|
|
29
33
|
},
|
|
30
|
-
expectedErrorsLength: 1
|
|
34
|
+
expectedErrorsLength: 1,
|
|
31
35
|
},
|
|
32
36
|
{
|
|
33
37
|
description: 'should return error for invalid payPerUseUnits',
|
|
34
38
|
dto: {
|
|
35
39
|
type: notification_message_type_enum_1.NotificationMessageTypeEnum.EMAIL,
|
|
36
40
|
title: 'Valid Title',
|
|
37
|
-
supportedActions: [item_actions_enum_1.
|
|
41
|
+
supportedActions: [item_actions_enum_1.ProductActionsEnum.CREATE],
|
|
38
42
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
39
|
-
payPerUseUnits: [
|
|
43
|
+
payPerUseUnits: [
|
|
44
|
+
{ id: '', unitDescription: '', intervalDescription: '' },
|
|
45
|
+
], // Invalid unit
|
|
40
46
|
},
|
|
41
|
-
expectedErrorsLength: 1
|
|
42
|
-
}
|
|
47
|
+
expectedErrorsLength: 1,
|
|
48
|
+
},
|
|
43
49
|
];
|
|
44
50
|
testCases.forEach(({ description, dto, expectedErrorsLength }) => {
|
|
45
51
|
it(description, async () => {
|
|
@@ -52,29 +58,31 @@ describe('NotificationInfoDto Validator', () => {
|
|
|
52
58
|
description: 'should return ValidationError for missing title',
|
|
53
59
|
dto: {
|
|
54
60
|
type: notification_message_type_enum_1.NotificationMessageTypeEnum.EMAIL,
|
|
55
|
-
supportedActions: [item_actions_enum_1.
|
|
61
|
+
supportedActions: [item_actions_enum_1.ProductActionsEnum.CREATE],
|
|
56
62
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
57
|
-
payPerUseUnits: [validUnit]
|
|
63
|
+
payPerUseUnits: [validUnit],
|
|
58
64
|
},
|
|
59
|
-
expectedErrors: ['title']
|
|
65
|
+
expectedErrors: ['title'],
|
|
60
66
|
},
|
|
61
67
|
{
|
|
62
68
|
description: 'should return ValidationError for invalid payPerUseUnits',
|
|
63
69
|
dto: {
|
|
64
70
|
type: notification_message_type_enum_1.NotificationMessageTypeEnum.EMAIL,
|
|
65
71
|
title: 'Valid Title',
|
|
66
|
-
supportedActions: [item_actions_enum_1.
|
|
72
|
+
supportedActions: [item_actions_enum_1.ProductActionsEnum.CREATE],
|
|
67
73
|
supportedLanguages: [language_enum_1.LanguageEnum.ENGLISH],
|
|
68
|
-
payPerUseUnits: [
|
|
74
|
+
payPerUseUnits: [
|
|
75
|
+
{ id: '', unitDescription: '', intervalDescription: '' },
|
|
76
|
+
],
|
|
69
77
|
},
|
|
70
|
-
expectedErrors: ['payPerUseUnits']
|
|
71
|
-
}
|
|
78
|
+
expectedErrors: ['payPerUseUnits'],
|
|
79
|
+
},
|
|
72
80
|
];
|
|
73
81
|
validationErrorTestCases.forEach(({ description, dto, expectedErrors }) => {
|
|
74
82
|
it(description, async () => {
|
|
75
83
|
const errors = await (0, notification_info_validator_1.validateNotificationInfoDto)(dto);
|
|
76
|
-
const errorProperties = errors.map(error => error.property);
|
|
77
|
-
expectedErrors.forEach(expectedError => {
|
|
84
|
+
const errorProperties = errors.map((error) => error.property);
|
|
85
|
+
expectedErrors.forEach((expectedError) => {
|
|
78
86
|
expect(errorProperties).toContain(expectedError);
|
|
79
87
|
});
|
|
80
88
|
});
|