fix(input-iban): allow formatting empty IBAN model values

This commit is contained in:
qa46hx 2019-05-01 13:28:20 +02:00 committed by Mikhail Bashkirov
parent 03264b3704
commit dcd7719a0f
2 changed files with 8 additions and 0 deletions

View file

@ -7,5 +7,9 @@ import { friendlyFormatIBAN } from '@bundled-es-modules/ibantools';
* @return {string} formatted value * @return {string} formatted value
*/ */
export function formatIBAN(modelValue) { export function formatIBAN(modelValue) {
// defensive code because of ibantools
if (modelValue === '') {
return '';
}
return friendlyFormatIBAN(modelValue); return friendlyFormatIBAN(modelValue);
} }

View file

@ -6,4 +6,8 @@ describe('formatIBAN', () => {
it('formats the IBAN', () => { it('formats the IBAN', () => {
expect(formatIBAN('NL17INGB0002822608')).to.equal('NL17 INGB 0002 8226 08'); expect(formatIBAN('NL17INGB0002822608')).to.equal('NL17 INGB 0002 8226 08');
}); });
it('returns `` if no value is given', () => {
expect(formatIBAN('')).to.equal('');
});
}); });