@aidc-toolkit/gs1 0.9.10-beta → 0.9.12-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/index.cjs +129 -119
- package/dist/index.d.cts +59 -52
- package/dist/index.d.ts +59 -52
- package/dist/index.js +129 -119
- package/package.json +10 -9
- package/src/idkey.ts +184 -173
- package/src/locale/en/locale-strings.ts +1 -0
- package/src/locale/fr/locale-strings.ts +1 -0
- package/test/idkey.test.ts +118 -115
- /package/{eslint.config.js → eslint.config.ts} +0 -0
package/test/idkey.test.ts
CHANGED
|
@@ -19,10 +19,10 @@ import {
|
|
|
19
19
|
GTIN13_VALIDATOR,
|
|
20
20
|
GTIN8_VALIDATOR,
|
|
21
21
|
GTIN_VALIDATORS,
|
|
22
|
-
GTINCreator,
|
|
22
|
+
type GTINCreator,
|
|
23
23
|
GTINLevel,
|
|
24
24
|
GTINType,
|
|
25
|
-
|
|
25
|
+
GTINValidator,
|
|
26
26
|
hasValidCheckCharacterPair,
|
|
27
27
|
hasValidCheckDigit,
|
|
28
28
|
i18nGS1Init,
|
|
@@ -420,7 +420,10 @@ function testNumericIdentificationKeyCreator(creator: NumericIdentificationKeyCr
|
|
|
420
420
|
expect(hasValidCheckDigit(identificationKey)).toBe(true);
|
|
421
421
|
}
|
|
422
422
|
|
|
423
|
-
test("Straight",
|
|
423
|
+
test("Straight", {
|
|
424
|
+
// Test can take a long time.
|
|
425
|
+
timeout: 20 * 1000
|
|
426
|
+
}, () => {
|
|
424
427
|
expect(creator.referenceLength).toBe(referenceLength);
|
|
425
428
|
expect(creator.capacity).toBe(Number(CharacterSetCreator.powerOf10(referenceLength)));
|
|
426
429
|
|
|
@@ -550,7 +553,7 @@ function testGTINCreator(creator: GTINCreator): void {
|
|
|
550
553
|
|
|
551
554
|
function validate(gtin: string, index: number, sparse: boolean): void {
|
|
552
555
|
expect(() => {
|
|
553
|
-
|
|
556
|
+
GTINValidator.validateGTIN14(gtin);
|
|
554
557
|
}).not.toThrow(RangeError);
|
|
555
558
|
expect(gtin).toBe(creator.createGTIN14("5", index, sparse));
|
|
556
559
|
|
|
@@ -626,109 +629,109 @@ function testGTINCreator(creator: GTINCreator): void {
|
|
|
626
629
|
|
|
627
630
|
if (creator.gtinType === GTINType.GTIN12) {
|
|
628
631
|
test("Zero-suppress GTIN-12 rule 1", () => {
|
|
629
|
-
expect(
|
|
630
|
-
expect(
|
|
631
|
-
expect(
|
|
632
|
-
expect(
|
|
633
|
-
expect(
|
|
632
|
+
expect(GTINValidator.zeroSuppress("012345000058")).toBe("01234558");
|
|
633
|
+
expect(GTINValidator.zeroSuppress("012345000065")).toBe("01234565");
|
|
634
|
+
expect(GTINValidator.zeroSuppress("012345000072")).toBe("01234572");
|
|
635
|
+
expect(GTINValidator.zeroSuppress("012345000089")).toBe("01234589");
|
|
636
|
+
expect(GTINValidator.zeroSuppress("012345000096")).toBe("01234596");
|
|
634
637
|
});
|
|
635
638
|
|
|
636
639
|
test("Zero-suppress GTIN-12 rule 2", () => {
|
|
637
|
-
expect(
|
|
640
|
+
expect(GTINValidator.zeroSuppress("045670000080")).toBe("04567840");
|
|
638
641
|
});
|
|
639
642
|
|
|
640
643
|
test("Zero-suppress GTIN-12 rule 3", () => {
|
|
641
|
-
expect(
|
|
642
|
-
expect(
|
|
643
|
-
expect(
|
|
644
|
+
expect(GTINValidator.zeroSuppress("034000005673")).toBe("03456703");
|
|
645
|
+
expect(GTINValidator.zeroSuppress("034100005672")).toBe("03456712");
|
|
646
|
+
expect(GTINValidator.zeroSuppress("034200005671")).toBe("03456721");
|
|
644
647
|
});
|
|
645
648
|
|
|
646
649
|
test("Zero-suppress GTIN-12 rule 4", () => {
|
|
647
|
-
expect(
|
|
648
|
-
expect(
|
|
649
|
-
expect(
|
|
650
|
-
expect(
|
|
651
|
-
expect(
|
|
652
|
-
expect(
|
|
653
|
-
expect(
|
|
650
|
+
expect(GTINValidator.zeroSuppress("098300000752")).toBe("09837532");
|
|
651
|
+
expect(GTINValidator.zeroSuppress("098400000751")).toBe("09847531");
|
|
652
|
+
expect(GTINValidator.zeroSuppress("098500000750")).toBe("09857530");
|
|
653
|
+
expect(GTINValidator.zeroSuppress("098600000759")).toBe("09867539");
|
|
654
|
+
expect(GTINValidator.zeroSuppress("098700000758")).toBe("09877538");
|
|
655
|
+
expect(GTINValidator.zeroSuppress("098800000757")).toBe("09887537");
|
|
656
|
+
expect(GTINValidator.zeroSuppress("098900000756")).toBe("09897536");
|
|
654
657
|
});
|
|
655
658
|
|
|
656
659
|
test("Non-zero-suppressible GTIN-12 rule 1", () => {
|
|
657
|
-
expect(() =>
|
|
658
|
-
expect(() =>
|
|
659
|
-
expect(() =>
|
|
660
|
-
expect(() =>
|
|
661
|
-
expect(() =>
|
|
662
|
-
expect(() =>
|
|
660
|
+
expect(() => GTINValidator.zeroSuppress("012345100055")).toThrow("GTIN-12 not zero-suppressible");
|
|
661
|
+
expect(() => GTINValidator.zeroSuppress("012345010057")).toThrow("GTIN-12 not zero-suppressible");
|
|
662
|
+
expect(() => GTINValidator.zeroSuppress("012345001055")).toThrow("GTIN-12 not zero-suppressible");
|
|
663
|
+
expect(() => GTINValidator.zeroSuppress("012345000157")).toThrow("GTIN-12 not zero-suppressible");
|
|
664
|
+
expect(() => GTINValidator.zeroSuppress("012345000041")).toThrow("GTIN-12 not zero-suppressible");
|
|
665
|
+
expect(() => GTINValidator.zeroSuppress("012345000003")).toThrow("GTIN-12 not zero-suppressible");
|
|
663
666
|
});
|
|
664
667
|
|
|
665
668
|
test("Non-zero-suppressible GTIN-12 rule 2", () => {
|
|
666
|
-
expect(() =>
|
|
667
|
-
expect(() =>
|
|
668
|
-
expect(() =>
|
|
669
|
-
expect(() =>
|
|
669
|
+
expect(() => GTINValidator.zeroSuppress("045670100087")).toThrow("GTIN-12 not zero-suppressible");
|
|
670
|
+
expect(() => GTINValidator.zeroSuppress("045670010089")).toThrow("GTIN-12 not zero-suppressible");
|
|
671
|
+
expect(() => GTINValidator.zeroSuppress("045670001087")).toThrow("GTIN-12 not zero-suppressible");
|
|
672
|
+
expect(() => GTINValidator.zeroSuppress("045670000189")).toThrow("GTIN-12 not zero-suppressible");
|
|
670
673
|
});
|
|
671
674
|
|
|
672
675
|
test("Non-zero-suppressible GTIN-12 rule 3", () => {
|
|
673
|
-
expect(() =>
|
|
674
|
-
expect(() =>
|
|
675
|
-
expect(() =>
|
|
676
|
-
expect(() =>
|
|
676
|
+
expect(() => GTINValidator.zeroSuppress("034010005670")).toThrow("GTIN-12 not zero-suppressible");
|
|
677
|
+
expect(() => GTINValidator.zeroSuppress("034001005672")).toThrow("GTIN-12 not zero-suppressible");
|
|
678
|
+
expect(() => GTINValidator.zeroSuppress("034000105670")).toThrow("GTIN-12 not zero-suppressible");
|
|
679
|
+
expect(() => GTINValidator.zeroSuppress("034000015672")).toThrow("GTIN-12 not zero-suppressible");
|
|
677
680
|
});
|
|
678
681
|
|
|
679
682
|
test("Non-zero-suppressible GTIN-12 rule 4", () => {
|
|
680
|
-
expect(() =>
|
|
681
|
-
expect(() =>
|
|
682
|
-
expect(() =>
|
|
683
|
-
expect(() =>
|
|
684
|
-
expect(() =>
|
|
683
|
+
expect(() => GTINValidator.zeroSuppress("098310000759")).toThrow("GTIN-12 not zero-suppressible");
|
|
684
|
+
expect(() => GTINValidator.zeroSuppress("098301000751")).toThrow("GTIN-12 not zero-suppressible");
|
|
685
|
+
expect(() => GTINValidator.zeroSuppress("098300100759")).toThrow("GTIN-12 not zero-suppressible");
|
|
686
|
+
expect(() => GTINValidator.zeroSuppress("098300010751")).toThrow("GTIN-12 not zero-suppressible");
|
|
687
|
+
expect(() => GTINValidator.zeroSuppress("098300001759")).toThrow("GTIN-12 not zero-suppressible");
|
|
685
688
|
});
|
|
686
689
|
|
|
687
690
|
test("Zero-suppress other error", () => {
|
|
688
|
-
expect(() =>
|
|
689
|
-
expect(() =>
|
|
690
|
-
expect(() =>
|
|
691
|
+
expect(() => GTINValidator.zeroSuppress("0012345000059")).toThrow("GTIN must be 12 digits long");
|
|
692
|
+
expect(() => GTINValidator.zeroSuppress("012345000059")).toThrow("Invalid check digit");
|
|
693
|
+
expect(() => GTINValidator.zeroSuppress("112345000055")).toThrow("GTIN-12 not zero-suppressible");
|
|
691
694
|
});
|
|
692
695
|
|
|
693
696
|
test("Zero-expand GTIN-12 rule 1", () => {
|
|
694
|
-
expect(
|
|
695
|
-
expect(
|
|
696
|
-
expect(
|
|
697
|
-
expect(
|
|
698
|
-
expect(
|
|
699
|
-
expect(() =>
|
|
697
|
+
expect(GTINValidator.zeroExpand("01234558")).toBe("012345000058");
|
|
698
|
+
expect(GTINValidator.zeroExpand("01234565")).toBe("012345000065");
|
|
699
|
+
expect(GTINValidator.zeroExpand("01234572")).toBe("012345000072");
|
|
700
|
+
expect(GTINValidator.zeroExpand("01234589")).toBe("012345000089");
|
|
701
|
+
expect(GTINValidator.zeroExpand("01234596")).toBe("012345000096");
|
|
702
|
+
expect(() => GTINValidator.zeroExpand("00000154")).toThrow("U.P.C. Company Prefix can't start with \"0000\"");
|
|
700
703
|
});
|
|
701
704
|
|
|
702
705
|
test("Zero-expand GTIN-12 rule 2", () => {
|
|
703
|
-
expect(
|
|
704
|
-
expect(() =>
|
|
706
|
+
expect(GTINValidator.zeroExpand("04567840")).toBe("045670000080");
|
|
707
|
+
expect(() => GTINValidator.zeroExpand("00001047")).toThrow("U.P.C. Company Prefix can't start with \"0000\"");
|
|
705
708
|
});
|
|
706
709
|
|
|
707
710
|
test("Zero-expand GTIN-12 rule 3", () => {
|
|
708
|
-
expect(
|
|
709
|
-
expect(
|
|
710
|
-
expect(
|
|
711
|
-
expect(() =>
|
|
711
|
+
expect(GTINValidator.zeroExpand("03456703")).toBe("034000005673");
|
|
712
|
+
expect(GTINValidator.zeroExpand("03456712")).toBe("034100005672");
|
|
713
|
+
expect(GTINValidator.zeroExpand("03456721")).toBe("034200005671");
|
|
714
|
+
expect(() => GTINValidator.zeroExpand("00000028")).not.toThrow(RangeError);
|
|
712
715
|
});
|
|
713
716
|
|
|
714
717
|
test("Zero-expand GTIN-12 rule 4", () => {
|
|
715
|
-
expect(
|
|
716
|
-
expect(
|
|
717
|
-
expect(
|
|
718
|
-
expect(
|
|
719
|
-
expect(
|
|
720
|
-
expect(
|
|
721
|
-
expect(
|
|
722
|
-
expect(() =>
|
|
718
|
+
expect(GTINValidator.zeroExpand("09837532")).toBe("098300000752");
|
|
719
|
+
expect(GTINValidator.zeroExpand("09847531")).toBe("098400000751");
|
|
720
|
+
expect(GTINValidator.zeroExpand("09857530")).toBe("098500000750");
|
|
721
|
+
expect(GTINValidator.zeroExpand("09867539")).toBe("098600000759");
|
|
722
|
+
expect(GTINValidator.zeroExpand("09877538")).toBe("098700000758");
|
|
723
|
+
expect(GTINValidator.zeroExpand("09887537")).toBe("098800000757");
|
|
724
|
+
expect(GTINValidator.zeroExpand("09897536")).toBe("098900000756");
|
|
725
|
+
expect(() => GTINValidator.zeroExpand("00030037")).not.toThrow(RangeError);
|
|
723
726
|
});
|
|
724
727
|
|
|
725
728
|
test("Zero-expand error", () => {
|
|
726
|
-
expect(() =>
|
|
727
|
-
expect(() =>
|
|
728
|
-
expect(() =>
|
|
729
|
-
expect(() =>
|
|
730
|
-
expect(() =>
|
|
731
|
-
expect(() =>
|
|
729
|
+
expect(() => GTINValidator.zeroExpand("001234505")).toThrow("Length 9 must be less than or equal to 8");
|
|
730
|
+
expect(() => GTINValidator.zeroExpand("01234506")).toThrow("Invalid check digit");
|
|
731
|
+
expect(() => GTINValidator.zeroExpand("11234506")).toThrow("Invalid zero-suppressed GTIN-12");
|
|
732
|
+
expect(() => GTINValidator.zeroExpand("09800037")).toThrow("Invalid zero-suppressed GTIN-12");
|
|
733
|
+
expect(() => GTINValidator.zeroExpand("09800047")).toThrow("Invalid zero-suppressed GTIN-12");
|
|
734
|
+
expect(() => GTINValidator.zeroExpand("09800052")).toThrow("Invalid zero-suppressed GTIN-12");
|
|
732
735
|
});
|
|
733
736
|
}
|
|
734
737
|
|
|
@@ -737,20 +740,20 @@ function testGTINCreator(creator: GTINCreator): void {
|
|
|
737
740
|
|
|
738
741
|
expect(gtin.length).toBe(creator.length);
|
|
739
742
|
|
|
740
|
-
let gtin14 =
|
|
743
|
+
let gtin14 = GTINValidator.convertToGTIN14("0", gtin);
|
|
741
744
|
|
|
742
745
|
expect(gtin14.length).toBe(14);
|
|
743
|
-
expect(
|
|
746
|
+
expect(GTINValidator.normalize(gtin14)).toBe(gtin);
|
|
744
747
|
|
|
745
|
-
gtin14 =
|
|
748
|
+
gtin14 = GTINValidator.convertToGTIN14("1", gtin);
|
|
746
749
|
|
|
747
750
|
expect(gtin14.length).toBe(14);
|
|
748
|
-
expect(
|
|
751
|
+
expect(GTINValidator.normalize(gtin14)).not.toBe(gtin);
|
|
749
752
|
|
|
750
|
-
gtin14 =
|
|
753
|
+
gtin14 = GTINValidator.convertToGTIN14("2", gtin14);
|
|
751
754
|
|
|
752
755
|
expect(gtin14.length).toBe(14);
|
|
753
|
-
expect(
|
|
756
|
+
expect(GTINValidator.normalize(gtin14)).not.toBe(gtin);
|
|
754
757
|
});
|
|
755
758
|
});
|
|
756
759
|
}
|
|
@@ -759,112 +762,112 @@ function testGTINValidationAndNormalization(): void {
|
|
|
759
762
|
describe("GTIN validation and normalization", () => {
|
|
760
763
|
test("Validation", () => {
|
|
761
764
|
expect(() => {
|
|
762
|
-
|
|
765
|
+
GTINValidator.validateAny("9521873000122", GTINLevel.Any);
|
|
763
766
|
}).not.toThrow(RangeError);
|
|
764
767
|
expect(() => {
|
|
765
|
-
|
|
768
|
+
GTINValidator.validateAny("19521873000129", GTINLevel.Any);
|
|
766
769
|
}).not.toThrow(RangeError);
|
|
767
770
|
expect(() => {
|
|
768
|
-
|
|
771
|
+
GTINValidator.validateAny("9521873000160", GTINLevel.Any);
|
|
769
772
|
}).not.toThrow(RangeError);
|
|
770
773
|
expect(() => {
|
|
771
|
-
|
|
774
|
+
GTINValidator.validateAny("95216843", GTINLevel.Any);
|
|
772
775
|
}).not.toThrow(RangeError);
|
|
773
776
|
expect(() => {
|
|
774
|
-
|
|
777
|
+
GTINValidator.validateAny("95217800031", GTINLevel.Any);
|
|
775
778
|
}).toThrow("GTIN must be 13, 12, 8, or 14 digits long");
|
|
776
779
|
expect(() => {
|
|
777
|
-
|
|
780
|
+
GTINValidator.validateAny("614141773985", GTINLevel.Any);
|
|
778
781
|
}).not.toThrow(RangeError);
|
|
779
782
|
expect(() => {
|
|
780
|
-
|
|
783
|
+
GTINValidator.validateAny("614141773991", GTINLevel.Any);
|
|
781
784
|
}).toThrow("Invalid check digit");
|
|
782
785
|
expect(() => {
|
|
783
|
-
|
|
786
|
+
GTINValidator.validateAny("09867539", GTINLevel.Any);
|
|
784
787
|
}).not.toThrow(RangeError);
|
|
785
788
|
expect(() => {
|
|
786
|
-
|
|
789
|
+
GTINValidator.validateAny("09800037", GTINLevel.Any);
|
|
787
790
|
}).toThrow("Invalid zero-suppressed GTIN-12");
|
|
788
791
|
expect(() => {
|
|
789
|
-
|
|
792
|
+
GTINValidator.validateAny("9521873000122", GTINLevel.RetailConsumer);
|
|
790
793
|
}).not.toThrow(RangeError);
|
|
791
794
|
expect(() => {
|
|
792
|
-
|
|
795
|
+
GTINValidator.validateAny("19521873000129", GTINLevel.RetailConsumer);
|
|
793
796
|
}).toThrow("GTIN not supported at retail consumer trade item level");
|
|
794
797
|
expect(() => {
|
|
795
|
-
|
|
798
|
+
GTINValidator.validateAny("9521873000160", GTINLevel.RetailConsumer);
|
|
796
799
|
}).not.toThrow(RangeError);
|
|
797
800
|
expect(() => {
|
|
798
|
-
|
|
801
|
+
GTINValidator.validateAny("95216843", GTINLevel.RetailConsumer);
|
|
799
802
|
}).not.toThrow(RangeError);
|
|
800
803
|
expect(() => {
|
|
801
|
-
|
|
804
|
+
GTINValidator.validateAny("95217800031", GTINLevel.RetailConsumer);
|
|
802
805
|
}).toThrow("GTIN must be 13, 12, 8, or 14 digits long");
|
|
803
806
|
expect(() => {
|
|
804
|
-
|
|
807
|
+
GTINValidator.validateAny("614141773985", GTINLevel.RetailConsumer);
|
|
805
808
|
}).not.toThrow(RangeError);
|
|
806
809
|
expect(() => {
|
|
807
|
-
|
|
810
|
+
GTINValidator.validateAny("0614141773985", GTINLevel.RetailConsumer);
|
|
808
811
|
}).toThrow("GTIN-13 at retail consumer trade item level can't start with zero");
|
|
809
812
|
expect(() => {
|
|
810
|
-
|
|
813
|
+
GTINValidator.validateAny("614141773991", GTINLevel.RetailConsumer);
|
|
811
814
|
}).toThrow("Invalid check digit");
|
|
812
815
|
expect(() => {
|
|
813
|
-
|
|
816
|
+
GTINValidator.validateAny("09867539", GTINLevel.RetailConsumer);
|
|
814
817
|
}).not.toThrow(RangeError);
|
|
815
818
|
expect(() => {
|
|
816
|
-
|
|
819
|
+
GTINValidator.validateAny("09800037", GTINLevel.RetailConsumer);
|
|
817
820
|
}).toThrow("Invalid zero-suppressed GTIN-12");
|
|
818
821
|
expect(() => {
|
|
819
|
-
|
|
822
|
+
GTINValidator.validateAny("9521873000122", GTINLevel.OtherThanRetailConsumer);
|
|
820
823
|
}).not.toThrow(RangeError);
|
|
821
824
|
expect(() => {
|
|
822
|
-
|
|
825
|
+
GTINValidator.validateAny("19521873000129", GTINLevel.OtherThanRetailConsumer);
|
|
823
826
|
}).not.toThrow(RangeError);
|
|
824
827
|
expect(() => {
|
|
825
|
-
|
|
828
|
+
GTINValidator.validateAny("9521873000160", GTINLevel.OtherThanRetailConsumer);
|
|
826
829
|
}).not.toThrow(RangeError);
|
|
827
830
|
expect(() => {
|
|
828
|
-
|
|
831
|
+
GTINValidator.validateAny("95216843", GTINLevel.OtherThanRetailConsumer);
|
|
829
832
|
}).toThrow("GTIN not supported at other than retail consumer trade item level");
|
|
830
833
|
expect(() => {
|
|
831
|
-
|
|
834
|
+
GTINValidator.validateAny("95217800031", GTINLevel.OtherThanRetailConsumer);
|
|
832
835
|
}).toThrow("GTIN must be 13, 12, 8, or 14 digits long");
|
|
833
836
|
expect(() => {
|
|
834
|
-
|
|
837
|
+
GTINValidator.validateAny("614141773985", GTINLevel.OtherThanRetailConsumer);
|
|
835
838
|
}).not.toThrow(RangeError);
|
|
836
839
|
expect(() => {
|
|
837
|
-
|
|
840
|
+
GTINValidator.validateAny("614141773991", GTINLevel.OtherThanRetailConsumer);
|
|
838
841
|
}).toThrow("Invalid check digit");
|
|
839
842
|
expect(() => {
|
|
840
|
-
|
|
843
|
+
GTINValidator.validateAny("09867539", GTINLevel.OtherThanRetailConsumer);
|
|
841
844
|
}).toThrow("GTIN not supported at other than retail consumer trade item level");
|
|
842
845
|
expect(() => {
|
|
843
|
-
|
|
846
|
+
GTINValidator.validateAny("09800037", GTINLevel.OtherThanRetailConsumer);
|
|
844
847
|
}).toThrow("Invalid zero-suppressed GTIN-12");
|
|
845
848
|
});
|
|
846
849
|
|
|
847
850
|
test("Normalization", () => {
|
|
848
851
|
// GTIN-14.
|
|
849
|
-
expect(
|
|
850
|
-
expect(
|
|
851
|
-
expect(() =>
|
|
852
|
-
expect(
|
|
853
|
-
expect(
|
|
852
|
+
expect(GTINValidator.normalize("09526543219996")).toBe("9526543219996");
|
|
853
|
+
expect(GTINValidator.normalize("00614141009992")).toBe("614141009992");
|
|
854
|
+
expect(() => GTINValidator.normalize("00000001234505")).toThrow("Invalid zero-suppressed GTIN-12 as GTIN-14");
|
|
855
|
+
expect(GTINValidator.normalize("00000095209999")).toBe("95209999");
|
|
856
|
+
expect(GTINValidator.normalize("49526543219994")).toBe("49526543219994");
|
|
854
857
|
|
|
855
858
|
// GTIN-13.
|
|
856
|
-
expect(
|
|
857
|
-
expect(
|
|
858
|
-
expect(() =>
|
|
859
|
-
expect(
|
|
859
|
+
expect(GTINValidator.normalize("9526543219996")).toBe("9526543219996");
|
|
860
|
+
expect(GTINValidator.normalize("0614141009992")).toBe("614141009992");
|
|
861
|
+
expect(() => GTINValidator.normalize("0000001234505")).toThrow("Invalid zero-suppressed GTIN-12 as GTIN-13");
|
|
862
|
+
expect(GTINValidator.normalize("0000095209999")).toBe("95209999");
|
|
860
863
|
|
|
861
864
|
// GTIN-12.
|
|
862
|
-
expect(
|
|
863
|
-
expect(
|
|
864
|
-
expect(() =>
|
|
865
|
+
expect(GTINValidator.normalize("614141009992")).toBe("614141009992");
|
|
866
|
+
expect(GTINValidator.normalize("01234505")).toBe("012000003455");
|
|
867
|
+
expect(() => GTINValidator.normalize("09800037")).toThrow("Invalid zero-suppressed GTIN-12");
|
|
865
868
|
|
|
866
869
|
// GTIN-8.
|
|
867
|
-
expect(
|
|
870
|
+
expect(GTINValidator.normalize("95209999")).toBe("95209999");
|
|
868
871
|
});
|
|
869
872
|
});
|
|
870
873
|
}
|
|
File without changes
|