const validateDni = require('../validateDni'); describe('DNI validation', () => { it('should return false for invented DNI', () => { let isValid = validateDni('Pepinillos'); expect(isValid).toBeFalsy(); }); describe('Spanish', () => { it('should return true for valid spanish DNI', () => { let isValid = validateDni('20849756A'); expect(isValid).toBeTruthy(); }); it('should return false for spanish DNI with exceeded digits', () => { let isValid = validateDni('208497563239A'); expect(isValid).toBeFalsy(); }); it('should return false for spanish DNI with invalid letter', () => { let isValid = validateDni('20243746E'); expect(isValid).toBeFalsy(); }); it('should return true for valid spanish CIF', () => { let isValid = validateDni('B97367486'); expect(isValid).toBeTruthy(); }); it('should return false for spanish CIF with invalid letter', () => { let isValid = validateDni('A97527786'); expect(isValid).toBeFalsy(); }); }); describe('French', () => { it('should return true for valid french DNI', () => { let isValid = validateDni('1B123456789', 'fr'); expect(isValid).toBeTruthy(); }); it('should return false for french DNI with exceeded digits', () => { let isValid = validateDni('1B12345678910', 'fr'); expect(isValid).toBeFalsy(); }); it('should return false for french DNI with bad syntax', () => { let isValid = validateDni('1B12345678A', 'fr'); expect(isValid).toBeFalsy(); }); }); describe('Italian', () => { it('should return true for valid italian DNI', () => { let isValid = validateDni('12345678911', 'it'); expect(isValid).toBeTruthy(); }); it('should return false for italian DNI with exceeded digits', () => { let isValid = validateDni('123456789112', 'it'); expect(isValid).toBeFalsy(); }); it('should return false for italian DNI with bad syntax', () => { let isValid = validateDni('1234567891A', 'it'); expect(isValid).toBeFalsy(); }); }); describe('Portuguese', () => { it('should return true for valid portuguese DNI', () => { let isValid = validateDni('123456789', 'pt'); expect(isValid).toBeTruthy(); }); it('should return false for portuguese DNI with exceeded digits', () => { let isValid = validateDni('12345678910', 'pt'); expect(isValid).toBeFalsy(); }); it('should return false for portuguese DNI with bad syntax', () => { let isValid = validateDni('12345678A', 'pt'); expect(isValid).toBeFalsy(); }); }); });