polish-validators
Version:
A set of validator functions that check common polish numbers.
28 lines (27 loc) • 1.7 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const id_card_1 = require("./id-card");
describe('Polish ID Card Number Validation', () => {
describe('isIdCardNumberValid', () => {
it('should return true for a valid Polish ID card number', () => {
expect((0, id_card_1.isIdCardNumberValid)('ABC412345')).toBe(true);
});
it('should return true for a valid ID card number with extra spaces or in lower-case', () => {
// The utility function toLettersAndDigits should ignore extra whitespace and case.
// "abc 412345" should be normalized to "ABC412345" and pass validation.
expect((0, id_card_1.isIdCardNumberValid)('abc 412345')).toBe(true);
});
it('should return false if the ID card number does not match the required pattern', () => {
// Example with only two letters and too many digits (pattern must be 3 letters and 6 digits).
expect((0, id_card_1.isIdCardNumberValid)('AB4123456')).toBe(false);
});
it('should return false for an ID card number with an incorrect control digit', () => {
// "ABC512345" is the same as the valid number except the control digit (position 3) is altered from 4 to 5.
expect((0, id_card_1.isIdCardNumberValid)('ABC512345')).toBe(false);
});
it('should return false for an ID card number with invalid characters in the numeric part', () => {
// The numeric part should contain only digits; here a non-digit is introduced.
expect((0, id_card_1.isIdCardNumberValid)('ABC4A2345')).toBe(false);
});
});
});