Skip to content

Commit

Permalink
feat(ean): switch gtin to ean aim codes
Browse files Browse the repository at this point in the history
  • Loading branch information
stonelasley committed Feb 7, 2019
1 parent 73adacc commit a09d303
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/__tests__/config/aim-codes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('AimCodes', () => {

describe('GTIN', () => {
it('should return GTIN code', () => {
expect(AimCodes.GTIN).toBe(']E');
expect(AimCodes.GTIN).toBe(']E0');
});
});

Expand All @@ -33,7 +33,7 @@ describe('AimCodes', () => {

describe('EAN13', () => {
it('should return EAN code', () => {
expect(AimCodes.EAN13).toBe(']E4');
expect(AimCodes.EAN13).toBe(']E3');
});
});
});
10 changes: 5 additions & 5 deletions src/__tests__/readers/gtin-12.reader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
});
});
Expand Down
10 changes: 5 additions & 5 deletions src/__tests__/readers/gtin-13.reader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
});
});
Expand Down
10 changes: 5 additions & 5 deletions src/__tests__/readers/gtin-14.reader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
});
});
Expand Down
10 changes: 5 additions & 5 deletions src/__tests__/readers/gtin-8.reader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
});
});
Expand Down
6 changes: 3 additions & 3 deletions src/config/aim-codes.ts
Original file line number Diff line number Diff line change
@@ -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',
}
2 changes: 1 addition & 1 deletion src/readers/gtin-12.reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/readers/gtin-13.reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/readers/gtin-14.reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/readers/gtin-8.reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit a09d303

Please sign in to comment.