UNPKG

polish-validators

Version:

A set of validator functions that check common polish numbers.

38 lines (37 loc) 2.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const regon_1 = require("./regon"); describe('REGON', () => { it('should return true for a valid 9-digit REGON number', () => { expect((0, regon_1.isRegonValid)('123456785')).toBe(true); // 9-digit }); it('should return true for a valid 14-digit REGON number', () => { expect((0, regon_1.isRegonValid)('12345678512347')).toBe(true); // 14-digit }); it('should return true for a valid REGON with dashes and whitespace', () => { expect((0, regon_1.isRegonValid)('123-456-785')).toBe(true); // 9-digit with separators expect((0, regon_1.isRegonValid)('123-456-785 123 47')).toBe(true); // 14-digit with separators }); it('should return false for a REGON with incorrect control number (9 digits)', () => { expect((0, regon_1.isRegonValid)('123456786')).toBe(false); // wrong control number for 9-digit REGON }); it('should return false for a REGON with incorrect control number (14 digits)', () => { expect((0, regon_1.isRegonValid)('12345678512348')).toBe(false); // wrong control number for 14-digit REGON }); it('should return false for a REGON with an invalid length', () => { expect((0, regon_1.isRegonValid)('12345678')).toBe(false); // 8 digits expect((0, regon_1.isRegonValid)('123456785123')).toBe(false); // 12 digits expect((0, regon_1.isRegonValid)('1234567851234789')).toBe(false); // 16 digits }); it('should return false for a REGON that is all zeros', () => { expect((0, regon_1.isRegonValid)('000000000')).toBe(false); // 9 zeros expect((0, regon_1.isRegonValid)('00000000000000')).toBe(false); // 14 zeros }); it('should return false for a REGON with non-numeric characters', () => { expect((0, regon_1.isRegonValid)('12345678A')).toBe(false); // contains letters expect((0, regon_1.isRegonValid)('1234-5678A5')).toBe(false); // contains letters with dashes }); it('should return false for an empty string', () => { expect((0, regon_1.isRegonValid)('')).toBe(false); // empty string }); });