Skip to content
Snippets Groups Projects
Commit ee3f5532 authored by Tore.Brede's avatar Tore.Brede
Browse files

GREG-60: Adding a test for phone numbers

parent 15ca5e7f
No related branches found
No related tags found
1 merge request!81GREG-60: Mobile phone validation
Pipeline #95723 passed
import { isValidMobilePhoneNumber } from './index'
// Mock i18next module to return a translation that just returns the key
jest.mock('i18next', () => ({
t: (value: string) => value,
}))
test('Invalid phone number', async () => {
expect(isValidMobilePhoneNumber('dafasfdsfasdf')).not.toEqual(true)
})
test('Valid phone number', async () => {
expect(isValidMobilePhoneNumber('+47 97510000')).toEqual(true)
})
......@@ -52,7 +52,10 @@ export function isValidFnr(data: string | undefined): boolean | string {
return i18n.t('common:validation.invalidIdNumber').toString()
}
export function isValidMobilePhoneNumber(data: string): boolean | string {
export function isValidMobilePhoneNumber(data: string | undefined): boolean | string {
if (!data) {
return i18n.t('common:validation.invalidMobilePhoneNumber').toString()
}
const valid = isValidPhoneNumber(data)
if (valid) {
return true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment