Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
greg
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
it-bott-integrasjoner
greg
Commits
ee3f5532
Commit
ee3f5532
authored
3 years ago
by
Tore.Brede
Browse files
Options
Downloads
Patches
Plain Diff
GREG-60: Adding a test for phone numbers
parent
15ca5e7f
No related branches found
No related tags found
1 merge request
!81
GREG-60: Mobile phone validation
Pipeline
#95723
passed
3 years ago
Stage: venv update
Stage: tests and linting
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/utils/index.test.ts
+14
-0
14 additions, 0 deletions
frontend/src/utils/index.test.ts
frontend/src/utils/index.ts
+4
-1
4 additions, 1 deletion
frontend/src/utils/index.ts
with
18 additions
and
1 deletion
frontend/src/utils/index.test.ts
0 → 100644
+
14
−
0
View file @
ee3f5532
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
)
})
This diff is collapsed.
Click to expand it.
frontend/src/utils/index.ts
+
4
−
1
View file @
ee3f5532
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment