2018-11-15 10:55:27 +00:00
|
|
|
const validateIban = require('../validateIban');
|
|
|
|
|
|
|
|
describe('IBAN validation', () => {
|
2023-08-25 07:46:53 +00:00
|
|
|
it('should return false for invalid Spanish IBAN format', () => {
|
|
|
|
let isValid = validateIban('ES00 9999 0000 9999 0000 9999', 'ES');
|
2018-11-15 10:55:27 +00:00
|
|
|
|
|
|
|
expect(isValid).toBeFalsy();
|
|
|
|
});
|
|
|
|
|
2023-08-25 07:46:53 +00:00
|
|
|
it('should return true for valid Spanish IBAN', () => {
|
|
|
|
let isValid = validateIban('ES91 2100 0418 4502 0005 1332', 'ES');
|
|
|
|
|
|
|
|
expect(isValid).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return false for invalid Spanish IBAN with incorrect length', () => {
|
|
|
|
let isValid = validateIban('ES91210004184502000513', 'ES');
|
|
|
|
|
|
|
|
expect(isValid).toBeFalsy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return false for invalid Spanish IBAN with incorrect module97 result', () => {
|
|
|
|
let isValid = validateIban('ES9121000418450200051331', 'ES');
|
2018-11-15 10:55:27 +00:00
|
|
|
|
|
|
|
expect(isValid).toBeFalsy();
|
|
|
|
});
|
|
|
|
|
2023-08-25 07:46:53 +00:00
|
|
|
it('should return true for a non-Spanish countryCode', () => {
|
|
|
|
let isValid = validateIban('DE89370400440532013000', 'AT');
|
2018-11-15 10:55:27 +00:00
|
|
|
|
|
|
|
expect(isValid).toBeTruthy();
|
|
|
|
});
|
2023-08-25 07:46:53 +00:00
|
|
|
|
|
|
|
it('should return true for null IBAN', () => {
|
|
|
|
let isValid = validateIban(null, 'ES');
|
|
|
|
|
|
|
|
expect(isValid).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return false for non-string IBAN', () => {
|
|
|
|
let isValid = validateIban(12345, 'ES');
|
|
|
|
|
|
|
|
expect(isValid).toBeFalsy();
|
|
|
|
});
|
2018-11-15 10:55:27 +00:00
|
|
|
});
|