Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ecolyo
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
Ecolyo
Commits
fbd49bdd
Commit
fbd49bdd
authored
4 years ago
by
Yoan VALLET
Browse files
Options
Downloads
Patches
Plain Diff
feat: return null return for ecogesture service
parent
7e02de11
No related branches found
No related tags found
1 merge request
!139
Features/unit tests
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/services/ecogesture.service.spec.ts
+4
-4
4 additions, 4 deletions
src/services/ecogesture.service.spec.ts
src/services/ecogesture.service.ts
+1
-4
1 addition, 4 deletions
src/services/ecogesture.service.ts
with
5 additions
and
8 deletions
src/services/ecogesture.service.spec.ts
+
4
−
4
View file @
fbd49bdd
...
@@ -67,10 +67,10 @@ describe('Ecogesture service', () => {
...
@@ -67,10 +67,10 @@ describe('Ecogesture service', () => {
const
result
=
await
ecogestureService
.
getAllEcogestures
()
const
result
=
await
ecogestureService
.
getAllEcogestures
()
expect
(
result
).
toEqual
(
mockData
)
expect
(
result
).
toEqual
(
mockData
)
})
})
it
(
'
shoud return
null
when no ecogestures stored
'
,
async
()
=>
{
it
(
'
shoud return
empty array
when no ecogestures stored
'
,
async
()
=>
{
mockClient
.
query
.
mockResolvedValueOnce
({
data
:
null
})
mockClient
.
query
.
mockResolvedValueOnce
({
data
:
[]
})
const
result
=
await
ecogestureService
.
getAllEcogestures
()
const
result
=
await
ecogestureService
.
getAllEcogestures
()
expect
(
result
).
to
Be
(
null
)
expect
(
result
).
to
Equal
([]
)
})
})
})
})
...
@@ -84,7 +84,7 @@ describe('Ecogesture service', () => {
...
@@ -84,7 +84,7 @@ describe('Ecogesture service', () => {
expect
(
result
).
toBe
(
true
)
expect
(
result
).
toBe
(
true
)
})
})
it
(
'
shoud return true when no ecogestures stored
'
,
async
()
=>
{
it
(
'
shoud return true when no ecogestures stored
'
,
async
()
=>
{
mockClient
.
query
.
mockImplementation
(()
=>
Promise
.
resolve
({
data
:
null
}))
mockClient
.
query
.
mockImplementation
(()
=>
Promise
.
resolve
({
data
:
[]
}))
const
result
=
await
ecogestureService
.
deleteAllEcogestures
()
const
result
=
await
ecogestureService
.
deleteAllEcogestures
()
expect
(
result
).
toBe
(
true
)
expect
(
result
).
toBe
(
true
)
})
})
...
...
This diff is collapsed.
Click to expand it.
src/services/ecogesture.service.ts
+
1
−
4
View file @
fbd49bdd
...
@@ -9,18 +9,15 @@ export default class EcogestureService {
...
@@ -9,18 +9,15 @@ export default class EcogestureService {
this
.
_client
=
_client
this
.
_client
=
_client
}
}
public
async
getAllEcogestures
():
Promise
<
Ecogesture
[]
|
null
>
{
public
async
getAllEcogestures
():
Promise
<
Ecogesture
[]
>
{
const
ecogestures
=
await
this
.
_client
.
query
(
const
ecogestures
=
await
this
.
_client
.
query
(
this
.
_client
.
find
(
ECOGESTURE_DOCTYPE
)
this
.
_client
.
find
(
ECOGESTURE_DOCTYPE
)
)
)
if
(
!
ecogestures
)
return
null
return
ecogestures
.
data
return
ecogestures
.
data
}
}
public
async
deleteAllEcogestures
():
Promise
<
boolean
>
{
public
async
deleteAllEcogestures
():
Promise
<
boolean
>
{
const
ecogestures
=
await
this
.
getAllEcogestures
()
const
ecogestures
=
await
this
.
getAllEcogestures
()
if
(
!
ecogestures
)
return
true
try
{
try
{
for
(
let
index
=
0
;
index
<
ecogestures
.
length
;
index
++
)
{
for
(
let
index
=
0
;
index
<
ecogestures
.
length
;
index
++
)
{
await
this
.
_client
.
destroy
(
ecogestures
[
index
])
await
this
.
_client
.
destroy
(
ecogestures
[
index
])
...
...
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