Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
enedis_sge_konnector
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
Show more breadcrumbs
web-et-numerique
Factory
LLLE_Project
enedis_sge_konnector
Commits
c77b8f2e
Commit
c77b8f2e
authored
2 years ago
by
Bastien DUMONT
Browse files
Options
Downloads
Patches
Plain Diff
fix: increase coverage
parent
abb720e9
No related branches found
No related tags found
1 merge request
!9
Feat/insee code
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
__tests__/requests/insee.spec.js
+4
-0
4 additions, 0 deletions
__tests__/requests/insee.spec.js
src/requests/insee.js
+2
-4
2 additions, 4 deletions
src/requests/insee.js
with
6 additions
and
4 deletions
__tests__/requests/insee.spec.js
+
4
−
0
View file @
c77b8f2e
...
@@ -8,6 +8,10 @@ describe('getInseeCode', () => {
...
@@ -8,6 +8,10 @@ describe('getInseeCode', () => {
expect
(
await
getInseeCode
(
69013
)).
toEqual
(
null
)
expect
(
await
getInseeCode
(
69013
)).
toEqual
(
null
)
})
})
it
(
'
should return null for post code 69290 when city is not provided
'
,
async
()
=>
{
expect
(
await
getInseeCode
(
69290
)).
toEqual
(
null
)
})
it
(
'
should return Craponne insee code for post code 69290
'
,
async
()
=>
{
it
(
'
should return Craponne insee code for post code 69290
'
,
async
()
=>
{
expect
(
await
getInseeCode
(
69290
,
'
CRAPONNE
'
)).
toEqual
(
'
69069
'
)
expect
(
await
getInseeCode
(
69290
,
'
CRAPONNE
'
)).
toEqual
(
'
69069
'
)
})
})
...
...
This diff is collapsed.
Click to expand it.
src/requests/insee.js
+
2
−
4
View file @
c77b8f2e
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
const
{
default
:
axios
}
=
require
(
'
axios
'
)
const
{
default
:
axios
}
=
require
(
'
axios
'
)
const
{
log
}
=
require
(
'
cozy-konnector-libs
'
)
const
{
log
}
=
require
(
'
cozy-konnector-libs
'
)
const
API_URL
=
'
https://apicarto.ign.fr/api
'
const
API_URL
=
'
https://apicarto.ign.fr/api
/codes-postaux/communes
'
/**
/**
* Return inseeCode given a postalCode
* Return inseeCode given a postalCode
...
@@ -12,9 +12,7 @@ const API_URL = 'https://apicarto.ign.fr/api'
...
@@ -12,9 +12,7 @@ const API_URL = 'https://apicarto.ign.fr/api'
*/
*/
async
function
getInseeCode
(
postalCode
,
city
)
{
async
function
getInseeCode
(
postalCode
,
city
)
{
try
{
try
{
const
response
=
await
axios
.
get
(
const
response
=
await
axios
.
get
(
`
${
API_URL
}
/
${
postalCode
}
`
)
`
${
API_URL
}
/codes-postaux/communes/
${
postalCode
}
`
)
log
(
'
info
'
,
`Query getInseeCode for postalCode
${
postalCode
}
/
${
city
}
`
)
log
(
'
info
'
,
`Query getInseeCode for postalCode
${
postalCode
}
/
${
city
}
`
)
if
(
response
.
data
.
length
===
1
)
{
if
(
response
.
data
.
length
===
1
)
{
...
...
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