@managesome/eposmatic-toolkit 0.2.360 → 0.2.361
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.
|
@@ -48,6 +48,8 @@ function getReceiptTypes(value) {
|
|
|
48
48
|
const validReceiptTypes = new Set(constants_1.ALL_RECEIPT_TYPES);
|
|
49
49
|
if (!Array.isArray(value))
|
|
50
50
|
return [...constants_1.ALL_RECEIPT_TYPES];
|
|
51
|
+
if (value.length === 0)
|
|
52
|
+
return [];
|
|
51
53
|
const receiptTypes = Array.from(new Set(value.filter((receiptType) => typeof receiptType === 'string' && validReceiptTypes.has(receiptType))));
|
|
52
54
|
return receiptTypes.length > 0 ? receiptTypes : [...constants_1.ALL_RECEIPT_TYPES];
|
|
53
55
|
}
|
|
@@ -93,6 +95,8 @@ function getSelectedPlatforms(value) {
|
|
|
93
95
|
const validPlatforms = new Set(constants_1.ALL_PLATFORMS);
|
|
94
96
|
if (!Array.isArray(value))
|
|
95
97
|
return [...constants_1.ALL_PLATFORMS];
|
|
98
|
+
if (value.length === 0)
|
|
99
|
+
return [];
|
|
96
100
|
const selectedPlatforms = Array.from(new Set(value.filter((platform) => typeof platform === 'string' && validPlatforms.has(platform))));
|
|
97
101
|
return selectedPlatforms.length > 0 ? selectedPlatforms : [...constants_1.ALL_PLATFORMS];
|
|
98
102
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const constants_1 = require("../constants");
|
|
4
|
+
const printer_helpers_1 = require("../helpers/utils/printer-helpers");
|
|
5
|
+
describe('syncPrinterSettingsFields receiptTypes', () => {
|
|
6
|
+
it('preserves explicit empty receiptTypes arrays', () => {
|
|
7
|
+
const result = (0, printer_helpers_1.syncPrinterSettingsFields)({
|
|
8
|
+
receiptTypes: [],
|
|
9
|
+
});
|
|
10
|
+
expect(result.receiptTypes).toEqual([]);
|
|
11
|
+
});
|
|
12
|
+
it('falls back to all receiptTypes when input is not an array', () => {
|
|
13
|
+
const result = (0, printer_helpers_1.syncPrinterSettingsFields)({
|
|
14
|
+
receiptTypes: 'invalid',
|
|
15
|
+
});
|
|
16
|
+
expect(result.receiptTypes).toEqual(constants_1.ALL_RECEIPT_TYPES);
|
|
17
|
+
});
|
|
18
|
+
it('falls back to all receiptTypes when array has only invalid values', () => {
|
|
19
|
+
const result = (0, printer_helpers_1.syncPrinterSettingsFields)({
|
|
20
|
+
receiptTypes: ['invalid'],
|
|
21
|
+
});
|
|
22
|
+
expect(result.receiptTypes).toEqual(constants_1.ALL_RECEIPT_TYPES);
|
|
23
|
+
});
|
|
24
|
+
it('keeps only valid deduplicated receiptTypes', () => {
|
|
25
|
+
const result = (0, printer_helpers_1.syncPrinterSettingsFields)({
|
|
26
|
+
receiptTypes: [constants_1.RECEIPT_TYPE_ENUM.CUSTOMER, 'invalid', constants_1.RECEIPT_TYPE_ENUM.CUSTOMER],
|
|
27
|
+
});
|
|
28
|
+
expect(result.receiptTypes).toEqual([constants_1.RECEIPT_TYPE_ENUM.CUSTOMER]);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
describe('syncPrinterSettingsFields selectedPlatforms', () => {
|
|
32
|
+
it('preserves explicit empty selectedPlatforms arrays', () => {
|
|
33
|
+
const result = (0, printer_helpers_1.syncPrinterSettingsFields)({
|
|
34
|
+
[constants_1.RECEIPT_TYPE_ENUM.KITCHEN]: {
|
|
35
|
+
selectedPlatforms: [],
|
|
36
|
+
},
|
|
37
|
+
[constants_1.RECEIPT_TYPE_ENUM.CUSTOMER]: {
|
|
38
|
+
selectedPlatforms: [],
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
expect(result[constants_1.RECEIPT_TYPE_ENUM.KITCHEN].selectedPlatforms).toEqual([]);
|
|
42
|
+
expect(result[constants_1.RECEIPT_TYPE_ENUM.CUSTOMER].selectedPlatforms).toEqual([]);
|
|
43
|
+
});
|
|
44
|
+
it('falls back to all selectedPlatforms when array has only invalid values', () => {
|
|
45
|
+
const result = (0, printer_helpers_1.syncPrinterSettingsFields)({
|
|
46
|
+
[constants_1.RECEIPT_TYPE_ENUM.KITCHEN]: {
|
|
47
|
+
selectedPlatforms: ['invalid'],
|
|
48
|
+
},
|
|
49
|
+
[constants_1.RECEIPT_TYPE_ENUM.CUSTOMER]: {
|
|
50
|
+
selectedPlatforms: ['invalid'],
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
expect(result[constants_1.RECEIPT_TYPE_ENUM.KITCHEN].selectedPlatforms).toEqual(constants_1.ALL_PLATFORMS);
|
|
54
|
+
expect(result[constants_1.RECEIPT_TYPE_ENUM.CUSTOMER].selectedPlatforms).toEqual(constants_1.ALL_PLATFORMS);
|
|
55
|
+
});
|
|
56
|
+
it('keeps only valid deduplicated selectedPlatforms', () => {
|
|
57
|
+
const result = (0, printer_helpers_1.syncPrinterSettingsFields)({
|
|
58
|
+
[constants_1.RECEIPT_TYPE_ENUM.KITCHEN]: {
|
|
59
|
+
selectedPlatforms: [constants_1.PLATFORMS_ENUM.WEB_TAKE_AWAY, 'invalid', constants_1.PLATFORMS_ENUM.WEB_TAKE_AWAY],
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
expect(result[constants_1.RECEIPT_TYPE_ENUM.KITCHEN].selectedPlatforms).toEqual([constants_1.PLATFORMS_ENUM.WEB_TAKE_AWAY]);
|
|
63
|
+
});
|
|
64
|
+
});
|