From a09d303a7c15265a45fadd5ccf44124bf1b2a5b1 Mon Sep 17 00:00:00 2001 From: "Stone C. Lasley" Date: Thu, 7 Feb 2019 13:41:36 -0700 Subject: [PATCH] feat(ean): switch gtin to ean aim codes --- src/__tests__/config/aim-codes.spec.ts | 4 ++-- src/__tests__/readers/gtin-12.reader.spec.ts | 10 +++++----- src/__tests__/readers/gtin-13.reader.spec.ts | 10 +++++----- src/__tests__/readers/gtin-14.reader.spec.ts | 10 +++++----- src/__tests__/readers/gtin-8.reader.spec.ts | 10 +++++----- src/config/aim-codes.ts | 6 +++--- src/readers/gtin-12.reader.ts | 2 +- src/readers/gtin-13.reader.ts | 2 +- src/readers/gtin-14.reader.ts | 2 +- src/readers/gtin-8.reader.ts | 2 +- 10 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/__tests__/config/aim-codes.spec.ts b/src/__tests__/config/aim-codes.spec.ts index 237fff0..01e7f03 100644 --- a/src/__tests__/config/aim-codes.spec.ts +++ b/src/__tests__/config/aim-codes.spec.ts @@ -9,7 +9,7 @@ describe('AimCodes', () => { describe('GTIN', () => { it('should return GTIN code', () => { - expect(AimCodes.GTIN).toBe(']E'); + expect(AimCodes.GTIN).toBe(']E0'); }); }); @@ -33,7 +33,7 @@ describe('AimCodes', () => { describe('EAN13', () => { it('should return EAN code', () => { - expect(AimCodes.EAN13).toBe(']E4'); + expect(AimCodes.EAN13).toBe(']E3'); }); }); }); diff --git a/src/__tests__/readers/gtin-12.reader.spec.ts b/src/__tests__/readers/gtin-12.reader.spec.ts index a50f17a..35e86e6 100644 --- a/src/__tests__/readers/gtin-12.reader.spec.ts +++ b/src/__tests__/readers/gtin-12.reader.spec.ts @@ -12,16 +12,16 @@ describe('Gtin12Reader', () => { describe('validate', () => { test('should validate by length', () => { /* tslint:disable */ - expect(classUnderTest['validate'](']E111111111111')).toBe(true); - expect(classUnderTest['validate'](']E111111111111111')).toBe(false); - expect(classUnderTest['validate']('E[1111111')).toBe(false); + expect(classUnderTest['validate'](']E0111111111111')).toBe(true); + expect(classUnderTest['validate'](']E0111111111111111')).toBe(false); + expect(classUnderTest['validate']('E[01111111')).toBe(false); /* tslint:enable */ }); test('should validate character type', () => { /* tslint:disable */ - expect(classUnderTest['validate'](']E111111111111')).toBe(true); - expect(classUnderTest['validate'](']Eaaaaaaaaaaaa')).toBe(false); + expect(classUnderTest['validate'](']E0111111111111')).toBe(true); + expect(classUnderTest['validate'](']E0aaaaaaaaaaaa')).toBe(false); /* tslint:enable */ }); }); diff --git a/src/__tests__/readers/gtin-13.reader.spec.ts b/src/__tests__/readers/gtin-13.reader.spec.ts index 1dbf06c..7b5e72d 100644 --- a/src/__tests__/readers/gtin-13.reader.spec.ts +++ b/src/__tests__/readers/gtin-13.reader.spec.ts @@ -12,16 +12,16 @@ describe('Gtin13Reader', () => { describe('validate', () => { test('should validate value length', () => { /* tslint:disable */ - expect(classUnderTest['validate'](']E1111111111111')).toBe(true); - expect(classUnderTest['validate'](']E11111111111111')).toBe(false); - expect(classUnderTest['validate'](']E111111')).toBe(false); + expect(classUnderTest['validate'](']E01111111111111')).toBe(true); + expect(classUnderTest['validate'](']E011111111111111')).toBe(false); + expect(classUnderTest['validate'](']E0111111')).toBe(false); /* tslint:enable */ }); test('should validate character type', () => { /* tslint:disable */ - expect(classUnderTest['validate'](']E1111111111111')).toBe(true); - expect(classUnderTest['validate'](']Eaaaaaaaaaaaaa')).toBe(false); + expect(classUnderTest['validate'](']E01111111111111')).toBe(true); + expect(classUnderTest['validate'](']E0aaaaaaaaaaaaa')).toBe(false); /* tslint:enable */ }); }); diff --git a/src/__tests__/readers/gtin-14.reader.spec.ts b/src/__tests__/readers/gtin-14.reader.spec.ts index 63e5782..c02d535 100644 --- a/src/__tests__/readers/gtin-14.reader.spec.ts +++ b/src/__tests__/readers/gtin-14.reader.spec.ts @@ -12,16 +12,16 @@ describe('Gtin14Reader', () => { describe('validate', () => { test('should validate value length', () => { /* tslint:disable */ - expect(classUnderTest['validate'](']E11111111111111')).toBe(true); - expect(classUnderTest['validate'](']E111111111111111')).toBe(false); - expect(classUnderTest['validate'](']E1111111')).toBe(false); + expect(classUnderTest['validate'](']E011111111111111')).toBe(true); + expect(classUnderTest['validate'](']E0111111111111111')).toBe(false); + expect(classUnderTest['validate'](']E01111111')).toBe(false); /* tslint:enable */ }); test('should validate character type', () => { /* tslint:disable */ - expect(classUnderTest['validate'](']E11111111111111')).toBe(true); - expect(classUnderTest['validate'](']Eaaaaaaaaaaaaaa')).toBe(false); + expect(classUnderTest['validate'](']E011111111111111')).toBe(true); + expect(classUnderTest['validate'](']E0aaaaaaaaaaaaaa')).toBe(false); /* tslint:enable */ }); }); diff --git a/src/__tests__/readers/gtin-8.reader.spec.ts b/src/__tests__/readers/gtin-8.reader.spec.ts index 61b6d0c..9f13227 100644 --- a/src/__tests__/readers/gtin-8.reader.spec.ts +++ b/src/__tests__/readers/gtin-8.reader.spec.ts @@ -12,16 +12,16 @@ describe('Gtin8Reader', () => { describe('validate', () => { test('should validate by length', () => { /* tslint:disable */ - expect(classUnderTest['validate'](']E11111111')).toBe(true); - expect(classUnderTest['validate'](']E111111111')).toBe(false); - expect(classUnderTest['validate'](']E1111111')).toBe(false); + expect(classUnderTest['validate'](']E411111111')).toBe(true); + expect(classUnderTest['validate'](']E4111111111')).toBe(false); + expect(classUnderTest['validate'](']E41111111')).toBe(false); /* tslint:enable */ }); test('should validate character type', () => { /* tslint:disable */ - expect(classUnderTest['validate'](']E11111111')).toBe(true); - expect(classUnderTest['validate'](']Eaaaaaaaa')).toBe(false); + expect(classUnderTest['validate'](']E411111111')).toBe(true); + expect(classUnderTest['validate'](']E0aaaaaaaa')).toBe(false); /* tslint:enable */ }); }); diff --git a/src/config/aim-codes.ts b/src/config/aim-codes.ts index 8337993..bb0beec 100644 --- a/src/config/aim-codes.ts +++ b/src/config/aim-codes.ts @@ -1,9 +1,9 @@ export enum AimCodes { GS1 = ']C1', - GTIN = ']E', + GTIN = ']E0', ITF = ']I0', CODE39 = ']A0', CODE128 = ']C0', - EAN13 = ']E4', - EAN8 = ']E0', + EAN13 = ']E3', + EAN8 = ']E4', } diff --git a/src/readers/gtin-12.reader.ts b/src/readers/gtin-12.reader.ts index de8e1da..7f9696f 100644 --- a/src/readers/gtin-12.reader.ts +++ b/src/readers/gtin-12.reader.ts @@ -2,7 +2,7 @@ import { IReaderConfiguration } from '../models'; import { BaseGtinReader } from './base-gtin.reader'; import { Symbologies } from '../config'; -const REG: RegExp = /^\]E[0-9]{12,12}$/; +const REG: RegExp = /^\]E0[0-9]{12,12}$/; export class Gtin12Reader extends BaseGtinReader { constructor(readerConfig?: IReaderConfiguration) { diff --git a/src/readers/gtin-13.reader.ts b/src/readers/gtin-13.reader.ts index 5b4ece7..fedb326 100644 --- a/src/readers/gtin-13.reader.ts +++ b/src/readers/gtin-13.reader.ts @@ -2,7 +2,7 @@ import { IReaderConfiguration } from '../models'; import { BaseGtinReader } from './base-gtin.reader'; import { Symbologies } from '../config'; -const REG: RegExp = /^\]E[0-9]{13,13}$/; +const REG: RegExp = /^\]E0[0-9]{13,13}$/; export class Gtin13Reader extends BaseGtinReader { constructor(readerConfig?: IReaderConfiguration) { diff --git a/src/readers/gtin-14.reader.ts b/src/readers/gtin-14.reader.ts index 144adef..b10f4a3 100644 --- a/src/readers/gtin-14.reader.ts +++ b/src/readers/gtin-14.reader.ts @@ -2,7 +2,7 @@ import { IReaderConfiguration } from '../models'; import { BaseGtinReader } from './base-gtin.reader'; import { Symbologies } from '../config'; -const REG: RegExp = /^\]E[0-9]{14,14}$/; +const REG: RegExp = /^\]E0[0-9]{14,14}$/; export class Gtin14Reader extends BaseGtinReader { constructor(readerConfig?: IReaderConfiguration) { diff --git a/src/readers/gtin-8.reader.ts b/src/readers/gtin-8.reader.ts index 0cf5448..44d3eb2 100644 --- a/src/readers/gtin-8.reader.ts +++ b/src/readers/gtin-8.reader.ts @@ -2,7 +2,7 @@ import { IReaderConfiguration } from '../models'; import { BaseGtinReader } from './base-gtin.reader'; import { Symbologies } from '../config'; -const REG: RegExp = /^\]E[0-9]{8,8}$/; +const REG: RegExp = /^\]E4[0-9]{8,8}$/; export class Gtin8Reader extends BaseGtinReader { constructor(readerConfig?: IReaderConfiguration) {