@aidc-toolkit/gs1 0.9.20-beta → 1.0.22-beta
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/dist/character-set.d.ts +4 -4
- package/dist/character-set.d.ts.map +1 -1
- package/dist/character-set.js +7 -7
- package/dist/character-set.js.map +1 -1
- package/dist/gtin-creator.d.ts +68 -0
- package/dist/gtin-creator.d.ts.map +1 -0
- package/dist/gtin-creator.js +158 -0
- package/dist/gtin-creator.js.map +1 -0
- package/dist/gtin-validator.d.ts +202 -0
- package/dist/gtin-validator.d.ts.map +1 -0
- package/dist/gtin-validator.js +470 -0
- package/dist/gtin-validator.js.map +1 -0
- package/dist/identifier-creator.d.ts +72 -0
- package/dist/identifier-creator.d.ts.map +1 -0
- package/dist/identifier-creator.js +50 -0
- package/dist/identifier-creator.js.map +1 -0
- package/dist/identifier-type.d.ts +58 -0
- package/dist/identifier-type.d.ts.map +1 -0
- package/dist/identifier-type.js +54 -0
- package/dist/identifier-type.js.map +1 -0
- package/dist/identifier-validator.d.ts +174 -0
- package/dist/identifier-validator.d.ts.map +1 -0
- package/dist/identifier-validator.js +145 -0
- package/dist/identifier-validator.js.map +1 -0
- package/dist/index.d.ts +16 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -1
- package/dist/index.js.map +1 -1
- package/dist/locale/en/locale-strings.d.ts +3 -3
- package/dist/locale/en/locale-strings.js +3 -3
- package/dist/locale/en/locale-strings.js.map +1 -1
- package/dist/locale/fr/locale-strings.d.ts +3 -3
- package/dist/locale/fr/locale-strings.js +3 -3
- package/dist/locale/fr/locale-strings.js.map +1 -1
- package/dist/non-gtin-numeric-identifier-creator.d.ts +30 -0
- package/dist/non-gtin-numeric-identifier-creator.d.ts.map +1 -0
- package/dist/non-gtin-numeric-identifier-creator.js +30 -0
- package/dist/non-gtin-numeric-identifier-creator.js.map +1 -0
- package/dist/non-gtin-numeric-identifier-validator.d.ts +41 -0
- package/dist/non-gtin-numeric-identifier-validator.d.ts.map +1 -0
- package/dist/non-gtin-numeric-identifier-validator.js +40 -0
- package/dist/non-gtin-numeric-identifier-validator.js.map +1 -0
- package/dist/non-numeric-identifier-creator.d.ts +55 -0
- package/dist/non-numeric-identifier-creator.d.ts.map +1 -0
- package/dist/non-numeric-identifier-creator.js +93 -0
- package/dist/non-numeric-identifier-creator.js.map +1 -0
- package/dist/non-numeric-identifier-validator.d.ts +78 -0
- package/dist/non-numeric-identifier-validator.d.ts.map +1 -0
- package/dist/non-numeric-identifier-validator.js +95 -0
- package/dist/non-numeric-identifier-validator.js.map +1 -0
- package/dist/numeric-identifier-creator.d.ts +121 -0
- package/dist/numeric-identifier-creator.d.ts.map +1 -0
- package/dist/numeric-identifier-creator.js +135 -0
- package/dist/numeric-identifier-creator.js.map +1 -0
- package/dist/numeric-identifier-validator.d.ts +76 -0
- package/dist/numeric-identifier-validator.d.ts.map +1 -0
- package/dist/numeric-identifier-validator.js +84 -0
- package/dist/numeric-identifier-validator.js.map +1 -0
- package/dist/prefix-manager.d.ts +224 -0
- package/dist/prefix-manager.d.ts.map +1 -0
- package/dist/prefix-manager.js +369 -0
- package/dist/prefix-manager.js.map +1 -0
- package/dist/prefix-provider.d.ts +27 -0
- package/dist/prefix-provider.d.ts.map +1 -0
- package/dist/prefix-provider.js +2 -0
- package/dist/prefix-provider.js.map +1 -0
- package/dist/prefix-type.d.ts +22 -0
- package/dist/prefix-type.d.ts.map +1 -0
- package/dist/prefix-type.js +18 -0
- package/dist/prefix-type.js.map +1 -0
- package/dist/prefix-validator.d.ts +58 -0
- package/dist/prefix-validator.d.ts.map +1 -0
- package/dist/prefix-validator.js +154 -0
- package/dist/prefix-validator.js.map +1 -0
- package/dist/serializable-numeric-identifier-creator.d.ts +86 -0
- package/dist/serializable-numeric-identifier-creator.d.ts.map +1 -0
- package/dist/serializable-numeric-identifier-creator.js +116 -0
- package/dist/serializable-numeric-identifier-creator.js.map +1 -0
- package/dist/serializable-numeric-identifier-validator.d.ts +79 -0
- package/dist/serializable-numeric-identifier-validator.d.ts.map +1 -0
- package/dist/serializable-numeric-identifier-validator.js +99 -0
- package/dist/serializable-numeric-identifier-validator.js.map +1 -0
- package/gs1.iml +4 -1
- package/package.json +2 -3
- package/src/character-set.ts +7 -7
- package/src/gtin-creator.ts +195 -0
- package/src/gtin-validator.ts +564 -0
- package/src/identifier-creator.ts +97 -0
- package/src/identifier-type.ts +69 -0
- package/src/identifier-validator.ts +235 -0
- package/src/index.ts +16 -1
- package/src/locale/en/locale-strings.ts +3 -3
- package/src/locale/fr/locale-strings.ts +3 -3
- package/src/non-gtin-numeric-identifier-creator.ts +33 -0
- package/src/non-gtin-numeric-identifier-validator.ts +54 -0
- package/src/non-numeric-identifier-creator.ts +111 -0
- package/src/non-numeric-identifier-validator.ts +128 -0
- package/src/numeric-identifier-creator.ts +200 -0
- package/src/numeric-identifier-validator.ts +128 -0
- package/src/prefix-manager.ts +446 -0
- package/src/prefix-provider.ts +31 -0
- package/src/prefix-type.ts +24 -0
- package/src/prefix-validator.ts +191 -0
- package/src/serializable-numeric-identifier-creator.ts +128 -0
- package/src/serializable-numeric-identifier-validator.ts +124 -0
- package/test/check.test.ts +0 -4
- package/test/creator.test.ts +30 -0
- package/test/gtin-creator.ts +239 -0
- package/test/gtin-validator.test.ts +149 -0
- package/test/identifier-creator.ts +84 -0
- package/test/identifier-validator.ts +8 -0
- package/test/non-gtin-numeric-identifier-creator.ts +98 -0
- package/test/non-gtin-numeric-identifier-validator.ts +6 -0
- package/test/non-numeric-identifier-validator.ts +24 -0
- package/test/numeric-identifier-creator.ts +132 -0
- package/test/numeric-identifier-validator.ts +23 -0
- package/test/prefix-manager.test.ts +112 -0
- package/test/serializable-numeric-identifier-creator.ts +56 -0
- package/test/serializable-numeric-identifier-validator.ts +24 -0
- package/test/setup.ts +4 -0
- package/test/sparse.test.ts +56 -0
- package/test/utility.ts +22 -0
- package/test/validator.test.ts +52 -0
- package/test/variable-measure-rcn.test.ts +201 -0
- package/vitest.config.ts +7 -0
- package/dist/idkey.d.ts +0 -1346
- package/dist/idkey.d.ts.map +0 -1
- package/dist/idkey.js +0 -2024
- package/dist/idkey.js.map +0 -1
- package/src/idkey.ts +0 -2532
- package/test/idkey.test.ts +0 -1247
package/test/idkey.test.ts
DELETED
|
@@ -1,1247 +0,0 @@
|
|
|
1
|
-
import { I18nEnvironment } from "@aidc-toolkit/core";
|
|
2
|
-
import { CharacterSetCreator, Exclusion, NUMERIC_CREATOR, Sequence } from "@aidc-toolkit/utility";
|
|
3
|
-
import { describe, expect, test } from "vitest";
|
|
4
|
-
import {
|
|
5
|
-
AI39_CREATOR,
|
|
6
|
-
AI82_CREATOR,
|
|
7
|
-
ContentCharacterSet,
|
|
8
|
-
CPID_VALIDATOR,
|
|
9
|
-
GCN_VALIDATOR,
|
|
10
|
-
GDTI_VALIDATOR,
|
|
11
|
-
GIAI_VALIDATOR,
|
|
12
|
-
GINC_VALIDATOR,
|
|
13
|
-
GLN_VALIDATOR,
|
|
14
|
-
GMN_VALIDATOR,
|
|
15
|
-
GRAI_VALIDATOR,
|
|
16
|
-
GSIN_VALIDATOR,
|
|
17
|
-
GSRN_VALIDATOR,
|
|
18
|
-
GTIN12_VALIDATOR,
|
|
19
|
-
GTIN13_VALIDATOR,
|
|
20
|
-
GTIN8_VALIDATOR,
|
|
21
|
-
GTIN_VALIDATORS,
|
|
22
|
-
GTINCreator,
|
|
23
|
-
GTINLevel,
|
|
24
|
-
GTINType,
|
|
25
|
-
GTINValidator,
|
|
26
|
-
hasValidCheckCharacterPair,
|
|
27
|
-
hasValidCheckDigit,
|
|
28
|
-
i18nGS1Init,
|
|
29
|
-
IdentificationKeyType,
|
|
30
|
-
type IdentificationKeyValidator,
|
|
31
|
-
isValidPriceOrWeightCheckDigit,
|
|
32
|
-
LeaderType,
|
|
33
|
-
type NonGTINNumericIdentificationKeyCreator,
|
|
34
|
-
type NonGTINNumericIdentificationKeyValidator,
|
|
35
|
-
type NonNumericIdentificationKeyCreator,
|
|
36
|
-
type NonNumericIdentificationKeyValidator,
|
|
37
|
-
type NumericIdentificationKeyCreator,
|
|
38
|
-
type NumericIdentificationKeyValidator,
|
|
39
|
-
PrefixManager,
|
|
40
|
-
PrefixType,
|
|
41
|
-
type RCNReference,
|
|
42
|
-
type SerializableNumericIdentificationKeyCreator,
|
|
43
|
-
type SerializableNumericIdentificationKeyValidator,
|
|
44
|
-
SSCC_VALIDATOR
|
|
45
|
-
} from "../src";
|
|
46
|
-
|
|
47
|
-
await i18nGS1Init(I18nEnvironment.CLI);
|
|
48
|
-
|
|
49
|
-
function creatorFor(characterSet: ContentCharacterSet): CharacterSetCreator {
|
|
50
|
-
let creator: CharacterSetCreator;
|
|
51
|
-
|
|
52
|
-
switch (characterSet) {
|
|
53
|
-
case ContentCharacterSet.Numeric:
|
|
54
|
-
creator = NUMERIC_CREATOR;
|
|
55
|
-
break;
|
|
56
|
-
|
|
57
|
-
case ContentCharacterSet.AI82:
|
|
58
|
-
creator = AI82_CREATOR;
|
|
59
|
-
break;
|
|
60
|
-
|
|
61
|
-
case ContentCharacterSet.AI39:
|
|
62
|
-
creator = AI39_CREATOR;
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return creator;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function validateIdentificationKeyValidator(creator: IdentificationKeyValidator, identificationKeyType: IdentificationKeyType, prefixType: PrefixType, length: number): void {
|
|
70
|
-
expect(creator.identificationKeyType).toBe(identificationKeyType);
|
|
71
|
-
expect(creator.prefixType).toBe(prefixType);
|
|
72
|
-
expect(creator.length).toBe(length);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function validateNumericIdentificationKeyValidator(validator: NumericIdentificationKeyValidator, isCreator: boolean, identificationKeyType: IdentificationKeyType, prefixType: PrefixType, length: number, leaderType: LeaderType): void {
|
|
76
|
-
validateIdentificationKeyValidator(validator, identificationKeyType, prefixType, length);
|
|
77
|
-
|
|
78
|
-
expect(validator.leaderType).toBe(leaderType);
|
|
79
|
-
expect(validator.referenceCharacterSet).toBe(ContentCharacterSet.Numeric);
|
|
80
|
-
expect(validator.referenceCreator).toBe(NUMERIC_CREATOR);
|
|
81
|
-
|
|
82
|
-
if (isCreator) {
|
|
83
|
-
expect((validator as NumericIdentificationKeyCreator).referenceCreator).toBe(NUMERIC_CREATOR);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function validateGTINValidator(validator: GTINValidator, isCreator: boolean, gtinType: GTINType): void {
|
|
88
|
-
let prefixType: PrefixType;
|
|
89
|
-
|
|
90
|
-
switch (gtinType) {
|
|
91
|
-
case GTINType.GTIN13:
|
|
92
|
-
prefixType = PrefixType.GS1CompanyPrefix;
|
|
93
|
-
break;
|
|
94
|
-
|
|
95
|
-
case GTINType.GTIN12:
|
|
96
|
-
prefixType = PrefixType.UPCCompanyPrefix;
|
|
97
|
-
break;
|
|
98
|
-
|
|
99
|
-
case GTINType.GTIN8:
|
|
100
|
-
prefixType = PrefixType.GS18Prefix;
|
|
101
|
-
break;
|
|
102
|
-
|
|
103
|
-
default:
|
|
104
|
-
throw new Error("Not supported");
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
validateNumericIdentificationKeyValidator(validator, isCreator, IdentificationKeyType.GTIN, prefixType, gtinType, LeaderType.IndicatorDigit);
|
|
108
|
-
|
|
109
|
-
expect(validator.gtinType).toBe(gtinType);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function validateNonGTINNumericIdentificationKeyValidator(validator: NonGTINNumericIdentificationKeyValidator, isCreator: boolean, identificationKeyType: IdentificationKeyType, length: number, leaderType: LeaderType): void {
|
|
113
|
-
validateNumericIdentificationKeyValidator(validator, isCreator, identificationKeyType, PrefixType.GS1CompanyPrefix, length, leaderType);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function validateSerializableNumericIdentificationKeyValidator(validator: SerializableNumericIdentificationKeyValidator, isCreator: boolean, identificationKeyType: IdentificationKeyType, length: number, leaderType: LeaderType, serialLength: number, serialCharacterSet: ContentCharacterSet): void {
|
|
117
|
-
validateNonGTINNumericIdentificationKeyValidator(validator, isCreator, identificationKeyType, length, leaderType);
|
|
118
|
-
|
|
119
|
-
const serialCreator = creatorFor(serialCharacterSet);
|
|
120
|
-
|
|
121
|
-
expect(validator.serialComponentLength).toBe(serialLength);
|
|
122
|
-
expect(validator.serialComponentCharacterSet).toBe(serialCharacterSet);
|
|
123
|
-
expect(validator.serialComponentCreator).toBe(serialCreator);
|
|
124
|
-
|
|
125
|
-
if (isCreator) {
|
|
126
|
-
expect((validator as SerializableNumericIdentificationKeyCreator).serialComponentCreator).toBe(serialCreator);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function validateNonNumericIdentificationKeyValidator(validator: NonNumericIdentificationKeyValidator, isCreator: boolean, identificationKeyType: IdentificationKeyType, length: number, referenceCharacterSet: ContentCharacterSet, requiresCheckCharacterPair: boolean): void {
|
|
131
|
-
validateIdentificationKeyValidator(validator, identificationKeyType, PrefixType.GS1CompanyPrefix, length);
|
|
132
|
-
|
|
133
|
-
const referenceCreator = creatorFor(referenceCharacterSet);
|
|
134
|
-
|
|
135
|
-
expect(validator.referenceCharacterSet).toBe(referenceCharacterSet);
|
|
136
|
-
expect(validator.referenceCreator).toBe(referenceCreator);
|
|
137
|
-
expect(validator.requiresCheckCharacterPair).toBe(requiresCheckCharacterPair);
|
|
138
|
-
|
|
139
|
-
if (isCreator) {
|
|
140
|
-
expect((validator as NonNumericIdentificationKeyCreator).referenceCreator).toBe(referenceCreator);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
describe("Validators", () => {
|
|
145
|
-
test("GTIN", () => {
|
|
146
|
-
expect(GTIN_VALIDATORS[PrefixType.GS1CompanyPrefix]).toBe(GTIN13_VALIDATOR);
|
|
147
|
-
expect(GTIN_VALIDATORS[PrefixType.UPCCompanyPrefix]).toBe(GTIN12_VALIDATOR);
|
|
148
|
-
expect(GTIN_VALIDATORS[PrefixType.GS18Prefix]).toBe(GTIN8_VALIDATOR);
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
test("Structure", () => {
|
|
152
|
-
validateGTINValidator(GTIN13_VALIDATOR, false, GTINType.GTIN13);
|
|
153
|
-
validateGTINValidator(GTIN12_VALIDATOR, false, GTINType.GTIN12);
|
|
154
|
-
validateGTINValidator(GTIN8_VALIDATOR, false, GTINType.GTIN8);
|
|
155
|
-
validateNonGTINNumericIdentificationKeyValidator(GLN_VALIDATOR, false, IdentificationKeyType.GLN, 13, LeaderType.None);
|
|
156
|
-
validateNonGTINNumericIdentificationKeyValidator(SSCC_VALIDATOR, false, IdentificationKeyType.SSCC, 18, LeaderType.ExtensionDigit);
|
|
157
|
-
validateSerializableNumericIdentificationKeyValidator(GRAI_VALIDATOR, false, IdentificationKeyType.GRAI, 13, LeaderType.None, 16, ContentCharacterSet.AI82);
|
|
158
|
-
validateNonNumericIdentificationKeyValidator(GIAI_VALIDATOR, false, IdentificationKeyType.GIAI, 30, ContentCharacterSet.AI82, false);
|
|
159
|
-
validateNonGTINNumericIdentificationKeyValidator(GSRN_VALIDATOR, false, IdentificationKeyType.GSRN, 18, LeaderType.None);
|
|
160
|
-
validateSerializableNumericIdentificationKeyValidator(GDTI_VALIDATOR, false, IdentificationKeyType.GDTI, 13, LeaderType.None, 17, ContentCharacterSet.AI82);
|
|
161
|
-
validateNonNumericIdentificationKeyValidator(GINC_VALIDATOR, false, IdentificationKeyType.GINC, 30, ContentCharacterSet.AI82, false);
|
|
162
|
-
validateNonGTINNumericIdentificationKeyValidator(GSIN_VALIDATOR, false, IdentificationKeyType.GSIN, 17, LeaderType.None);
|
|
163
|
-
validateSerializableNumericIdentificationKeyValidator(GCN_VALIDATOR, false, IdentificationKeyType.GCN, 13, LeaderType.None, 12, ContentCharacterSet.Numeric);
|
|
164
|
-
validateNonNumericIdentificationKeyValidator(CPID_VALIDATOR, false, IdentificationKeyType.CPID, 30, ContentCharacterSet.AI39, false);
|
|
165
|
-
validateNonNumericIdentificationKeyValidator(GMN_VALIDATOR, false, IdentificationKeyType.GMN, 25, ContentCharacterSet.AI82, true);
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
function validateIdentificationKeyCreators(prefixManager: PrefixManager): void {
|
|
170
|
-
let gtinType: GTINType;
|
|
171
|
-
|
|
172
|
-
switch (prefixManager.prefixType) {
|
|
173
|
-
case PrefixType.GS1CompanyPrefix:
|
|
174
|
-
expect(prefixManager.prefix).toBe(prefixManager.gs1CompanyPrefix);
|
|
175
|
-
gtinType = GTINType.GTIN13;
|
|
176
|
-
break;
|
|
177
|
-
|
|
178
|
-
case PrefixType.UPCCompanyPrefix:
|
|
179
|
-
expect(prefixManager.prefix).toBe(prefixManager.upcCompanyPrefix);
|
|
180
|
-
gtinType = GTINType.GTIN12;
|
|
181
|
-
break;
|
|
182
|
-
|
|
183
|
-
case PrefixType.GS18Prefix:
|
|
184
|
-
expect(prefixManager.prefix).toBe(prefixManager.gs18Prefix);
|
|
185
|
-
gtinType = GTINType.GTIN8;
|
|
186
|
-
break;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
expect(prefixManager.gtinCreator).toBe(prefixManager.gtinCreator);
|
|
190
|
-
|
|
191
|
-
validateGTINValidator(prefixManager.gtinCreator, true, gtinType);
|
|
192
|
-
|
|
193
|
-
if (prefixManager.prefixType !== PrefixType.GS18Prefix) {
|
|
194
|
-
expect(prefixManager.glnCreator).toBe(prefixManager.glnCreator);
|
|
195
|
-
expect(prefixManager.ssccCreator).toBe(prefixManager.ssccCreator);
|
|
196
|
-
expect(prefixManager.graiCreator).toBe(prefixManager.graiCreator);
|
|
197
|
-
expect(prefixManager.giaiCreator).toBe(prefixManager.giaiCreator);
|
|
198
|
-
expect(prefixManager.gsrnCreator).toBe(prefixManager.gsrnCreator);
|
|
199
|
-
expect(prefixManager.gdtiCreator).toBe(prefixManager.gdtiCreator);
|
|
200
|
-
expect(prefixManager.gincCreator).toBe(prefixManager.gincCreator);
|
|
201
|
-
expect(prefixManager.gsinCreator).toBe(prefixManager.gsinCreator);
|
|
202
|
-
expect(prefixManager.gcnCreator).toBe(prefixManager.gcnCreator);
|
|
203
|
-
expect(prefixManager.cpidCreator).toBe(prefixManager.cpidCreator);
|
|
204
|
-
expect(prefixManager.gmnCreator).toBe(prefixManager.gmnCreator);
|
|
205
|
-
|
|
206
|
-
validateNonGTINNumericIdentificationKeyValidator(prefixManager.glnCreator, true, IdentificationKeyType.GLN, 13, LeaderType.None);
|
|
207
|
-
validateNonGTINNumericIdentificationKeyValidator(prefixManager.ssccCreator, true, IdentificationKeyType.SSCC, 18, LeaderType.ExtensionDigit);
|
|
208
|
-
validateSerializableNumericIdentificationKeyValidator(prefixManager.graiCreator, true, IdentificationKeyType.GRAI, 13, LeaderType.None, 16, ContentCharacterSet.AI82);
|
|
209
|
-
validateNonNumericIdentificationKeyValidator(prefixManager.giaiCreator, true, IdentificationKeyType.GIAI, 30, ContentCharacterSet.AI82, false);
|
|
210
|
-
validateNonGTINNumericIdentificationKeyValidator(prefixManager.gsrnCreator, true, IdentificationKeyType.GSRN, 18, LeaderType.None);
|
|
211
|
-
validateSerializableNumericIdentificationKeyValidator(prefixManager.gdtiCreator, true, IdentificationKeyType.GDTI, 13, LeaderType.None, 17, ContentCharacterSet.AI82);
|
|
212
|
-
validateNonNumericIdentificationKeyValidator(prefixManager.gincCreator, true, IdentificationKeyType.GINC, 30, ContentCharacterSet.AI82, false);
|
|
213
|
-
validateNonGTINNumericIdentificationKeyValidator(prefixManager.gsinCreator, true, IdentificationKeyType.GSIN, 17, LeaderType.None);
|
|
214
|
-
validateSerializableNumericIdentificationKeyValidator(prefixManager.gcnCreator, true, IdentificationKeyType.GCN, 13, LeaderType.None, 12, ContentCharacterSet.Numeric);
|
|
215
|
-
validateNonNumericIdentificationKeyValidator(prefixManager.cpidCreator, true, IdentificationKeyType.CPID, 30, ContentCharacterSet.AI39, false);
|
|
216
|
-
validateNonNumericIdentificationKeyValidator(prefixManager.gmnCreator, true, IdentificationKeyType.GMN, 25, ContentCharacterSet.AI82, true);
|
|
217
|
-
} else {
|
|
218
|
-
expect(() => prefixManager.glnCreator).toThrow("GLN not supported by GS1-8 Prefix");
|
|
219
|
-
expect(() => prefixManager.ssccCreator).toThrow("SSCC not supported by GS1-8 Prefix");
|
|
220
|
-
expect(() => prefixManager.graiCreator).toThrow("GRAI not supported by GS1-8 Prefix");
|
|
221
|
-
expect(() => prefixManager.giaiCreator).toThrow("GIAI not supported by GS1-8 Prefix");
|
|
222
|
-
expect(() => prefixManager.gsrnCreator).toThrow("GSRN not supported by GS1-8 Prefix");
|
|
223
|
-
expect(() => prefixManager.gdtiCreator).toThrow("GDTI not supported by GS1-8 Prefix");
|
|
224
|
-
expect(() => prefixManager.gincCreator).toThrow("GINC not supported by GS1-8 Prefix");
|
|
225
|
-
expect(() => prefixManager.gsinCreator).toThrow("GSIN not supported by GS1-8 Prefix");
|
|
226
|
-
expect(() => prefixManager.gcnCreator).toThrow("GCN not supported by GS1-8 Prefix");
|
|
227
|
-
expect(() => prefixManager.cpidCreator).toThrow("CPID not supported by GS1-8 Prefix");
|
|
228
|
-
expect(() => prefixManager.gmnCreator).toThrow("GMN not supported by GS1-8 Prefix");
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
describe("Prefix manager", () => {
|
|
233
|
-
let prefixManager: PrefixManager;
|
|
234
|
-
|
|
235
|
-
function validateGTINStartsWithPrefix(length: number): void {
|
|
236
|
-
expect(prefixManager.gtinCreator.length).toBe(length);
|
|
237
|
-
|
|
238
|
-
const gtin = prefixManager.gtinCreator.create(0);
|
|
239
|
-
|
|
240
|
-
expect(gtin.startsWith(prefixManager.prefix)).toBe(true);
|
|
241
|
-
expect(gtin.length).toBe(length);
|
|
242
|
-
|
|
243
|
-
const gtin14 = prefixManager.gtinCreator.createGTIN14("5", 0);
|
|
244
|
-
|
|
245
|
-
expect(gtin14.startsWith("5" + prefixManager.gs1CompanyPrefix)).toBe(true);
|
|
246
|
-
expect(gtin14.length).toBe(14);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
function validateNonGTINStartsWithGS1CompanyPrefix(): void {
|
|
250
|
-
const gln = prefixManager.glnCreator.create(0);
|
|
251
|
-
|
|
252
|
-
expect(gln.startsWith(prefixManager.gs1CompanyPrefix)).toBe(true);
|
|
253
|
-
expect(gln.length).toBe(prefixManager.glnCreator.length);
|
|
254
|
-
|
|
255
|
-
const grai = prefixManager.graiCreator.createSerialized(0, "1234");
|
|
256
|
-
|
|
257
|
-
expect(grai.startsWith(prefixManager.gs1CompanyPrefix)).toBe(true);
|
|
258
|
-
expect(grai.length).toBe(prefixManager.graiCreator.length + 4);
|
|
259
|
-
|
|
260
|
-
const giai = prefixManager.giaiCreator.create("1234");
|
|
261
|
-
|
|
262
|
-
expect(giai.startsWith(prefixManager.gs1CompanyPrefix)).toBe(true);
|
|
263
|
-
expect(giai.length).toBe(prefixManager.gs1CompanyPrefix.length + 4);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
test("Prefix equivalence", () => {
|
|
267
|
-
expect(PrefixManager.get(PrefixType.GS1CompanyPrefix, "9521234")).toBe(PrefixManager.get(PrefixType.GS1CompanyPrefix, "9521234"));
|
|
268
|
-
|
|
269
|
-
expect(PrefixManager.get(PrefixType.UPCCompanyPrefix, "614141")).toBe(PrefixManager.get(PrefixType.GS1CompanyPrefix, "0614141"));
|
|
270
|
-
|
|
271
|
-
expect(PrefixManager.get(PrefixType.GS18Prefix, "952")).toBe(PrefixManager.get(PrefixType.GS1CompanyPrefix, "00000952"));
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
test("GS1 Company Prefix 9521234", () => {
|
|
275
|
-
prefixManager = PrefixManager.get(PrefixType.GS1CompanyPrefix, "9521234");
|
|
276
|
-
|
|
277
|
-
expect(prefixManager.prefixType).toBe(PrefixType.GS1CompanyPrefix);
|
|
278
|
-
expect(prefixManager.prefix).toBe("9521234");
|
|
279
|
-
expect(prefixManager.gs1CompanyPrefix).toBe(prefixManager.prefix);
|
|
280
|
-
expect(prefixManager.upcCompanyPrefix).toBeUndefined();
|
|
281
|
-
expect(prefixManager.gs18Prefix).toBeUndefined();
|
|
282
|
-
|
|
283
|
-
validateGTINStartsWithPrefix(13);
|
|
284
|
-
validateNonGTINStartsWithGS1CompanyPrefix();
|
|
285
|
-
|
|
286
|
-
validateIdentificationKeyCreators(prefixManager);
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
test("U.P.C. Company Prefix 614141", () => {
|
|
290
|
-
prefixManager = PrefixManager.get(PrefixType.GS1CompanyPrefix, "0614141");
|
|
291
|
-
|
|
292
|
-
expect(prefixManager.prefixType).toBe(PrefixType.UPCCompanyPrefix);
|
|
293
|
-
expect(prefixManager.prefix).toBe("614141");
|
|
294
|
-
expect(prefixManager.gs1CompanyPrefix).toBe("0" + prefixManager.prefix);
|
|
295
|
-
expect(prefixManager.upcCompanyPrefix).toBe(prefixManager.prefix);
|
|
296
|
-
expect(prefixManager.gs18Prefix).toBeUndefined();
|
|
297
|
-
|
|
298
|
-
validateGTINStartsWithPrefix(12);
|
|
299
|
-
validateNonGTINStartsWithGS1CompanyPrefix();
|
|
300
|
-
|
|
301
|
-
validateIdentificationKeyCreators(prefixManager);
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
test("GS1-8 Prefix 952", () => {
|
|
305
|
-
prefixManager = PrefixManager.get(PrefixType.GS1CompanyPrefix, "00000952");
|
|
306
|
-
|
|
307
|
-
expect(prefixManager.prefixType).toBe(PrefixType.GS18Prefix);
|
|
308
|
-
expect(prefixManager.prefix).toBe("952");
|
|
309
|
-
expect(prefixManager.gs1CompanyPrefix).toBe("00000" + prefixManager.prefix);
|
|
310
|
-
expect(prefixManager.upcCompanyPrefix).toBeUndefined();
|
|
311
|
-
expect(prefixManager.gs18Prefix).toBe(prefixManager.prefix);
|
|
312
|
-
|
|
313
|
-
validateGTINStartsWithPrefix(8);
|
|
314
|
-
|
|
315
|
-
validateIdentificationKeyCreators(prefixManager);
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
test("Prefix validation", () => {
|
|
319
|
-
expect(() => PrefixManager.get(PrefixType.GS1CompanyPrefix, "952")).toThrow("Length 3 of GS1 Company Prefix must be greater than or equal to 4");
|
|
320
|
-
expect(() => PrefixManager.get(PrefixType.GS1CompanyPrefix, "9520")).not.toThrow(RangeError);
|
|
321
|
-
expect(() => PrefixManager.get(PrefixType.GS1CompanyPrefix, "952123456789")).not.toThrow(RangeError);
|
|
322
|
-
expect(() => PrefixManager.get(PrefixType.GS1CompanyPrefix, "9521234567890")).toThrow("Length 13 of GS1 Company Prefix must be less than or equal to 12");
|
|
323
|
-
|
|
324
|
-
expect(() => PrefixManager.get(PrefixType.GS1CompanyPrefix, "952123A56789")).toThrow("Invalid character 'A' at position 7 of GS1 Company Prefix");
|
|
325
|
-
|
|
326
|
-
expect(() => PrefixManager.get(PrefixType.UPCCompanyPrefix, "61414")).toThrow("Length 5 of U.P.C. Company Prefix must be greater than or equal to 6");
|
|
327
|
-
expect(() => PrefixManager.get(PrefixType.UPCCompanyPrefix, "614141")).not.toThrow(RangeError);
|
|
328
|
-
expect(() => PrefixManager.get(PrefixType.UPCCompanyPrefix, "61414112345")).not.toThrow(RangeError);
|
|
329
|
-
expect(() => PrefixManager.get(PrefixType.UPCCompanyPrefix, "614141123456")).toThrow("Length 12 of U.P.C. Company Prefix must be less than or equal to 11");
|
|
330
|
-
expect(() => PrefixManager.get(PrefixType.UPCCompanyPrefix, "000614")).not.toThrow(RangeError);
|
|
331
|
-
expect(() => PrefixManager.get(PrefixType.UPCCompanyPrefix, "000061")).toThrow("U.P.C. Company Prefix can't start with \"0000\"");
|
|
332
|
-
|
|
333
|
-
expect(() => PrefixManager.get(PrefixType.GS1CompanyPrefix, "00000952")).not.toThrow(RangeError);
|
|
334
|
-
expect(() => PrefixManager.get(PrefixType.GS1CompanyPrefix, "000000952")).toThrow("GS1 Company Prefix can't start with \"000000\"");
|
|
335
|
-
|
|
336
|
-
expect(() => PrefixManager.get(PrefixType.GS18Prefix, "952")).not.toThrow(RangeError);
|
|
337
|
-
expect(() => PrefixManager.get(PrefixType.GS18Prefix, "0952")).toThrow("GS1-8 Prefix can't start with \"0\"");
|
|
338
|
-
});
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
describe("Sparse creation", () => {
|
|
342
|
-
const prefixManager = PrefixManager.get(PrefixType.GS1CompanyPrefix, "9521234");
|
|
343
|
-
|
|
344
|
-
const gtin1 = prefixManager.gtinCreator.create(0, true);
|
|
345
|
-
const gln1 = prefixManager.glnCreator.create(0, true);
|
|
346
|
-
|
|
347
|
-
test("Same length 1, not equal", () => {
|
|
348
|
-
expect(gln1.length).toBe(gtin1.length);
|
|
349
|
-
expect(gln1).not.toBe(gtin1);
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
prefixManager.tweakFactor = 123456;
|
|
353
|
-
|
|
354
|
-
const gtin2 = prefixManager.gtinCreator.create(0, true);
|
|
355
|
-
const gln2 = prefixManager.glnCreator.create(0, true);
|
|
356
|
-
|
|
357
|
-
test("Same length 2, not equal", () => {
|
|
358
|
-
expect(gln2.length).toBe(gtin2.length);
|
|
359
|
-
expect(gln2).not.toBe(gtin2);
|
|
360
|
-
});
|
|
361
|
-
|
|
362
|
-
test("Same types 1 and 2, not equal", () => {
|
|
363
|
-
expect(gtin2).not.toBe(gtin1);
|
|
364
|
-
expect(gln2).not.toBe(gln1);
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
prefixManager.resetTweakFactor();
|
|
368
|
-
|
|
369
|
-
const gtin3 = prefixManager.gtinCreator.create(0, true);
|
|
370
|
-
const gln3 = prefixManager.glnCreator.create(0, true);
|
|
371
|
-
|
|
372
|
-
test("Same length 3, not equal", () => {
|
|
373
|
-
expect(gln3.length).toBe(gtin3.length);
|
|
374
|
-
expect(gln3).not.toBe(gtin3);
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
test("Same types 1 and 3, equal", () => {
|
|
378
|
-
expect(gtin3).toBe(gtin1);
|
|
379
|
-
expect(gln3).toBe(gln1);
|
|
380
|
-
});
|
|
381
|
-
|
|
382
|
-
prefixManager.tweakFactor = 0;
|
|
383
|
-
|
|
384
|
-
const sparseGTINs = Array.from(prefixManager.gtinCreator.create(new Sequence(0, 10), true));
|
|
385
|
-
const straightGTINs = Array.from(prefixManager.gtinCreator.create(new Sequence(0, 10)));
|
|
386
|
-
|
|
387
|
-
test("Tweak factor 0", () => {
|
|
388
|
-
expect(sparseGTINs).toStrictEqual(straightGTINs);
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
prefixManager.resetTweakFactor();
|
|
392
|
-
});
|
|
393
|
-
|
|
394
|
-
function testIdentificationKeyCreatorCallback(callback?: () => void): void {
|
|
395
|
-
if (callback !== undefined) {
|
|
396
|
-
callback();
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
function testNumericIdentificationKeyCreator(creator: NumericIdentificationKeyCreator, preTestCallback?: () => void, postTestCallback?: () => void): void {
|
|
401
|
-
describe(creator.identificationKeyType === IdentificationKeyType.GTIN ? `${creator.identificationKeyType}-${creator.length}` : creator.identificationKeyType, () => {
|
|
402
|
-
testIdentificationKeyCreatorCallback(preTestCallback);
|
|
403
|
-
|
|
404
|
-
const prefix = creator.prefix;
|
|
405
|
-
const prefixLength = prefix.length;
|
|
406
|
-
const hasExtensionDigit = creator.leaderType === LeaderType.ExtensionDigit;
|
|
407
|
-
const prefixSubstringStart = Number(hasExtensionDigit);
|
|
408
|
-
const prefixSubstringEnd = prefixSubstringStart + prefixLength;
|
|
409
|
-
const referenceLength = creator.length - prefixLength - 1;
|
|
410
|
-
const referenceCount = Number(CharacterSetCreator.powerOf10(referenceLength));
|
|
411
|
-
const referenceSubstringStart = prefixSubstringEnd;
|
|
412
|
-
const referenceSubstringEnd = referenceSubstringStart + referenceLength - prefixSubstringStart;
|
|
413
|
-
|
|
414
|
-
function validate(identificationKey: string, index: number, sparse: boolean): void {
|
|
415
|
-
expect(() => {
|
|
416
|
-
creator.validate(identificationKey);
|
|
417
|
-
}).not.toThrow(RangeError);
|
|
418
|
-
expect(identificationKey).toBe(creator.create(index, sparse));
|
|
419
|
-
|
|
420
|
-
expect(identificationKey.length).toBe(creator.length);
|
|
421
|
-
expect(identificationKey.substring(prefixSubstringStart, prefixSubstringEnd)).toBe(prefix);
|
|
422
|
-
expect(hasValidCheckDigit(identificationKey)).toBe(true);
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
test("Straight", {
|
|
426
|
-
// Test can take a long time.
|
|
427
|
-
timeout: 20 * 1000
|
|
428
|
-
}, () => {
|
|
429
|
-
expect(creator.referenceLength).toBe(referenceLength);
|
|
430
|
-
expect(creator.capacity).toBe(Number(CharacterSetCreator.powerOf10(referenceLength)));
|
|
431
|
-
|
|
432
|
-
const sequenceIterator = creator.create(new Sequence(0, referenceCount))[Symbol.iterator]();
|
|
433
|
-
|
|
434
|
-
let index = 0;
|
|
435
|
-
|
|
436
|
-
for (const identificationKey of creator.createAll()) {
|
|
437
|
-
validate(identificationKey, index, false);
|
|
438
|
-
|
|
439
|
-
expect(Number((hasExtensionDigit ? identificationKey.charAt(0) : "") + identificationKey.substring(referenceSubstringStart, referenceSubstringEnd))).toBe(index);
|
|
440
|
-
expect(sequenceIterator.next().value).toBe(identificationKey);
|
|
441
|
-
|
|
442
|
-
index++;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
expect(index).toBe(referenceCount);
|
|
446
|
-
expect(sequenceIterator.next().value).toBeUndefined();
|
|
447
|
-
|
|
448
|
-
const randomValues = new Array<number>();
|
|
449
|
-
const identificationKeys = new Array<string>();
|
|
450
|
-
|
|
451
|
-
for (let i = 0; i < 1000; i++) {
|
|
452
|
-
const randomValue = Math.floor(Math.random() * creator.capacity);
|
|
453
|
-
|
|
454
|
-
randomValues.push(randomValue);
|
|
455
|
-
identificationKeys.push(creator.create(randomValue));
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
expect(Array.from(creator.create(randomValues))).toStrictEqual(identificationKeys);
|
|
459
|
-
});
|
|
460
|
-
|
|
461
|
-
test("Sparse", () => {
|
|
462
|
-
const sparseReferenceCount = Math.min(referenceCount, 1000);
|
|
463
|
-
|
|
464
|
-
// Reference count of 1 is neither sequential nor sparse so treat it as sparse.
|
|
465
|
-
let sequential = sparseReferenceCount !== 1;
|
|
466
|
-
|
|
467
|
-
const sequenceSet = new Set<string>();
|
|
468
|
-
|
|
469
|
-
let index = 0;
|
|
470
|
-
|
|
471
|
-
for (const identificationKey of creator.create(new Sequence(0, sparseReferenceCount), true)) {
|
|
472
|
-
validate(identificationKey, index, true);
|
|
473
|
-
|
|
474
|
-
sequential &&= Number((hasExtensionDigit ? identificationKey.charAt(0) : "") + identificationKey.substring(referenceSubstringStart, referenceSubstringEnd)) === index;
|
|
475
|
-
|
|
476
|
-
expect(sequenceSet.has(identificationKey)).toBe(false);
|
|
477
|
-
sequenceSet.add(identificationKey);
|
|
478
|
-
|
|
479
|
-
index++;
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
expect(sequential).toBe(false);
|
|
483
|
-
expect(index).toBe(sparseReferenceCount);
|
|
484
|
-
|
|
485
|
-
const randomValues = new Array<number>();
|
|
486
|
-
const identificationKeys = new Array<string>();
|
|
487
|
-
|
|
488
|
-
for (let i = 0; i < 1000; i++) {
|
|
489
|
-
const randomValue = Math.floor(Math.random() * creator.capacity);
|
|
490
|
-
|
|
491
|
-
randomValues.push(randomValue);
|
|
492
|
-
identificationKeys.push(creator.create(randomValue, true));
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
expect(Array.from(creator.create(randomValues, true))).toStrictEqual(identificationKeys);
|
|
496
|
-
});
|
|
497
|
-
|
|
498
|
-
test("Validation position", () => {
|
|
499
|
-
const identificationKey = creator.create(0);
|
|
500
|
-
|
|
501
|
-
const badIdentificationKey1 = `${identificationKey.substring(0, identificationKey.length - 2)}O${identificationKey.substring(identificationKey.length - 1)}`;
|
|
502
|
-
|
|
503
|
-
expect(badIdentificationKey1.length).toBe(creator.length);
|
|
504
|
-
expect(() => {
|
|
505
|
-
creator.validate(badIdentificationKey1);
|
|
506
|
-
}).toThrow(`Invalid character 'O' at position ${creator.length - 1}`);
|
|
507
|
-
|
|
508
|
-
const badIdentificationKey2 = `${identificationKey.substring(0, 2)}O${identificationKey.substring(3)}`;
|
|
509
|
-
|
|
510
|
-
expect(badIdentificationKey2.length).toBe(creator.length);
|
|
511
|
-
expect(() => {
|
|
512
|
-
creator.validate(badIdentificationKey2);
|
|
513
|
-
}).toThrow("Invalid character 'O' at position 3");
|
|
514
|
-
});
|
|
515
|
-
|
|
516
|
-
test("Position offset", () => {
|
|
517
|
-
expect(() => {
|
|
518
|
-
creator.validate(creator.create(0), {
|
|
519
|
-
positionOffset: 4
|
|
520
|
-
});
|
|
521
|
-
}).not.toThrow(RangeError);
|
|
522
|
-
});
|
|
523
|
-
|
|
524
|
-
testIdentificationKeyCreatorCallback(postTestCallback);
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
function testGTINCreator(creator: GTINCreator): void {
|
|
529
|
-
testNumericIdentificationKeyCreator(creator, () => {
|
|
530
|
-
test("Length", () => {
|
|
531
|
-
switch (creator.prefixType) {
|
|
532
|
-
case PrefixType.GS1CompanyPrefix:
|
|
533
|
-
expect(creator.length).toBe(13);
|
|
534
|
-
break;
|
|
535
|
-
|
|
536
|
-
case PrefixType.UPCCompanyPrefix:
|
|
537
|
-
expect(creator.length).toBe(12);
|
|
538
|
-
break;
|
|
539
|
-
|
|
540
|
-
case PrefixType.GS18Prefix:
|
|
541
|
-
expect(creator.length).toBe(8);
|
|
542
|
-
break;
|
|
543
|
-
}
|
|
544
|
-
});
|
|
545
|
-
}, () => {
|
|
546
|
-
const gs1CompanyPrefix = creator.prefixManager.gs1CompanyPrefix;
|
|
547
|
-
const prefix = creator.prefix;
|
|
548
|
-
const prefixLength = prefix.length;
|
|
549
|
-
const prefixSubstringStart = 14 - creator.length;
|
|
550
|
-
const prefixSubstringEnd = prefixSubstringStart + prefixLength;
|
|
551
|
-
const referenceLength = creator.length - prefixLength - 1;
|
|
552
|
-
const referenceCount = Number(CharacterSetCreator.powerOf10(referenceLength));
|
|
553
|
-
const referenceSubstringStart = prefixSubstringEnd;
|
|
554
|
-
const referenceSubstringEnd = referenceSubstringStart + referenceLength;
|
|
555
|
-
|
|
556
|
-
function validate(gtin: string, index: number, sparse: boolean): void {
|
|
557
|
-
expect(() => {
|
|
558
|
-
GTINValidator.validateGTIN14(gtin);
|
|
559
|
-
}).not.toThrow(RangeError);
|
|
560
|
-
expect(gtin).toBe(creator.createGTIN14("5", index, sparse));
|
|
561
|
-
|
|
562
|
-
expect(gtin.length).toBe(14);
|
|
563
|
-
expect(gtin.charAt(0)).toBe("5");
|
|
564
|
-
expect(gtin.substring(1, prefixSubstringEnd)).toBe(gs1CompanyPrefix);
|
|
565
|
-
expect(gtin.substring(prefixSubstringStart, prefixSubstringEnd)).toBe(prefix);
|
|
566
|
-
expect(hasValidCheckDigit(gtin)).toBe(true);
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
test("GTIN-14 straight", () => {
|
|
570
|
-
let index = 0;
|
|
571
|
-
|
|
572
|
-
for (const gtin of creator.createGTIN14("5", new Sequence(0, referenceCount))) {
|
|
573
|
-
expect(Number(gtin.substring(referenceSubstringStart, referenceSubstringEnd))).toBe(index);
|
|
574
|
-
|
|
575
|
-
validate(gtin, index, false);
|
|
576
|
-
|
|
577
|
-
index++;
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
expect(index).toBe(referenceCount);
|
|
581
|
-
|
|
582
|
-
const randomValues = new Array<number>();
|
|
583
|
-
const identificationKeys = new Array<string>();
|
|
584
|
-
|
|
585
|
-
for (let i = 0; i < 1000; i++) {
|
|
586
|
-
const randomValue = Math.floor(Math.random() * creator.capacity);
|
|
587
|
-
|
|
588
|
-
randomValues.push(randomValue);
|
|
589
|
-
identificationKeys.push(creator.createGTIN14("5", randomValue));
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
expect(Array.from(creator.createGTIN14("5", randomValues))).toStrictEqual(identificationKeys);
|
|
593
|
-
});
|
|
594
|
-
|
|
595
|
-
test("GTIN-14 sparse", () => {
|
|
596
|
-
const sparseReferenceCount = Math.min(referenceCount, 1000);
|
|
597
|
-
|
|
598
|
-
// Reference count of 1 is neither sequential nor sparse so treat it as sparse.
|
|
599
|
-
let sequential = sparseReferenceCount !== 1;
|
|
600
|
-
|
|
601
|
-
const sequenceSet = new Set<string>();
|
|
602
|
-
|
|
603
|
-
let index = 0;
|
|
604
|
-
|
|
605
|
-
for (const gtin of creator.createGTIN14("5", new Sequence(0, sparseReferenceCount), true)) {
|
|
606
|
-
sequential &&= Number(gtin.substring(referenceSubstringStart, referenceSubstringEnd)) === index;
|
|
607
|
-
|
|
608
|
-
validate(gtin, index, true);
|
|
609
|
-
|
|
610
|
-
expect(sequenceSet.has(gtin)).toBe(false);
|
|
611
|
-
sequenceSet.add(gtin);
|
|
612
|
-
|
|
613
|
-
index++;
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
expect(sequential).toBe(false);
|
|
617
|
-
expect(index).toBe(sparseReferenceCount);
|
|
618
|
-
|
|
619
|
-
const randomValues = new Array<number>();
|
|
620
|
-
const identificationKeys = new Array<string>();
|
|
621
|
-
|
|
622
|
-
for (let i = 0; i < 1000; i++) {
|
|
623
|
-
const randomValue = Math.floor(Math.random() * creator.capacity);
|
|
624
|
-
|
|
625
|
-
randomValues.push(randomValue);
|
|
626
|
-
identificationKeys.push(creator.createGTIN14("5", randomValue, true));
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
expect(Array.from(creator.createGTIN14("5", randomValues, true))).toStrictEqual(identificationKeys);
|
|
630
|
-
});
|
|
631
|
-
|
|
632
|
-
if (creator.gtinType === GTINType.GTIN12) {
|
|
633
|
-
test("Zero-suppress GTIN-12 rule 1", () => {
|
|
634
|
-
expect(GTINValidator.zeroSuppress("012345000058")).toBe("01234558");
|
|
635
|
-
expect(GTINValidator.zeroSuppress("012345000065")).toBe("01234565");
|
|
636
|
-
expect(GTINValidator.zeroSuppress("012345000072")).toBe("01234572");
|
|
637
|
-
expect(GTINValidator.zeroSuppress("012345000089")).toBe("01234589");
|
|
638
|
-
expect(GTINValidator.zeroSuppress("012345000096")).toBe("01234596");
|
|
639
|
-
});
|
|
640
|
-
|
|
641
|
-
test("Zero-suppress GTIN-12 rule 2", () => {
|
|
642
|
-
expect(GTINValidator.zeroSuppress("045670000080")).toBe("04567840");
|
|
643
|
-
});
|
|
644
|
-
|
|
645
|
-
test("Zero-suppress GTIN-12 rule 3", () => {
|
|
646
|
-
expect(GTINValidator.zeroSuppress("034000005673")).toBe("03456703");
|
|
647
|
-
expect(GTINValidator.zeroSuppress("034100005672")).toBe("03456712");
|
|
648
|
-
expect(GTINValidator.zeroSuppress("034200005671")).toBe("03456721");
|
|
649
|
-
});
|
|
650
|
-
|
|
651
|
-
test("Zero-suppress GTIN-12 rule 4", () => {
|
|
652
|
-
expect(GTINValidator.zeroSuppress("098300000752")).toBe("09837532");
|
|
653
|
-
expect(GTINValidator.zeroSuppress("098400000751")).toBe("09847531");
|
|
654
|
-
expect(GTINValidator.zeroSuppress("098500000750")).toBe("09857530");
|
|
655
|
-
expect(GTINValidator.zeroSuppress("098600000759")).toBe("09867539");
|
|
656
|
-
expect(GTINValidator.zeroSuppress("098700000758")).toBe("09877538");
|
|
657
|
-
expect(GTINValidator.zeroSuppress("098800000757")).toBe("09887537");
|
|
658
|
-
expect(GTINValidator.zeroSuppress("098900000756")).toBe("09897536");
|
|
659
|
-
});
|
|
660
|
-
|
|
661
|
-
test("Non-zero-suppressible GTIN-12 rule 1", () => {
|
|
662
|
-
expect(() => GTINValidator.zeroSuppress("012345100055")).toThrow("GTIN-12 not zero-suppressible");
|
|
663
|
-
expect(() => GTINValidator.zeroSuppress("012345010057")).toThrow("GTIN-12 not zero-suppressible");
|
|
664
|
-
expect(() => GTINValidator.zeroSuppress("012345001055")).toThrow("GTIN-12 not zero-suppressible");
|
|
665
|
-
expect(() => GTINValidator.zeroSuppress("012345000157")).toThrow("GTIN-12 not zero-suppressible");
|
|
666
|
-
expect(() => GTINValidator.zeroSuppress("012345000041")).toThrow("GTIN-12 not zero-suppressible");
|
|
667
|
-
expect(() => GTINValidator.zeroSuppress("012345000003")).toThrow("GTIN-12 not zero-suppressible");
|
|
668
|
-
});
|
|
669
|
-
|
|
670
|
-
test("Non-zero-suppressible GTIN-12 rule 2", () => {
|
|
671
|
-
expect(() => GTINValidator.zeroSuppress("045670100087")).toThrow("GTIN-12 not zero-suppressible");
|
|
672
|
-
expect(() => GTINValidator.zeroSuppress("045670010089")).toThrow("GTIN-12 not zero-suppressible");
|
|
673
|
-
expect(() => GTINValidator.zeroSuppress("045670001087")).toThrow("GTIN-12 not zero-suppressible");
|
|
674
|
-
expect(() => GTINValidator.zeroSuppress("045670000189")).toThrow("GTIN-12 not zero-suppressible");
|
|
675
|
-
});
|
|
676
|
-
|
|
677
|
-
test("Non-zero-suppressible GTIN-12 rule 3", () => {
|
|
678
|
-
expect(() => GTINValidator.zeroSuppress("034010005670")).toThrow("GTIN-12 not zero-suppressible");
|
|
679
|
-
expect(() => GTINValidator.zeroSuppress("034001005672")).toThrow("GTIN-12 not zero-suppressible");
|
|
680
|
-
expect(() => GTINValidator.zeroSuppress("034000105670")).toThrow("GTIN-12 not zero-suppressible");
|
|
681
|
-
expect(() => GTINValidator.zeroSuppress("034000015672")).toThrow("GTIN-12 not zero-suppressible");
|
|
682
|
-
});
|
|
683
|
-
|
|
684
|
-
test("Non-zero-suppressible GTIN-12 rule 4", () => {
|
|
685
|
-
expect(() => GTINValidator.zeroSuppress("098310000759")).toThrow("GTIN-12 not zero-suppressible");
|
|
686
|
-
expect(() => GTINValidator.zeroSuppress("098301000751")).toThrow("GTIN-12 not zero-suppressible");
|
|
687
|
-
expect(() => GTINValidator.zeroSuppress("098300100759")).toThrow("GTIN-12 not zero-suppressible");
|
|
688
|
-
expect(() => GTINValidator.zeroSuppress("098300010751")).toThrow("GTIN-12 not zero-suppressible");
|
|
689
|
-
expect(() => GTINValidator.zeroSuppress("098300001759")).toThrow("GTIN-12 not zero-suppressible");
|
|
690
|
-
});
|
|
691
|
-
|
|
692
|
-
test("Zero-suppress other error", () => {
|
|
693
|
-
expect(() => GTINValidator.zeroSuppress("0012345000059")).toThrow("GTIN must be 12 digits long");
|
|
694
|
-
expect(() => GTINValidator.zeroSuppress("012345000059")).toThrow("Invalid check digit");
|
|
695
|
-
expect(() => GTINValidator.zeroSuppress("112345000055")).toThrow("GTIN-12 not zero-suppressible");
|
|
696
|
-
});
|
|
697
|
-
|
|
698
|
-
test("Zero-expand GTIN-12 rule 1", () => {
|
|
699
|
-
expect(GTINValidator.zeroExpand("01234558")).toBe("012345000058");
|
|
700
|
-
expect(GTINValidator.zeroExpand("01234565")).toBe("012345000065");
|
|
701
|
-
expect(GTINValidator.zeroExpand("01234572")).toBe("012345000072");
|
|
702
|
-
expect(GTINValidator.zeroExpand("01234589")).toBe("012345000089");
|
|
703
|
-
expect(GTINValidator.zeroExpand("01234596")).toBe("012345000096");
|
|
704
|
-
expect(() => GTINValidator.zeroExpand("00000154")).toThrow("U.P.C. Company Prefix can't start with \"0000\"");
|
|
705
|
-
});
|
|
706
|
-
|
|
707
|
-
test("Zero-expand GTIN-12 rule 2", () => {
|
|
708
|
-
expect(GTINValidator.zeroExpand("04567840")).toBe("045670000080");
|
|
709
|
-
expect(() => GTINValidator.zeroExpand("00001047")).toThrow("U.P.C. Company Prefix can't start with \"0000\"");
|
|
710
|
-
});
|
|
711
|
-
|
|
712
|
-
test("Zero-expand GTIN-12 rule 3", () => {
|
|
713
|
-
expect(GTINValidator.zeroExpand("03456703")).toBe("034000005673");
|
|
714
|
-
expect(GTINValidator.zeroExpand("03456712")).toBe("034100005672");
|
|
715
|
-
expect(GTINValidator.zeroExpand("03456721")).toBe("034200005671");
|
|
716
|
-
expect(() => GTINValidator.zeroExpand("00000028")).not.toThrow(RangeError);
|
|
717
|
-
});
|
|
718
|
-
|
|
719
|
-
test("Zero-expand GTIN-12 rule 4", () => {
|
|
720
|
-
expect(GTINValidator.zeroExpand("09837532")).toBe("098300000752");
|
|
721
|
-
expect(GTINValidator.zeroExpand("09847531")).toBe("098400000751");
|
|
722
|
-
expect(GTINValidator.zeroExpand("09857530")).toBe("098500000750");
|
|
723
|
-
expect(GTINValidator.zeroExpand("09867539")).toBe("098600000759");
|
|
724
|
-
expect(GTINValidator.zeroExpand("09877538")).toBe("098700000758");
|
|
725
|
-
expect(GTINValidator.zeroExpand("09887537")).toBe("098800000757");
|
|
726
|
-
expect(GTINValidator.zeroExpand("09897536")).toBe("098900000756");
|
|
727
|
-
expect(() => GTINValidator.zeroExpand("00030037")).not.toThrow(RangeError);
|
|
728
|
-
});
|
|
729
|
-
|
|
730
|
-
test("Zero-expand error", () => {
|
|
731
|
-
expect(() => GTINValidator.zeroExpand("001234505")).toThrow("Length 9 must be less than or equal to 8");
|
|
732
|
-
expect(() => GTINValidator.zeroExpand("01234506")).toThrow("Invalid check digit");
|
|
733
|
-
expect(() => GTINValidator.zeroExpand("11234506")).toThrow("Invalid zero-suppressed GTIN-12");
|
|
734
|
-
expect(() => GTINValidator.zeroExpand("09800037")).toThrow("Invalid zero-suppressed GTIN-12");
|
|
735
|
-
expect(() => GTINValidator.zeroExpand("09800047")).toThrow("Invalid zero-suppressed GTIN-12");
|
|
736
|
-
expect(() => GTINValidator.zeroExpand("09800052")).toThrow("Invalid zero-suppressed GTIN-12");
|
|
737
|
-
});
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
test("GTIN-14", () => {
|
|
741
|
-
const gtin = creator.create(0, true);
|
|
742
|
-
|
|
743
|
-
expect(gtin.length).toBe(creator.length);
|
|
744
|
-
|
|
745
|
-
let gtin14 = GTINValidator.convertToGTIN14("0", gtin);
|
|
746
|
-
|
|
747
|
-
expect(gtin14.length).toBe(14);
|
|
748
|
-
expect(GTINValidator.normalize(gtin14)).toBe(gtin);
|
|
749
|
-
|
|
750
|
-
gtin14 = GTINValidator.convertToGTIN14("1", gtin);
|
|
751
|
-
|
|
752
|
-
expect(gtin14.length).toBe(14);
|
|
753
|
-
expect(GTINValidator.normalize(gtin14)).not.toBe(gtin);
|
|
754
|
-
|
|
755
|
-
gtin14 = GTINValidator.convertToGTIN14("2", gtin14);
|
|
756
|
-
|
|
757
|
-
expect(gtin14.length).toBe(14);
|
|
758
|
-
expect(GTINValidator.normalize(gtin14)).not.toBe(gtin);
|
|
759
|
-
});
|
|
760
|
-
});
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
function testGTINValidationAndNormalization(): void {
|
|
764
|
-
describe("GTIN validation and normalization", () => {
|
|
765
|
-
test("Validation", () => {
|
|
766
|
-
expect(() => {
|
|
767
|
-
GTINValidator.validateAny("9521873000122", GTINLevel.Any);
|
|
768
|
-
}).not.toThrow(RangeError);
|
|
769
|
-
expect(() => {
|
|
770
|
-
GTINValidator.validateAny("19521873000129", GTINLevel.Any);
|
|
771
|
-
}).not.toThrow(RangeError);
|
|
772
|
-
expect(() => {
|
|
773
|
-
GTINValidator.validateAny("9521873000160", GTINLevel.Any);
|
|
774
|
-
}).not.toThrow(RangeError);
|
|
775
|
-
expect(() => {
|
|
776
|
-
GTINValidator.validateAny("95216843", GTINLevel.Any);
|
|
777
|
-
}).not.toThrow(RangeError);
|
|
778
|
-
expect(() => {
|
|
779
|
-
GTINValidator.validateAny("95217800031", GTINLevel.Any);
|
|
780
|
-
}).toThrow("GTIN must be 13, 12, 8, or 14 digits long");
|
|
781
|
-
expect(() => {
|
|
782
|
-
GTINValidator.validateAny("614141773985", GTINLevel.Any);
|
|
783
|
-
}).not.toThrow(RangeError);
|
|
784
|
-
expect(() => {
|
|
785
|
-
GTINValidator.validateAny("614141773991", GTINLevel.Any);
|
|
786
|
-
}).toThrow("Invalid check digit");
|
|
787
|
-
expect(() => {
|
|
788
|
-
GTINValidator.validateAny("09867539", GTINLevel.Any);
|
|
789
|
-
}).not.toThrow(RangeError);
|
|
790
|
-
expect(() => {
|
|
791
|
-
GTINValidator.validateAny("09800037", GTINLevel.Any);
|
|
792
|
-
}).toThrow("Invalid zero-suppressed GTIN-12");
|
|
793
|
-
expect(() => {
|
|
794
|
-
GTINValidator.validateAny("9521873000122", GTINLevel.RetailConsumer);
|
|
795
|
-
}).not.toThrow(RangeError);
|
|
796
|
-
expect(() => {
|
|
797
|
-
GTINValidator.validateAny("19521873000129", GTINLevel.RetailConsumer);
|
|
798
|
-
}).toThrow("GTIN not supported at retail consumer trade item level");
|
|
799
|
-
expect(() => {
|
|
800
|
-
GTINValidator.validateAny("9521873000160", GTINLevel.RetailConsumer);
|
|
801
|
-
}).not.toThrow(RangeError);
|
|
802
|
-
expect(() => {
|
|
803
|
-
GTINValidator.validateAny("95216843", GTINLevel.RetailConsumer);
|
|
804
|
-
}).not.toThrow(RangeError);
|
|
805
|
-
expect(() => {
|
|
806
|
-
GTINValidator.validateAny("95217800031", GTINLevel.RetailConsumer);
|
|
807
|
-
}).toThrow("GTIN must be 13, 12, 8, or 14 digits long");
|
|
808
|
-
expect(() => {
|
|
809
|
-
GTINValidator.validateAny("614141773985", GTINLevel.RetailConsumer);
|
|
810
|
-
}).not.toThrow(RangeError);
|
|
811
|
-
expect(() => {
|
|
812
|
-
GTINValidator.validateAny("0614141773985", GTINLevel.RetailConsumer);
|
|
813
|
-
}).toThrow("GTIN-13 at retail consumer trade item level can't start with zero");
|
|
814
|
-
expect(() => {
|
|
815
|
-
GTINValidator.validateAny("614141773991", GTINLevel.RetailConsumer);
|
|
816
|
-
}).toThrow("Invalid check digit");
|
|
817
|
-
expect(() => {
|
|
818
|
-
GTINValidator.validateAny("09867539", GTINLevel.RetailConsumer);
|
|
819
|
-
}).not.toThrow(RangeError);
|
|
820
|
-
expect(() => {
|
|
821
|
-
GTINValidator.validateAny("09800037", GTINLevel.RetailConsumer);
|
|
822
|
-
}).toThrow("Invalid zero-suppressed GTIN-12");
|
|
823
|
-
expect(() => {
|
|
824
|
-
GTINValidator.validateAny("9521873000122", GTINLevel.OtherThanRetailConsumer);
|
|
825
|
-
}).not.toThrow(RangeError);
|
|
826
|
-
expect(() => {
|
|
827
|
-
GTINValidator.validateAny("19521873000129", GTINLevel.OtherThanRetailConsumer);
|
|
828
|
-
}).not.toThrow(RangeError);
|
|
829
|
-
expect(() => {
|
|
830
|
-
GTINValidator.validateAny("9521873000160", GTINLevel.OtherThanRetailConsumer);
|
|
831
|
-
}).not.toThrow(RangeError);
|
|
832
|
-
expect(() => {
|
|
833
|
-
GTINValidator.validateAny("95216843", GTINLevel.OtherThanRetailConsumer);
|
|
834
|
-
}).toThrow("GTIN not supported at other than retail consumer trade item level");
|
|
835
|
-
expect(() => {
|
|
836
|
-
GTINValidator.validateAny("95217800031", GTINLevel.OtherThanRetailConsumer);
|
|
837
|
-
}).toThrow("GTIN must be 13, 12, 8, or 14 digits long");
|
|
838
|
-
expect(() => {
|
|
839
|
-
GTINValidator.validateAny("614141773985", GTINLevel.OtherThanRetailConsumer);
|
|
840
|
-
}).not.toThrow(RangeError);
|
|
841
|
-
expect(() => {
|
|
842
|
-
GTINValidator.validateAny("614141773991", GTINLevel.OtherThanRetailConsumer);
|
|
843
|
-
}).toThrow("Invalid check digit");
|
|
844
|
-
expect(() => {
|
|
845
|
-
GTINValidator.validateAny("09867539", GTINLevel.OtherThanRetailConsumer);
|
|
846
|
-
}).toThrow("GTIN not supported at other than retail consumer trade item level");
|
|
847
|
-
expect(() => {
|
|
848
|
-
GTINValidator.validateAny("09800037", GTINLevel.OtherThanRetailConsumer);
|
|
849
|
-
}).toThrow("Invalid zero-suppressed GTIN-12");
|
|
850
|
-
});
|
|
851
|
-
|
|
852
|
-
test("Normalization", () => {
|
|
853
|
-
// GTIN-14.
|
|
854
|
-
expect(GTINValidator.normalize("09526543219996")).toBe("9526543219996");
|
|
855
|
-
expect(GTINValidator.normalize("00614141009992")).toBe("614141009992");
|
|
856
|
-
expect(() => GTINValidator.normalize("00000001234505")).toThrow("Invalid zero-suppressed GTIN-12 as GTIN-14");
|
|
857
|
-
expect(GTINValidator.normalize("00000095209999")).toBe("95209999");
|
|
858
|
-
expect(GTINValidator.normalize("49526543219994")).toBe("49526543219994");
|
|
859
|
-
|
|
860
|
-
// GTIN-13.
|
|
861
|
-
expect(GTINValidator.normalize("9526543219996")).toBe("9526543219996");
|
|
862
|
-
expect(GTINValidator.normalize("0614141009992")).toBe("614141009992");
|
|
863
|
-
expect(() => GTINValidator.normalize("0000001234505")).toThrow("Invalid zero-suppressed GTIN-12 as GTIN-13");
|
|
864
|
-
expect(GTINValidator.normalize("0000095209999")).toBe("95209999");
|
|
865
|
-
|
|
866
|
-
// GTIN-12.
|
|
867
|
-
expect(GTINValidator.normalize("614141009992")).toBe("614141009992");
|
|
868
|
-
expect(GTINValidator.normalize("01234505")).toBe("012000003455");
|
|
869
|
-
expect(() => GTINValidator.normalize("09800037")).toThrow("Invalid zero-suppressed GTIN-12");
|
|
870
|
-
|
|
871
|
-
// GTIN-8.
|
|
872
|
-
expect(GTINValidator.normalize("95209999")).toBe("95209999");
|
|
873
|
-
});
|
|
874
|
-
});
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
function testVariableMeasureRCN(): void {
|
|
878
|
-
describe("Variable measure RCN", () => {
|
|
879
|
-
test("RCN-12", () => {
|
|
880
|
-
const rcn1 = GTINCreator.createVariableMeasureRCN("2IIIIIVPPPPC", 12345, 4321);
|
|
881
|
-
|
|
882
|
-
expect(rcn1.length).toBe(12);
|
|
883
|
-
expect(rcn1.charAt(0)).toBe("2");
|
|
884
|
-
expect(rcn1.substring(1, 6)).toBe("12345");
|
|
885
|
-
expect(rcn1.substring(7, 11)).toBe("4321");
|
|
886
|
-
expect(isValidPriceOrWeightCheckDigit(rcn1.substring(7, 11), rcn1.charAt(6))).toBe(true);
|
|
887
|
-
expect(hasValidCheckDigit(rcn1)).toBe(true);
|
|
888
|
-
expect(() => {
|
|
889
|
-
GTINValidator.parseVariableMeasureRCN("2IIIIIVPPPPC", rcn1);
|
|
890
|
-
}).not.toThrow(RangeError);
|
|
891
|
-
expect(GTINValidator.parseVariableMeasureRCN("2IIIIIVPPPPC", rcn1)).toEqual({
|
|
892
|
-
itemReference: 12345,
|
|
893
|
-
priceOrWeight: 4321
|
|
894
|
-
} satisfies RCNReference);
|
|
895
|
-
|
|
896
|
-
const rcn2 = GTINCreator.createVariableMeasureRCN("2IIIIPPPPPVC", 1234, 54321);
|
|
897
|
-
|
|
898
|
-
expect(rcn2.length).toBe(12);
|
|
899
|
-
expect(rcn2.charAt(0)).toBe("2");
|
|
900
|
-
expect(rcn2.substring(1, 5)).toBe("1234");
|
|
901
|
-
expect(rcn2.substring(5, 10)).toBe("54321");
|
|
902
|
-
expect(isValidPriceOrWeightCheckDigit(rcn2.substring(5, 10), rcn2.charAt(10))).toBe(true);
|
|
903
|
-
expect(hasValidCheckDigit(rcn2)).toBe(true);
|
|
904
|
-
expect(() => {
|
|
905
|
-
GTINValidator.parseVariableMeasureRCN("2IIIIPPPPPVC", rcn2);
|
|
906
|
-
}).not.toThrow(RangeError);
|
|
907
|
-
expect(GTINValidator.parseVariableMeasureRCN("2IIIIPPPPPVC", rcn2)).toEqual({
|
|
908
|
-
itemReference: 1234,
|
|
909
|
-
priceOrWeight: 54321
|
|
910
|
-
} satisfies RCNReference);
|
|
911
|
-
|
|
912
|
-
const rcn3 = GTINCreator.createVariableMeasureRCN("2PPPPPIIIIIC", 12345, 54321);
|
|
913
|
-
|
|
914
|
-
expect(rcn3.length).toBe(12);
|
|
915
|
-
expect(rcn3.charAt(0)).toBe("2");
|
|
916
|
-
expect(rcn3.substring(1, 6)).toBe("54321");
|
|
917
|
-
expect(rcn3.substring(6, 11)).toBe("12345");
|
|
918
|
-
expect(hasValidCheckDigit(rcn3)).toBe(true);
|
|
919
|
-
expect(() => {
|
|
920
|
-
GTINValidator.parseVariableMeasureRCN("2PPPPPIIIIIC", rcn3);
|
|
921
|
-
}).not.toThrow(RangeError);
|
|
922
|
-
expect(GTINValidator.parseVariableMeasureRCN("2PPPPPIIIIIC", rcn3)).toEqual({
|
|
923
|
-
itemReference: 12345,
|
|
924
|
-
priceOrWeight: 54321
|
|
925
|
-
} satisfies RCNReference);
|
|
926
|
-
|
|
927
|
-
expect(() => GTINCreator.createVariableMeasureRCN("3PPPPPIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
|
|
928
|
-
expect(() => GTINCreator.createVariableMeasureRCN("20PPPPPIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
|
|
929
|
-
expect(() => GTINCreator.createVariableMeasureRCN("2PPPPPIIIIII", 12345, 54321)).toThrow("Invalid variable measure RCN format");
|
|
930
|
-
expect(() => GTINCreator.createVariableMeasureRCN("2PPPPPIIIIKC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
|
|
931
|
-
expect(() => GTINCreator.createVariableMeasureRCN("2PPPPPIIPIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
|
|
932
|
-
expect(() => GTINCreator.createVariableMeasureRCN("2PPIPPIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
|
|
933
|
-
expect(() => GTINCreator.createVariableMeasureRCN("2PPPPPIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
|
|
934
|
-
expect(() => GTINCreator.createVariableMeasureRCN("2PPPPPIIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
|
|
935
|
-
expect(() => GTINCreator.createVariableMeasureRCN("2PPPPPPPPPPC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
|
|
936
|
-
expect(() => GTINCreator.createVariableMeasureRCN("2IIIIIIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
|
|
937
|
-
|
|
938
|
-
expect(() => {
|
|
939
|
-
GTINCreator.parseVariableMeasureRCN("3PPPPPIIIIIC", "2543211234540");
|
|
940
|
-
}).toThrow("RCN length must match format length");
|
|
941
|
-
expect(() => {
|
|
942
|
-
GTINCreator.parseVariableMeasureRCN("3PPPPPIIIIIC", "25432112345");
|
|
943
|
-
}).toThrow("RCN length must match format length");
|
|
944
|
-
expect(() => {
|
|
945
|
-
GTINCreator.parseVariableMeasureRCN("3PPPPPIIIIIC", "254321123454");
|
|
946
|
-
}).toThrow("Invalid variable measure RCN format");
|
|
947
|
-
expect(() => {
|
|
948
|
-
GTINCreator.parseVariableMeasureRCN("20PPPPPIIIIC", "254321123454");
|
|
949
|
-
}).toThrow("Invalid variable measure RCN format");
|
|
950
|
-
expect(() => {
|
|
951
|
-
GTINCreator.parseVariableMeasureRCN("2PPPPPIIIIII", "254321123454");
|
|
952
|
-
}).toThrow("Invalid variable measure RCN format");
|
|
953
|
-
expect(() => {
|
|
954
|
-
GTINCreator.parseVariableMeasureRCN("2PPPPPIIIIKC", "254321123454");
|
|
955
|
-
}).toThrow("Invalid variable measure RCN format");
|
|
956
|
-
expect(() => {
|
|
957
|
-
GTINCreator.parseVariableMeasureRCN("2PPPPPIIPIIC", "254321123454");
|
|
958
|
-
}).toThrow("Invalid variable measure RCN format");
|
|
959
|
-
expect(() => {
|
|
960
|
-
GTINCreator.parseVariableMeasureRCN("2PPIPPIIIIIC", "254321123454");
|
|
961
|
-
}).toThrow("Invalid variable measure RCN format");
|
|
962
|
-
expect(() => {
|
|
963
|
-
GTINCreator.parseVariableMeasureRCN("2PPPPPIIIIC", "25432112345");
|
|
964
|
-
}).toThrow("Invalid variable measure RCN format");
|
|
965
|
-
expect(() => {
|
|
966
|
-
GTINCreator.parseVariableMeasureRCN("2PPPPPIIIIIIC", "2543211234540");
|
|
967
|
-
}).toThrow("Invalid variable measure RCN format");
|
|
968
|
-
expect(() => {
|
|
969
|
-
GTINCreator.parseVariableMeasureRCN("2PPPPPPPPPPC", "254321123454");
|
|
970
|
-
}).toThrow("Invalid variable measure RCN format");
|
|
971
|
-
expect(() => {
|
|
972
|
-
GTINCreator.parseVariableMeasureRCN("2IIIIIIIIIIC", "254321123454");
|
|
973
|
-
}).toThrow("Invalid variable measure RCN format");
|
|
974
|
-
});
|
|
975
|
-
|
|
976
|
-
test("RCN-13", () => {
|
|
977
|
-
const rcn1 = GTINCreator.createVariableMeasureRCN("24IIIIIVPPPPC", 12345, 4321);
|
|
978
|
-
|
|
979
|
-
expect(rcn1.length).toBe(13);
|
|
980
|
-
expect(rcn1.substring(0, 2)).toBe("24");
|
|
981
|
-
expect(rcn1.substring(2, 7)).toBe("12345");
|
|
982
|
-
expect(rcn1.substring(8, 12)).toBe("4321");
|
|
983
|
-
expect(isValidPriceOrWeightCheckDigit(rcn1.substring(8, 12), rcn1.charAt(7))).toBe(true);
|
|
984
|
-
expect(hasValidCheckDigit(rcn1)).toBe(true);
|
|
985
|
-
expect(() => {
|
|
986
|
-
GTINValidator.parseVariableMeasureRCN("24IIIIIVPPPPC", rcn1);
|
|
987
|
-
}).not.toThrow(RangeError);
|
|
988
|
-
expect(GTINValidator.parseVariableMeasureRCN("24IIIIIVPPPPC", rcn1)).toEqual({
|
|
989
|
-
itemReference: 12345,
|
|
990
|
-
priceOrWeight: 4321
|
|
991
|
-
} satisfies RCNReference);
|
|
992
|
-
|
|
993
|
-
const rcn2 = GTINCreator.createVariableMeasureRCN("21IIIIPPPPPVC", 1234, 54321);
|
|
994
|
-
|
|
995
|
-
expect(rcn2.length).toBe(13);
|
|
996
|
-
expect(rcn2.substring(0, 2)).toBe("21");
|
|
997
|
-
expect(rcn2.substring(2, 6)).toBe("1234");
|
|
998
|
-
expect(rcn2.substring(6, 11)).toBe("54321");
|
|
999
|
-
expect(isValidPriceOrWeightCheckDigit(rcn2.substring(6, 11), rcn2.charAt(11))).toBe(true);
|
|
1000
|
-
expect(hasValidCheckDigit(rcn2)).toBe(true);
|
|
1001
|
-
expect(() => {
|
|
1002
|
-
GTINValidator.parseVariableMeasureRCN("21IIIIPPPPPVC", rcn2);
|
|
1003
|
-
}).not.toThrow(RangeError);
|
|
1004
|
-
expect(GTINValidator.parseVariableMeasureRCN("21IIIIPPPPPVC", rcn2)).toEqual({
|
|
1005
|
-
itemReference: 1234,
|
|
1006
|
-
priceOrWeight: 54321
|
|
1007
|
-
} satisfies RCNReference);
|
|
1008
|
-
|
|
1009
|
-
const rcn3 = GTINCreator.createVariableMeasureRCN("27PPPPPIIIIIC", 12345, 54321);
|
|
1010
|
-
|
|
1011
|
-
expect(rcn3.length).toBe(13);
|
|
1012
|
-
expect(rcn3.substring(0, 2)).toBe("27");
|
|
1013
|
-
expect(rcn3.substring(2, 7)).toBe("54321");
|
|
1014
|
-
expect(rcn3.substring(7, 12)).toBe("12345");
|
|
1015
|
-
expect(hasValidCheckDigit(rcn3)).toBe(true);
|
|
1016
|
-
expect(() => {
|
|
1017
|
-
GTINValidator.parseVariableMeasureRCN("27PPPPPIIIIIC", rcn3);
|
|
1018
|
-
}).not.toThrow(RangeError);
|
|
1019
|
-
expect(GTINValidator.parseVariableMeasureRCN("27PPPPPIIIIIC", rcn3)).toEqual({
|
|
1020
|
-
itemReference: 12345,
|
|
1021
|
-
priceOrWeight: 54321
|
|
1022
|
-
} satisfies RCNReference);
|
|
1023
|
-
|
|
1024
|
-
expect(() => GTINCreator.createVariableMeasureRCN("30PPPPPIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
|
|
1025
|
-
expect(() => GTINCreator.createVariableMeasureRCN("2PPPPPPIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
|
|
1026
|
-
expect(() => GTINCreator.createVariableMeasureRCN("20PPPPPIIIIII", 12345, 54321)).toThrow("Invalid variable measure RCN format");
|
|
1027
|
-
expect(() => GTINCreator.createVariableMeasureRCN("21PPPPPIIIIKC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
|
|
1028
|
-
expect(() => GTINCreator.createVariableMeasureRCN("22PPPPPIIPIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
|
|
1029
|
-
expect(() => GTINCreator.createVariableMeasureRCN("23PPIPPIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
|
|
1030
|
-
expect(() => GTINCreator.createVariableMeasureRCN("24PPPPPIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
|
|
1031
|
-
expect(() => GTINCreator.createVariableMeasureRCN("25PPPPPIIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
|
|
1032
|
-
expect(() => GTINCreator.createVariableMeasureRCN("26PPPPPPPPPPC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
|
|
1033
|
-
expect(() => GTINCreator.createVariableMeasureRCN("27IIIIIIIIIIC", 12345, 54321)).toThrow("Invalid variable measure RCN format");
|
|
1034
|
-
|
|
1035
|
-
expect(() => {
|
|
1036
|
-
GTINCreator.parseVariableMeasureRCN("30PPPPPIIIIIC", "27543211234570");
|
|
1037
|
-
}).toThrow("RCN length must match format length");
|
|
1038
|
-
expect(() => {
|
|
1039
|
-
GTINCreator.parseVariableMeasureRCN("30PPPPPIIIIIC", "275432112345");
|
|
1040
|
-
}).toThrow("RCN length must match format length");
|
|
1041
|
-
expect(() => {
|
|
1042
|
-
GTINCreator.parseVariableMeasureRCN("30PPPPPIIIIIC", "2754321123457");
|
|
1043
|
-
}).toThrow("Invalid variable measure RCN format");
|
|
1044
|
-
expect(() => {
|
|
1045
|
-
GTINCreator.parseVariableMeasureRCN("20PPPPPIIIIII", "2754321123457");
|
|
1046
|
-
}).toThrow("Invalid variable measure RCN format");
|
|
1047
|
-
expect(() => {
|
|
1048
|
-
GTINCreator.parseVariableMeasureRCN("21PPPPPIIIIKC", "2754321123457");
|
|
1049
|
-
}).toThrow("Invalid variable measure RCN format");
|
|
1050
|
-
expect(() => {
|
|
1051
|
-
GTINCreator.parseVariableMeasureRCN("22PPPPPIIPIIC", "2754321123457");
|
|
1052
|
-
}).toThrow("Invalid variable measure RCN format");
|
|
1053
|
-
expect(() => {
|
|
1054
|
-
GTINCreator.parseVariableMeasureRCN("23PPIPPIIIIIC", "2754321123457");
|
|
1055
|
-
}).toThrow("Invalid variable measure RCN format");
|
|
1056
|
-
expect(() => {
|
|
1057
|
-
GTINCreator.parseVariableMeasureRCN("24PPPPPIIIIC", "275432112345");
|
|
1058
|
-
}).toThrow("Invalid variable measure RCN format");
|
|
1059
|
-
expect(() => {
|
|
1060
|
-
GTINCreator.parseVariableMeasureRCN("25PPPPPIIIIIIC", "27543211234570");
|
|
1061
|
-
}).toThrow("Invalid variable measure RCN format");
|
|
1062
|
-
expect(() => {
|
|
1063
|
-
GTINCreator.parseVariableMeasureRCN("26PPPPPPPPPPC", "2754321123457");
|
|
1064
|
-
}).toThrow("Invalid variable measure RCN format");
|
|
1065
|
-
expect(() => {
|
|
1066
|
-
GTINCreator.parseVariableMeasureRCN("27IIIIIIIIIIC", "2754321123457");
|
|
1067
|
-
}).toThrow("Invalid variable measure RCN format");
|
|
1068
|
-
});
|
|
1069
|
-
});
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
function testNonGTINNumericIdentificationKeyCreator(creator: NonGTINNumericIdentificationKeyCreator, preTestCallback?: () => void, postTestCallback?: () => void): void {
|
|
1073
|
-
testNumericIdentificationKeyCreator(creator, preTestCallback, postTestCallback);
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
function testSerializableNumericIdentificationKeyCreator(creator: SerializableNumericIdentificationKeyCreator): void {
|
|
1077
|
-
testNonGTINNumericIdentificationKeyCreator(creator, undefined, () => {
|
|
1078
|
-
test("Serialization", () => {
|
|
1079
|
-
const identificationKey = creator.create(0, true);
|
|
1080
|
-
const serial = "12345678";
|
|
1081
|
-
const serializedIdentificationKey = identificationKey + serial;
|
|
1082
|
-
const serials = [serial, "23456789", "34567890", "456789012"];
|
|
1083
|
-
const serializedIdentificationKeys = serials.map(serial => identificationKey + serial);
|
|
1084
|
-
|
|
1085
|
-
expect(creator.createSerialized(0, serial, true)).toBe(serializedIdentificationKey);
|
|
1086
|
-
expect(creator.concatenate(identificationKey, serial)).toBe(serializedIdentificationKey);
|
|
1087
|
-
expect(Array.from(creator.createSerialized(0, serials, true))).toStrictEqual(serializedIdentificationKeys);
|
|
1088
|
-
expect(Array.from(creator.concatenate(identificationKey, serials))).toStrictEqual(serializedIdentificationKeys);
|
|
1089
|
-
|
|
1090
|
-
const fullLengthSerial = "0".repeat(creator.serialComponentLength);
|
|
1091
|
-
const fullLengthPlusOneSerial = fullLengthSerial + "0";
|
|
1092
|
-
const fullLengthPlusOneSerialErrorMessage = `Length ${creator.serialComponentLength + 1} of serial component must be less than or equal to ${creator.serialComponentLength}`;
|
|
1093
|
-
|
|
1094
|
-
expect(() => creator.createSerialized(0, fullLengthSerial, true)).not.toThrow(RangeError);
|
|
1095
|
-
expect(() => creator.concatenate(identificationKey, fullLengthSerial)).not.toThrow(RangeError);
|
|
1096
|
-
expect(() => Array.from(creator.createSerialized(0, [...serials, fullLengthSerial], true))).not.toThrow(RangeError);
|
|
1097
|
-
expect(() => Array.from(creator.concatenate(identificationKey, [...serials, fullLengthSerial]))).not.toThrow(RangeError);
|
|
1098
|
-
expect(() => creator.createSerialized(0, fullLengthPlusOneSerial, true)).toThrow(fullLengthPlusOneSerialErrorMessage);
|
|
1099
|
-
expect(() => creator.concatenate(identificationKey, fullLengthPlusOneSerial)).toThrow(fullLengthPlusOneSerialErrorMessage);
|
|
1100
|
-
expect(() => Array.from(creator.createSerialized(0, [...serials, fullLengthPlusOneSerial], true))).toThrow(fullLengthPlusOneSerialErrorMessage);
|
|
1101
|
-
expect(() => Array.from(creator.concatenate(identificationKey, [...serials, fullLengthPlusOneSerial]))).toThrow(fullLengthPlusOneSerialErrorMessage);
|
|
1102
|
-
|
|
1103
|
-
let invalidSerial: string;
|
|
1104
|
-
|
|
1105
|
-
switch (creator.serialComponentCharacterSet) {
|
|
1106
|
-
case ContentCharacterSet.Numeric:
|
|
1107
|
-
invalidSerial = "1234A5678";
|
|
1108
|
-
break;
|
|
1109
|
-
|
|
1110
|
-
case ContentCharacterSet.AI82:
|
|
1111
|
-
invalidSerial = "ABCD~1234";
|
|
1112
|
-
break;
|
|
1113
|
-
|
|
1114
|
-
case ContentCharacterSet.AI39:
|
|
1115
|
-
invalidSerial = "ABCD%1234";
|
|
1116
|
-
break;
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
const invalidSerialErrorMessage = `Invalid character '${invalidSerial.charAt(4)}' at position 5 of serial component`;
|
|
1120
|
-
|
|
1121
|
-
expect(() => creator.createSerialized(0, invalidSerial, true)).toThrow(invalidSerialErrorMessage);
|
|
1122
|
-
expect(() => creator.concatenate(identificationKey, invalidSerial)).toThrow(invalidSerialErrorMessage);
|
|
1123
|
-
expect(() => Array.from(creator.createSerialized(0, [...serials, invalidSerial], true))).toThrow(invalidSerialErrorMessage);
|
|
1124
|
-
expect(() => Array.from(creator.concatenate(identificationKey, [...serials, invalidSerial]))).toThrow(invalidSerialErrorMessage);
|
|
1125
|
-
});
|
|
1126
|
-
});
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
const TEST_REFERENCE_LENGTH = 2;
|
|
1130
|
-
|
|
1131
|
-
function testNonNumericIdentificationKeyCreator(creator: NonNumericIdentificationKeyCreator): void {
|
|
1132
|
-
describe(creator.identificationKeyType, () => {
|
|
1133
|
-
const prefix = creator.prefix;
|
|
1134
|
-
const prefixLength = prefix.length;
|
|
1135
|
-
const referenceLength = creator.length - prefixLength - 2 * Number(creator.requiresCheckCharacterPair);
|
|
1136
|
-
const referenceCount = creator.referenceCreator.characterSetSize ** TEST_REFERENCE_LENGTH;
|
|
1137
|
-
const referenceSubstringStart = prefixLength;
|
|
1138
|
-
const referenceSubstringEnd = prefixLength + TEST_REFERENCE_LENGTH;
|
|
1139
|
-
|
|
1140
|
-
test("Straight", () => {
|
|
1141
|
-
expect(creator.referenceLength).toBe(referenceLength);
|
|
1142
|
-
|
|
1143
|
-
let index = 0;
|
|
1144
|
-
|
|
1145
|
-
for (const identificationKey of creator.create(creator.referenceCreator.create(TEST_REFERENCE_LENGTH, new Sequence(0, referenceCount)))) {
|
|
1146
|
-
expect(() => {
|
|
1147
|
-
creator.validate(identificationKey);
|
|
1148
|
-
}).not.toThrow(RangeError);
|
|
1149
|
-
|
|
1150
|
-
expect(Number(creator.referenceCreator.valueFor(identificationKey.substring(referenceSubstringStart, referenceSubstringEnd)))).toBe(index);
|
|
1151
|
-
|
|
1152
|
-
expect(identificationKey.length).toBeLessThanOrEqual(creator.length);
|
|
1153
|
-
expect(identificationKey.substring(0, prefixLength)).toBe(prefix);
|
|
1154
|
-
expect(!creator.requiresCheckCharacterPair || hasValidCheckCharacterPair(identificationKey)).toBe(true);
|
|
1155
|
-
|
|
1156
|
-
expect(identificationKey).toBe(creator.referenceCreator.create(TEST_REFERENCE_LENGTH, index, Exclusion.None, undefined, reference => creator.create(reference)));
|
|
1157
|
-
|
|
1158
|
-
index++;
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
expect(index).toBe(referenceCount);
|
|
1162
|
-
});
|
|
1163
|
-
|
|
1164
|
-
test("Sparse", () => {
|
|
1165
|
-
let sequential = true;
|
|
1166
|
-
|
|
1167
|
-
let index = 0;
|
|
1168
|
-
|
|
1169
|
-
for (const identificationKey of creator.create(creator.referenceCreator.create(TEST_REFERENCE_LENGTH, new Sequence(0, referenceCount), Exclusion.None, 123456n))) {
|
|
1170
|
-
expect(() => {
|
|
1171
|
-
creator.validate(identificationKey);
|
|
1172
|
-
}).not.toThrow(RangeError);
|
|
1173
|
-
|
|
1174
|
-
expect(Number(creator.referenceCreator.valueFor(identificationKey.substring(referenceSubstringStart, referenceSubstringEnd), Exclusion.None, 123456n))).toBe(index);
|
|
1175
|
-
|
|
1176
|
-
sequential &&= Number(creator.referenceCreator.valueFor(identificationKey.substring(referenceSubstringStart, referenceSubstringEnd))) === index;
|
|
1177
|
-
|
|
1178
|
-
expect(identificationKey.length).toBeLessThanOrEqual(creator.length);
|
|
1179
|
-
expect(identificationKey.substring(0, prefixLength)).toBe(prefix);
|
|
1180
|
-
expect(!creator.requiresCheckCharacterPair || hasValidCheckCharacterPair(identificationKey)).toBe(true);
|
|
1181
|
-
|
|
1182
|
-
expect(identificationKey).toBe(creator.referenceCreator.create(TEST_REFERENCE_LENGTH, index, Exclusion.None, 123456n, reference => creator.create(reference)));
|
|
1183
|
-
|
|
1184
|
-
index++;
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
expect(sequential).toBe(false);
|
|
1188
|
-
expect(index).toBe(referenceCount);
|
|
1189
|
-
});
|
|
1190
|
-
|
|
1191
|
-
test("Position offset", () => {
|
|
1192
|
-
expect(() => {
|
|
1193
|
-
creator.validate(creator.create("ABC123"), {
|
|
1194
|
-
positionOffset: 4
|
|
1195
|
-
});
|
|
1196
|
-
}).not.toThrow(RangeError);
|
|
1197
|
-
});
|
|
1198
|
-
|
|
1199
|
-
test("Not all numeric", () => {
|
|
1200
|
-
expect(() => {
|
|
1201
|
-
creator.validate(creator.create("01234"), {
|
|
1202
|
-
exclusion: Exclusion.AllNumeric
|
|
1203
|
-
});
|
|
1204
|
-
}).toThrow("Reference can't be all-numeric");
|
|
1205
|
-
|
|
1206
|
-
expect(() => {
|
|
1207
|
-
creator.validate(creator.create("O1234"), {
|
|
1208
|
-
exclusion: Exclusion.AllNumeric
|
|
1209
|
-
});
|
|
1210
|
-
}).not.toThrow(RangeError);
|
|
1211
|
-
});
|
|
1212
|
-
});
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
|
-
let prefixManager: PrefixManager;
|
|
1216
|
-
|
|
1217
|
-
prefixManager = PrefixManager.get(PrefixType.GS1CompanyPrefix, "952123456");
|
|
1218
|
-
|
|
1219
|
-
testGTINCreator(prefixManager.gtinCreator);
|
|
1220
|
-
|
|
1221
|
-
prefixManager = PrefixManager.get(PrefixType.UPCCompanyPrefix, "61414112");
|
|
1222
|
-
|
|
1223
|
-
testGTINCreator(prefixManager.gtinCreator);
|
|
1224
|
-
|
|
1225
|
-
prefixManager = PrefixManager.get(PrefixType.GS18Prefix, "9521");
|
|
1226
|
-
|
|
1227
|
-
testGTINCreator(prefixManager.gtinCreator);
|
|
1228
|
-
|
|
1229
|
-
testGTINValidationAndNormalization();
|
|
1230
|
-
testVariableMeasureRCN();
|
|
1231
|
-
|
|
1232
|
-
prefixManager = PrefixManager.get(PrefixType.GS1CompanyPrefix, "952123456");
|
|
1233
|
-
|
|
1234
|
-
testNonGTINNumericIdentificationKeyCreator(prefixManager.glnCreator);
|
|
1235
|
-
testSerializableNumericIdentificationKeyCreator(prefixManager.graiCreator);
|
|
1236
|
-
testNonNumericIdentificationKeyCreator(prefixManager.giaiCreator);
|
|
1237
|
-
testSerializableNumericIdentificationKeyCreator(prefixManager.gdtiCreator);
|
|
1238
|
-
testNonNumericIdentificationKeyCreator(prefixManager.gincCreator);
|
|
1239
|
-
testSerializableNumericIdentificationKeyCreator(prefixManager.gcnCreator);
|
|
1240
|
-
testNonNumericIdentificationKeyCreator(prefixManager.cpidCreator);
|
|
1241
|
-
testNonNumericIdentificationKeyCreator(prefixManager.gmnCreator);
|
|
1242
|
-
|
|
1243
|
-
prefixManager = PrefixManager.get(PrefixType.GS1CompanyPrefix, "952123456789");
|
|
1244
|
-
|
|
1245
|
-
testNonGTINNumericIdentificationKeyCreator(prefixManager.ssccCreator);
|
|
1246
|
-
testNonGTINNumericIdentificationKeyCreator(prefixManager.gsrnCreator);
|
|
1247
|
-
testNonGTINNumericIdentificationKeyCreator(prefixManager.gsinCreator);
|