UNPKG

sprinque-js-sdk-wip

Version:

UI kit to implement Pay by Invoice with Sprinque

73 lines (72 loc) 2.78 kB
import { checkRegistrationNumber } from './index'; import { getTranslationKey } from './helpers'; describe('Registration number', () => { test('Netherlands', () => { // Happy flow expect(checkRegistrationNumber('77651006', 'nl')).toEqual({ isValid: true, message: '', }); // Unhappy flow expect(checkRegistrationNumber('', 'nl', 'nl')).toEqual({ isValid: false, message: getTranslationKey('nl', 'errors', 'required'), }); expect(checkRegistrationNumber('776510060002', 'nl', 'nl')).toEqual({ isValid: false, message: getTranslationKey('nl', 'errors', 'deleteFourLastDigits'), }); expect(checkRegistrationNumber('abc77651006', 'nl', 'nl')).toEqual({ isValid: false, message: getTranslationKey('nl', 'errors', 'formatIs') + ' "77651006"', }); }); test('Belgium', () => { // Happy flow expect(checkRegistrationNumber('071194951', 'be')).toEqual({ isValid: true, message: '', }); // Unhappy flow expect(checkRegistrationNumber('BE0711949514', 'BE')).toEqual({ isValid: false, message: 'The value seems to be a VAT ID. Please follow the format like "071194951"', }); expect(checkRegistrationNumber('anyOtherValue', 'be')).toEqual({ isValid: false, message: 'Registration number format should be like "071194951"', }); }); test('Spain', () => { // Happy flow expect(checkRegistrationNumber('00275914Y', 'ES')).toEqual({ isValid: true, message: '', }); // Unhappy flow expect(checkRegistrationNumber('002.759.14Y', 'ES')).toEqual({ isValid: false, message: 'Registration number format should be like "00275914Y" or "B10612307"', }); expect(checkRegistrationNumber('1234abc', 'es')).toEqual({ isValid: false, message: 'Registration number format should be like "00275914Y" or "B10612307"', }); }); test('France', () => { // Happy flow expect(checkRegistrationNumber('410034607', 'fr')).toEqual({ isValid: true, message: '', }); // Unhappy flow expect(checkRegistrationNumber('FR794100346074', 'fr')).toEqual({ isValid: false, message: 'The value seems to be a VAT ID. Please follow the format like "410034607"', }); expect(checkRegistrationNumber('11-23-049', 'fr')).toEqual({ isValid: false, message: 'Registration number format should be like "410034607"', }); }); });