scandit-datacapture-frameworks-label 8.4.1 → 8.5.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/__mocks__/ScanditDataCaptureCore.ts +14 -6
- package/dist/dts/defaults/index.d.ts +1 -1
- package/dist/dts/labelcapture/AdaptiveRecognitionResult.d.ts +1 -1
- package/dist/dts/labelcapture/CapturedLabel.d.ts +2 -2
- package/dist/dts/labelcapture/LabelCaptureFeedback.d.ts +2 -2
- package/dist/dts/labelcapture/LabelField.d.ts +6 -6
- package/dist/dts/labelcapture/ReceiptScanningResult.d.ts +3 -3
- package/dist/dts/labelcapture/controller/LabelCaptureAdaptiveRecognitionOverlayController.d.ts +6 -4
- package/dist/dts/labelcapture/controller/LabelCaptureAdvancedOverlayController.d.ts +2 -0
- package/dist/dts/labelcapture/controller/LabelCaptureBasicOverlayController.d.ts +2 -0
- package/dist/dts/labelcapture/controller/LabelCaptureValidationFlowOverlayController.d.ts +2 -0
- package/dist/dts/labelcapture/private/PrivateLabelField.d.ts +4 -4
- package/dist/dts/labelcapture/view/LabelCaptureAdaptiveRecognitionListener.d.ts +1 -1
- package/dist/dts/labelcapture/view/LabelCaptureAdaptiveRecognitionOverlay.d.ts +4 -4
- package/dist/dts/labelcapture/view/LabelCaptureAdvancedOverlay.d.ts +1 -1
- package/dist/dts/labelcapture/view/LabelCaptureAdvancedOverlayListener.d.ts +5 -5
- package/dist/dts/labelcapture/view/LabelCaptureAdvancedOverlayView.d.ts +1 -1
- package/dist/dts/proxy-types.d.ts +1 -1
- package/dist/index.js +205 -99
- package/dist/index.js.map +1 -1
- package/jest.config.js +4 -11
- package/package.json +3 -3
- package/test/AdaptiveRecognitionResultType.test.ts +0 -1
- package/test/BarcodeFieldSymbologies.test.ts +29 -0
- package/test/LabelCaptureAdaptiveRecognitionSettings.test.ts +0 -1
- package/test/LabelCaptureValidationFlowOverlayController.test.ts +9 -2
- package/test/ReceiptScanningLineItem.test.ts +15 -16
- package/test/ReceiptScanningResult.test.ts +22 -59
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scandit-datacapture-frameworks-label",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.5.0",
|
|
4
4
|
"description": "Label Capture common package",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Scandit",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"coverage": "jest --coverage --passWithNoTests"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"scandit-datacapture-frameworks-barcode": "8.
|
|
22
|
-
"scandit-datacapture-frameworks-core": "8.
|
|
21
|
+
"scandit-datacapture-frameworks-barcode": "8.5.0",
|
|
22
|
+
"scandit-datacapture-frameworks-core": "8.5.0"
|
|
23
23
|
},
|
|
24
24
|
"packageManager": "pnpm@10.15.0"
|
|
25
25
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { describe, it, expect } from '@jest/globals';
|
|
2
|
+
import { SymbologySettings } from 'scandit-datacapture-frameworks-barcode';
|
|
3
|
+
import { CustomBarcode } from '../src/labelcapture/CustomBarcode';
|
|
4
|
+
import { SerialNumberBarcode } from '../src/labelcapture/SerialNumberBarcode';
|
|
5
|
+
|
|
6
|
+
// A barcode label field with no symbologies serializes to an empty `symbologies`
|
|
7
|
+
// payload, which the native deserializer rejects with an abort (SDC-32003). The
|
|
8
|
+
// shared BarcodeField constructor guards against it so callers get a catchable
|
|
9
|
+
// error instead of a crash.
|
|
10
|
+
describe('BarcodeField symbology requirement', () => {
|
|
11
|
+
const oneSymbology = [{ symbology: { toString: () => 'code128' } } as unknown as SymbologySettings];
|
|
12
|
+
|
|
13
|
+
it('throws when a CustomBarcode is created without symbologies', () => {
|
|
14
|
+
expect(() => CustomBarcode.initWithNameAndSymbologySettings('Barcode', [])).toThrow(
|
|
15
|
+
/requires at least one symbology/
|
|
16
|
+
);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('throws for every barcode field type (guard lives in the shared base)', () => {
|
|
20
|
+
expect(() => SerialNumberBarcode.initWithNameAndSymbologySettings('Serial', [])).toThrow(
|
|
21
|
+
/requires at least one symbology/
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('constructs a CustomBarcode when given at least one symbology', () => {
|
|
26
|
+
const field = CustomBarcode.initWithNameAndSymbologySettings('Barcode', oneSymbology);
|
|
27
|
+
expect(field.symbologies).toHaveLength(1);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { describe, it, expect, jest, beforeEach, afterEach, beforeAll } from '@jest/globals';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
EventEmitter,
|
|
4
|
+
EventPayload,
|
|
5
|
+
FactoryMaker,
|
|
6
|
+
FrameData,
|
|
7
|
+
CoreProxy,
|
|
8
|
+
createNativeProxy,
|
|
9
|
+
} from 'scandit-datacapture-frameworks-core';
|
|
3
10
|
import { MockCaller, MockNativeEventEmitter } from '../__mocks__/ScanditDataCaptureCore';
|
|
4
11
|
import {
|
|
5
12
|
LabelCaptureValidationFlowOverlayController,
|
|
@@ -86,7 +93,7 @@ describe('LabelCaptureValidationFlowOverlayController', () => {
|
|
|
86
93
|
FactoryMaker.bindInstanceIfNotExists('LabelCaptureDefaults', mockDefaults);
|
|
87
94
|
// Register the proxy builder - each test gets a fresh proxy
|
|
88
95
|
FactoryMaker.bindLazyInstance('LabelCaptureValidationFlowOverlayProxy', () => createMockLabelProxy());
|
|
89
|
-
|
|
96
|
+
|
|
90
97
|
// Register CoreProxy for FrameDataController
|
|
91
98
|
const mockNativeModule = {
|
|
92
99
|
getLastFrameAsJson: jest.fn(() => Promise.resolve(null)),
|
|
@@ -4,11 +4,11 @@ import { ReceiptScanningLineItem } from '../src/labelcapture/ReceiptScanningLine
|
|
|
4
4
|
describe('ReceiptScanningLineItem', () => {
|
|
5
5
|
describe('constructor', () => {
|
|
6
6
|
it('should create a line item with all properties', () => {
|
|
7
|
-
const lineItem = new ReceiptScanningLineItem('Milk 2%', 3.99, 0.
|
|
7
|
+
const lineItem = new ReceiptScanningLineItem('Milk 2%', 3.99, 0.5, 2.0, 7.48);
|
|
8
8
|
|
|
9
9
|
expect(lineItem.name).toBe('Milk 2%');
|
|
10
10
|
expect(lineItem.unitPrice).toBe(3.99);
|
|
11
|
-
expect(lineItem.discount).toBe(0.
|
|
11
|
+
expect(lineItem.discount).toBe(0.5);
|
|
12
12
|
expect(lineItem.quantity).toBe(2.0);
|
|
13
13
|
expect(lineItem.totalPrice).toBe(7.48);
|
|
14
14
|
});
|
|
@@ -41,7 +41,7 @@ describe('ReceiptScanningLineItem', () => {
|
|
|
41
41
|
|
|
42
42
|
describe('getters', () => {
|
|
43
43
|
it('name getter returns the correct value', () => {
|
|
44
|
-
const lineItem = new ReceiptScanningLineItem('Test Item', 10.
|
|
44
|
+
const lineItem = new ReceiptScanningLineItem('Test Item', 10.0, null, 1, 10.0);
|
|
45
45
|
expect(lineItem.name).toBe('Test Item');
|
|
46
46
|
});
|
|
47
47
|
|
|
@@ -51,49 +51,48 @@ describe('ReceiptScanningLineItem', () => {
|
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
it('discount getter returns the correct value', () => {
|
|
54
|
-
const lineItem = new ReceiptScanningLineItem('Test', 10.
|
|
55
|
-
expect(lineItem.discount).toBe(2.
|
|
54
|
+
const lineItem = new ReceiptScanningLineItem('Test', 10.0, 2.0, 1, 8.0);
|
|
55
|
+
expect(lineItem.discount).toBe(2.0);
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
it('quantity getter returns the correct value', () => {
|
|
59
|
-
const lineItem = new ReceiptScanningLineItem('Test', 5.
|
|
59
|
+
const lineItem = new ReceiptScanningLineItem('Test', 5.0, null, 3, 15.0);
|
|
60
60
|
expect(lineItem.quantity).toBe(3);
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
it('totalPrice getter returns the correct value', () => {
|
|
64
|
-
const lineItem = new ReceiptScanningLineItem('Test', 5.
|
|
65
|
-
expect(lineItem.totalPrice).toBe(15.
|
|
64
|
+
const lineItem = new ReceiptScanningLineItem('Test', 5.0, null, 3, 15.0);
|
|
65
|
+
expect(lineItem.totalPrice).toBe(15.0);
|
|
66
66
|
});
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
describe('edge cases', () => {
|
|
70
70
|
it('should handle very large numbers', () => {
|
|
71
|
-
const lineItem = new ReceiptScanningLineItem('Expensive Item', 999999.99, null, 1000, 999999990.
|
|
71
|
+
const lineItem = new ReceiptScanningLineItem('Expensive Item', 999999.99, null, 1000, 999999990.0);
|
|
72
72
|
|
|
73
73
|
expect(lineItem.unitPrice).toBe(999999.99);
|
|
74
74
|
expect(lineItem.quantity).toBe(1000);
|
|
75
|
-
expect(lineItem.totalPrice).toBe(999999990.
|
|
75
|
+
expect(lineItem.totalPrice).toBe(999999990.0);
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
it('should handle negative values', () => {
|
|
79
79
|
// Refunds might have negative prices
|
|
80
|
-
const lineItem = new ReceiptScanningLineItem('Refund', -10.
|
|
80
|
+
const lineItem = new ReceiptScanningLineItem('Refund', -10.0, null, 1, -10.0);
|
|
81
81
|
|
|
82
|
-
expect(lineItem.unitPrice).toBe(-10.
|
|
83
|
-
expect(lineItem.totalPrice).toBe(-10.
|
|
82
|
+
expect(lineItem.unitPrice).toBe(-10.0);
|
|
83
|
+
expect(lineItem.totalPrice).toBe(-10.0);
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
it('should handle special characters in name', () => {
|
|
87
|
-
const lineItem = new ReceiptScanningLineItem('Café Mocha™ (Large) @50% Off!', 5.
|
|
87
|
+
const lineItem = new ReceiptScanningLineItem('Café Mocha™ (Large) @50% Off!', 5.0, 2.5, 1, 2.5);
|
|
88
88
|
|
|
89
89
|
expect(lineItem.name).toBe('Café Mocha™ (Large) @50% Off!');
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
it('should handle unicode in name', () => {
|
|
93
|
-
const lineItem = new ReceiptScanningLineItem('寿司 🍣', 12.
|
|
93
|
+
const lineItem = new ReceiptScanningLineItem('寿司 🍣', 12.0, null, 2, 24.0);
|
|
94
94
|
|
|
95
95
|
expect(lineItem.name).toBe('寿司 🍣');
|
|
96
96
|
});
|
|
97
97
|
});
|
|
98
98
|
});
|
|
99
|
-
|
|
@@ -8,14 +8,14 @@ describe('ReceiptScanningResult', () => {
|
|
|
8
8
|
it('should create a result with all properties', () => {
|
|
9
9
|
const lineItems = [
|
|
10
10
|
new ReceiptScanningLineItem('Milk', 3.99, null, 2, 7.98),
|
|
11
|
-
new ReceiptScanningLineItem('Bread', 2.
|
|
11
|
+
new ReceiptScanningLineItem('Bread', 2.5, 0.25, 1, 2.25),
|
|
12
12
|
];
|
|
13
13
|
|
|
14
14
|
const result = new ReceiptScanningResult(
|
|
15
15
|
'2024-01-15',
|
|
16
16
|
lineItems,
|
|
17
17
|
12345678,
|
|
18
|
-
45.
|
|
18
|
+
45.5,
|
|
19
19
|
3.64,
|
|
20
20
|
49.14,
|
|
21
21
|
'123 Main St, San Francisco, CA 94102',
|
|
@@ -27,7 +27,7 @@ describe('ReceiptScanningResult', () => {
|
|
|
27
27
|
expect(result.date).toBe('2024-01-15');
|
|
28
28
|
expect(result.lineItems).toHaveLength(2);
|
|
29
29
|
expect(result.loyaltyNumber).toBe(12345678);
|
|
30
|
-
expect(result.paymentPreTaxTotal).toBe(45.
|
|
30
|
+
expect(result.paymentPreTaxTotal).toBe(45.5);
|
|
31
31
|
expect(result.paymentTax).toBe(3.64);
|
|
32
32
|
expect(result.paymentTotal).toBe(49.14);
|
|
33
33
|
expect(result.storeAddress).toBe('123 Main St, San Francisco, CA 94102');
|
|
@@ -37,18 +37,7 @@ describe('ReceiptScanningResult', () => {
|
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
it('should create a result with all null optional values', () => {
|
|
40
|
-
const result = new ReceiptScanningResult(
|
|
41
|
-
null,
|
|
42
|
-
[],
|
|
43
|
-
null,
|
|
44
|
-
null,
|
|
45
|
-
null,
|
|
46
|
-
null,
|
|
47
|
-
null,
|
|
48
|
-
null,
|
|
49
|
-
null,
|
|
50
|
-
null
|
|
51
|
-
);
|
|
40
|
+
const result = new ReceiptScanningResult(null, [], null, null, null, null, null, null, null, null);
|
|
52
41
|
|
|
53
42
|
expect(result.date).toBeNull();
|
|
54
43
|
expect(result.lineItems).toHaveLength(0);
|
|
@@ -63,18 +52,7 @@ describe('ReceiptScanningResult', () => {
|
|
|
63
52
|
});
|
|
64
53
|
|
|
65
54
|
it('should handle empty line items array', () => {
|
|
66
|
-
const result = new ReceiptScanningResult(
|
|
67
|
-
'2024-01-15',
|
|
68
|
-
[],
|
|
69
|
-
null,
|
|
70
|
-
10.00,
|
|
71
|
-
0.80,
|
|
72
|
-
10.80,
|
|
73
|
-
null,
|
|
74
|
-
null,
|
|
75
|
-
'Test Store',
|
|
76
|
-
null
|
|
77
|
-
);
|
|
55
|
+
const result = new ReceiptScanningResult('2024-01-15', [], null, 10.0, 0.8, 10.8, null, null, 'Test Store', null);
|
|
78
56
|
|
|
79
57
|
expect(result.lineItems).toHaveLength(0);
|
|
80
58
|
expect(result.lineItems).toEqual([]);
|
|
@@ -83,9 +61,7 @@ describe('ReceiptScanningResult', () => {
|
|
|
83
61
|
|
|
84
62
|
describe('resultType', () => {
|
|
85
63
|
it('should return Receipt type', () => {
|
|
86
|
-
const result = new ReceiptScanningResult(
|
|
87
|
-
null, [], null, null, null, null, null, null, null, null
|
|
88
|
-
);
|
|
64
|
+
const result = new ReceiptScanningResult(null, [], null, null, null, null, null, null, null, null);
|
|
89
65
|
|
|
90
66
|
expect(result.resultType).toBe(AdaptiveRecognitionResultType.Receipt);
|
|
91
67
|
});
|
|
@@ -93,11 +69,11 @@ describe('ReceiptScanningResult', () => {
|
|
|
93
69
|
it('should always return Receipt regardless of other properties', () => {
|
|
94
70
|
const result = new ReceiptScanningResult(
|
|
95
71
|
'2024-01-15',
|
|
96
|
-
[new ReceiptScanningLineItem('Item', 10.
|
|
72
|
+
[new ReceiptScanningLineItem('Item', 10.0, null, 1, 10.0)],
|
|
97
73
|
12345,
|
|
98
|
-
10.
|
|
99
|
-
0.
|
|
100
|
-
10.
|
|
74
|
+
10.0,
|
|
75
|
+
0.8,
|
|
76
|
+
10.8,
|
|
101
77
|
'Address',
|
|
102
78
|
'City',
|
|
103
79
|
'Store',
|
|
@@ -114,11 +90,11 @@ describe('ReceiptScanningResult', () => {
|
|
|
114
90
|
beforeEach(() => {
|
|
115
91
|
result = new ReceiptScanningResult(
|
|
116
92
|
'2024-03-20',
|
|
117
|
-
[new ReceiptScanningLineItem('Test', 5.
|
|
93
|
+
[new ReceiptScanningLineItem('Test', 5.0, 1.0, 2, 8.0)],
|
|
118
94
|
99999,
|
|
119
|
-
100.
|
|
120
|
-
8.
|
|
121
|
-
108.
|
|
95
|
+
100.0,
|
|
96
|
+
8.5,
|
|
97
|
+
108.5,
|
|
122
98
|
'456 Oak Ave',
|
|
123
99
|
'Los Angeles',
|
|
124
100
|
'Test Market',
|
|
@@ -140,15 +116,15 @@ describe('ReceiptScanningResult', () => {
|
|
|
140
116
|
});
|
|
141
117
|
|
|
142
118
|
it('paymentPreTaxTotal getter returns correct value', () => {
|
|
143
|
-
expect(result.paymentPreTaxTotal).toBe(100.
|
|
119
|
+
expect(result.paymentPreTaxTotal).toBe(100.0);
|
|
144
120
|
});
|
|
145
121
|
|
|
146
122
|
it('paymentTax getter returns correct value', () => {
|
|
147
|
-
expect(result.paymentTax).toBe(8.
|
|
123
|
+
expect(result.paymentTax).toBe(8.5);
|
|
148
124
|
});
|
|
149
125
|
|
|
150
126
|
it('paymentTotal getter returns correct value', () => {
|
|
151
|
-
expect(result.paymentTotal).toBe(108.
|
|
127
|
+
expect(result.paymentTotal).toBe(108.5);
|
|
152
128
|
});
|
|
153
129
|
|
|
154
130
|
it('storeAddress getter returns correct value', () => {
|
|
@@ -170,8 +146,9 @@ describe('ReceiptScanningResult', () => {
|
|
|
170
146
|
|
|
171
147
|
describe('edge cases', () => {
|
|
172
148
|
it('should handle many line items', () => {
|
|
173
|
-
const lineItems = Array.from(
|
|
174
|
-
|
|
149
|
+
const lineItems = Array.from(
|
|
150
|
+
{ length: 100 },
|
|
151
|
+
(_, i) => new ReceiptScanningLineItem(`Item ${i + 1}`, i + 1, null, 1, i + 1)
|
|
175
152
|
);
|
|
176
153
|
|
|
177
154
|
const result = new ReceiptScanningResult(
|
|
@@ -212,18 +189,7 @@ describe('ReceiptScanningResult', () => {
|
|
|
212
189
|
});
|
|
213
190
|
|
|
214
191
|
it('should handle zero payment values', () => {
|
|
215
|
-
const result = new ReceiptScanningResult(
|
|
216
|
-
null,
|
|
217
|
-
[],
|
|
218
|
-
null,
|
|
219
|
-
0,
|
|
220
|
-
0,
|
|
221
|
-
0,
|
|
222
|
-
null,
|
|
223
|
-
null,
|
|
224
|
-
null,
|
|
225
|
-
null
|
|
226
|
-
);
|
|
192
|
+
const result = new ReceiptScanningResult(null, [], null, 0, 0, 0, null, null, null, null);
|
|
227
193
|
|
|
228
194
|
expect(result.paymentPreTaxTotal).toBe(0);
|
|
229
195
|
expect(result.paymentTax).toBe(0);
|
|
@@ -233,9 +199,7 @@ describe('ReceiptScanningResult', () => {
|
|
|
233
199
|
|
|
234
200
|
describe('implements AdaptiveRecognitionResult', () => {
|
|
235
201
|
it('should have resultType property from interface', () => {
|
|
236
|
-
const result = new ReceiptScanningResult(
|
|
237
|
-
null, [], null, null, null, null, null, null, null, null
|
|
238
|
-
);
|
|
202
|
+
const result = new ReceiptScanningResult(null, [], null, null, null, null, null, null, null, null);
|
|
239
203
|
|
|
240
204
|
// Type check - resultType should exist and be of correct type
|
|
241
205
|
const resultType = result.resultType;
|
|
@@ -244,4 +208,3 @@ describe('ReceiptScanningResult', () => {
|
|
|
244
208
|
});
|
|
245
209
|
});
|
|
246
210
|
});
|
|
247
|
-
|