Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
web-et-numerique
LLLE_Project
Ecolyo
Commits
6d41cb24
Commit
6d41cb24
authored
Oct 27, 2021
by
Hugo NOUTS
Browse files
feat(ProfileType): First profileType created by user acts as default
parent
06db2d08
Changes
19
Expand all
Hide whitespace changes
Inline
Side-by-side
src/services/action.service.spec.ts
View file @
6d41cb24
...
...
@@ -35,14 +35,14 @@ jest.mock('./ecogesture.service', () => {
describe
(
'
Action Service
'
,
()
=>
{
const
actionService
=
new
ActionService
(
mockClient
)
it
(
'
shoud return the default actions
'
,
async
()
=>
{
it
(
'
shou
l
d return the default actions
'
,
async
()
=>
{
mockgetAllEcogestures
.
mockResolvedValueOnce
(
AllEcogestureData
)
mockgetEcogesturesByIds
.
mockResolvedValueOnce
(
defaultEcogestureData
)
const
result
:
Ecogesture
[]
=
await
actionService
.
getDefaultActions
()
expect
(
result
).
toEqual
(
defaultEcogestureData
)
})
it
(
'
shoud return the Available Action List
'
,
async
()
=>
{
it
(
'
shou
l
d return the Available Action List
'
,
async
()
=>
{
mockgetAllUserChallengeEntities
.
mockResolvedValueOnce
(
userChallengeData
)
mockgetAllEcogestures
.
mockResolvedValueOnce
(
AllEcogestureData
)
mockgetEcogesturesByIds
.
mockResolvedValueOnce
([
...
...
@@ -58,7 +58,7 @@ describe('Action Service', () => {
AllEcogestureData
[
4
],
])
})
it
(
'
shoud return winter ecogestures
'
,
()
=>
{
it
(
'
shou
l
d return winter ecogestures
'
,
()
=>
{
jest
.
spyOn
(
utils
,
'
getSeason
'
).
mockReturnValueOnce
(
Season
.
WINTER
)
const
result
:
Ecogesture
[]
=
actionService
.
filterBySeason
(
AllEcogestureData
)
expect
(
result
).
toEqual
([
...
...
@@ -67,13 +67,13 @@ describe('Action Service', () => {
AllEcogestureData
[
5
],
])
})
it
(
'
shoud return no season ecogestures
'
,
()
=>
{
it
(
'
shou
l
d return no season ecogestures
'
,
()
=>
{
jest
.
spyOn
(
utils
,
'
getSeason
'
).
mockReturnValueOnce
(
Season
.
NONE
)
const
result
:
Ecogesture
[]
=
actionService
.
filterBySeason
(
AllEcogestureData
)
expect
(
result
).
toEqual
([
AllEcogestureData
[
3
],
AllEcogestureData
[
4
]])
})
it
(
'
shoud return summer ecogestures
'
,
()
=>
{
it
(
'
shou
l
d return summer ecogestures
'
,
()
=>
{
jest
.
spyOn
(
utils
,
'
getSeason
'
).
mockReturnValueOnce
(
Season
.
SUMMER
)
const
result
:
Ecogesture
[]
=
actionService
.
filterBySeason
(
AllEcogestureData
)
...
...
@@ -84,7 +84,7 @@ describe('Action Service', () => {
])
})
it
(
'
shoud launch an action
'
,
()
=>
{
it
(
'
shou
l
d launch an action
'
,
()
=>
{
jest
.
spyOn
(
DateTime
,
'
local
'
)
.
mockReturnValueOnce
(
...
...
@@ -119,7 +119,7 @@ describe('Action Service', () => {
})
describe
(
'
getCustomActions function
'
,
()
=>
{
it
(
'
shoud return filtered and sorted ecogestures and not complete the list
'
,
async
()
=>
{
it
(
'
shou
l
d return filtered and sorted ecogestures and not complete the list
'
,
async
()
=>
{
jest
.
spyOn
(
utils
,
'
getSeason
'
).
mockReturnValueOnce
(
Season
.
WINTER
)
mockgetAllUserChallengeEntities
.
mockResolvedValueOnce
(
userChallengeData
)
mockgetAllEcogestures
.
mockResolvedValueOnce
(
AllEcogestureData
)
...
...
@@ -139,7 +139,7 @@ describe('Action Service', () => {
AllEcogestureData
[
2
],
])
})
it
(
'
shoud return filtered and sorted ecogestures and complete the list with default ecogesture
'
,
async
()
=>
{
it
(
'
shou
l
d return filtered and sorted ecogestures and complete the list with default ecogesture
'
,
async
()
=>
{
jest
.
spyOn
(
utils
,
'
getSeason
'
).
mockReturnValueOnce
(
Season
.
WINTER
)
mockgetAllUserChallengeEntities
.
mockResolvedValueOnce
(
userChallengeData
)
mockgetAllEcogestures
.
mockResolvedValueOnce
(
AllEcogestureData
)
...
...
src/services/connection.service.spec.ts
View file @
6d41cb24
...
...
@@ -35,7 +35,7 @@ describe('Connection service', () => {
const
connectionService
=
new
ConnectionService
(
mockClient
)
describe
(
'
connectNewUser method
'
,
()
=>
{
it
(
'
shoud return created Trigger
'
,
async
()
=>
{
it
(
'
shou
l
d return created Trigger
'
,
async
()
=>
{
mockGetKonnector
.
mockResolvedValueOnce
(
konnectorsData
[
0
])
mockCreateAccount
.
mockResolvedValueOnce
(
accountsData
[
0
])
mockCreateTrigger
.
mockResolvedValueOnce
(
triggersData
[
0
])
...
...
@@ -48,7 +48,7 @@ describe('Connection service', () => {
expect
(
result
).
toEqual
(
mockResult
)
})
it
(
'
shoud throw error when konnector is not found
'
,
async
()
=>
{
it
(
'
shou
l
d throw error when konnector is not found
'
,
async
()
=>
{
let
error
try
{
await
connectionService
.
connectNewUser
(
...
...
@@ -64,7 +64,7 @@ describe('Connection service', () => {
)
})
it
(
'
shoud throw error when account is not created
'
,
async
()
=>
{
it
(
'
shou
l
d throw error when account is not created
'
,
async
()
=>
{
mockGetKonnector
.
mockResolvedValueOnce
(
konnectorsData
[
0
])
let
error
try
{
...
...
@@ -79,7 +79,7 @@ describe('Connection service', () => {
expect
(
error
).
toEqual
(
new
Error
(
`Error during account creation`
))
})
it
(
'
shoud throw error when trigger is not created
'
,
async
()
=>
{
it
(
'
shou
l
d throw error when trigger is not created
'
,
async
()
=>
{
mockGetKonnector
.
mockResolvedValueOnce
(
konnectorsData
[
0
])
mockCreateAccount
.
mockResolvedValueOnce
(
accountsData
[
0
])
let
error
...
...
src/services/consumption.service.spec.ts
View file @
6d41cb24
...
...
@@ -66,7 +66,7 @@ describe('Consumption service', () => {
)
expect
(
result
).
toBeNull
()
})
it
(
'
shoud return a mapped data for one fluid
'
,
async
()
=>
{
it
(
'
shou
l
d return a mapped data for one fluid
'
,
async
()
=>
{
mockFetchFluidData
.
mockResolvedValueOnce
(
mockFetchDataActual
)
mockFetchFluidData
.
mockResolvedValueOnce
(
mockFetchDataComparison
)
const
mockResult
=
{
...
...
@@ -241,7 +241,7 @@ describe('Consumption service', () => {
})
})
describe
(
'
getMaxLoad method
'
,
()
=>
{
it
(
'
shoud return the maxed value for a time period for the home
'
,
async
()
=>
{
it
(
'
shou
l
d return the maxed value for a time period for the home
'
,
async
()
=>
{
for
(
let
i
=
0
;
i
<
fluidTypes
.
length
;
i
++
)
{
mockFetchFluidData
.
mockResolvedValueOnce
(
mockFetchDataActual
)
mockFetchFluidData
.
mockResolvedValueOnce
(
mockFetchDataComparison
)
...
...
@@ -256,7 +256,7 @@ describe('Consumption service', () => {
)
expect
(
result
).
toEqual
(
expectedResult
)
})
it
(
'
shoud return the maxed value for a time period
'
,
async
()
=>
{
it
(
'
shou
l
d return the maxed value for a time period
'
,
async
()
=>
{
const
mockFluidTypes
=
[
1
]
const
expectedResult
=
63.1254
mockFetchFluidMaxData
.
mockResolvedValueOnce
(
expectedResult
)
...
...
@@ -271,7 +271,7 @@ describe('Consumption service', () => {
})
})
describe
(
'
getPerformanceIndicators method
'
,
()
=>
{
it
(
'
shoud return the performance indicator
'
,
async
()
=>
{
it
(
'
shou
l
d return the performance indicator
'
,
async
()
=>
{
mockFetchFluidData
.
mockResolvedValueOnce
(
mockFetchDataActual
)
mockFetchFluidData
.
mockResolvedValueOnce
(
mockFetchDataComparison
)
mockFetchFluidData
.
mockResolvedValueOnce
(
mockFetchDataActual
)
...
...
@@ -321,7 +321,7 @@ describe('Consumption service', () => {
})
})
describe
(
'
fetchLastDateData method
'
,
()
=>
{
it
(
'
shoud return the latest date data of one fluid
'
,
async
()
=>
{
it
(
'
shou
l
d return the latest date data of one fluid
'
,
async
()
=>
{
const
mockFluidTypes
=
[
0
]
const
expectedResult
=
DateTime
.
fromISO
(
'
2020-09-03T23:59:59.999Z
'
)
mockGetLastDateData
.
mockResolvedValueOnce
(
...
...
@@ -332,7 +332,7 @@ describe('Consumption service', () => {
)
expect
(
result
).
toEqual
(
expectedResult
)
})
it
(
'
shoud return the latest date data of multiple fluid
'
,
async
()
=>
{
it
(
'
shou
l
d return the latest date data of multiple fluid
'
,
async
()
=>
{
const
mockFluidTypes
=
[
0
,
2
]
mockGetLastDateData
.
mockResolvedValueOnce
(
DateTime
.
fromISO
(
'
2020-09-03T23:59:59.999Z
'
)
...
...
@@ -346,7 +346,7 @@ describe('Consumption service', () => {
)
expect
(
result
).
toEqual
(
expectedResult
)
})
it
(
'
shoud return the latest date data of all fluids
'
,
async
()
=>
{
it
(
'
shou
l
d return the latest date data of all fluids
'
,
async
()
=>
{
mockGetLastDateData
.
mockResolvedValueOnce
(
DateTime
.
fromISO
(
'
2020-09-02T23:59:59.999Z
'
)
)
...
...
@@ -365,7 +365,7 @@ describe('Consumption service', () => {
})
})
describe
(
'
fetchAllLastDateData method
'
,
()
=>
{
it
(
'
shoud return the latest date data of one fluid
'
,
async
()
=>
{
it
(
'
shou
l
d return the latest date data of one fluid
'
,
async
()
=>
{
const
mockFluidTypes
=
[
0
]
const
expectedResult
=
[
DateTime
.
fromISO
(
'
2020-09-03T23:59:59.999Z
'
)]
mockGetLastDateData
.
mockResolvedValueOnce
(
...
...
@@ -376,7 +376,7 @@ describe('Consumption service', () => {
)
expect
(
result
).
toEqual
(
expectedResult
)
})
it
(
'
shoud return the latest date data of All fluid
'
,
async
()
=>
{
it
(
'
shou
l
d return the latest date data of All fluid
'
,
async
()
=>
{
mockGetLastDateData
.
mockResolvedValueOnce
(
DateTime
.
fromISO
(
'
2020-09-02T23:59:59.999Z
'
)
)
...
...
@@ -398,7 +398,7 @@ describe('Consumption service', () => {
})
})
describe
(
'
checkDoctypeEntries method
'
,
()
=>
{
it
(
'
shoud return a boolean if doctype are correct
'
,
async
()
=>
{
it
(
'
shou
l
d return a boolean if doctype are correct
'
,
async
()
=>
{
let
fluidType
=
2
mockGetEntries
.
mockResolvedValueOnce
({
data
:
[
1
]
})
let
result
=
await
consumptionDataManager
.
checkDoctypeEntries
(
...
...
src/services/consumptionFormatter.service.spec.ts
View file @
6d41cb24
...
...
@@ -59,7 +59,7 @@ const unknowTimeStep = 999
describe
(
'
ConsumptionFormatter service
'
,
()
=>
{
const
consumptionFormatterService
=
new
ConsumptionFormatterService
()
describe
(
'
formatGraphData method
'
,
()
=>
{
it
(
'
shoud return a formattedData for DAY
'
,
()
=>
{
it
(
'
shou
l
d return a formattedData for DAY
'
,
()
=>
{
const
mockResult
=
[
{
date
:
DateTime
.
fromISO
(
'
2020-10-01T00:00:00.000Z
'
,
{
...
...
@@ -90,7 +90,7 @@ describe('ConsumptionFormatter service', () => {
)
expect
(
result
).
toEqual
(
mockResult
)
})
it
(
'
shoud return a formattedData for HALF_AN_HOUR
'
,
()
=>
{
it
(
'
shou
l
d return a formattedData for HALF_AN_HOUR
'
,
()
=>
{
mockTimePeriod
=
{
startDate
:
DateTime
.
fromISO
(
'
2020-10-01T00:00:00.000Z
'
,
{
zone
:
'
utc
'
,
...
...
@@ -130,7 +130,7 @@ describe('ConsumptionFormatter service', () => {
)
expect
(
result
).
toEqual
(
mockResult
)
})
it
(
'
shoud return a formattedData for MONTH
'
,
()
=>
{
it
(
'
shou
l
d return a formattedData for MONTH
'
,
()
=>
{
mockTimePeriod
=
{
startDate
:
DateTime
.
fromISO
(
'
2020-10-01T00:00:00.000Z
'
,
{
zone
:
'
utc
'
,
...
...
@@ -170,7 +170,7 @@ describe('ConsumptionFormatter service', () => {
)
expect
(
result
).
toEqual
(
mockResult
)
})
it
(
'
shoud return a formattedData for YEAR
'
,
()
=>
{
it
(
'
shou
l
d return a formattedData for YEAR
'
,
()
=>
{
mockTimePeriod
=
{
startDate
:
DateTime
.
fromISO
(
'
2018-10-01T00:00:00.000Z
'
,
{
zone
:
'
utc
'
,
...
...
@@ -210,7 +210,7 @@ describe('ConsumptionFormatter service', () => {
)
expect
(
result
).
toEqual
(
mockResult
)
})
it
(
'
shoud return an error because of unknown TimeStep
'
,
()
=>
{
it
(
'
shou
l
d return an error because of unknown TimeStep
'
,
()
=>
{
try
{
consumptionFormatterService
.
formatGraphData
(
mockDataLoad
,
...
...
src/services/consumptionValidator.service.spec.ts
View file @
6d41cb24
...
...
@@ -16,7 +16,7 @@ let fluidTypes: FluidType[] = [0, 1, 2]
describe
(
'
ConsumptionFormatter service
'
,
()
=>
{
const
consumptionValidatorService
=
new
ConsumptionValidatorService
()
describe
(
'
formatGraphData method
'
,
()
=>
{
it
(
'
shoud return true for DAY
'
,
()
=>
{
it
(
'
shou
l
d return true for DAY
'
,
()
=>
{
const
result
=
consumptionValidatorService
.
ValidateGetGraphData
(
mockTimePeriod
,
TimeStep
.
DAY
,
...
...
@@ -24,7 +24,7 @@ describe('ConsumptionFormatter service', () => {
)
expect
(
result
).
toBeTruthy
()
})
it
(
'
shoud return true with comparison Date
'
,
()
=>
{
it
(
'
shou
l
d return true with comparison Date
'
,
()
=>
{
const
result
=
consumptionValidatorService
.
ValidateGetGraphData
(
mockTimePeriod
,
TimeStep
.
DAY
,
...
...
@@ -33,7 +33,7 @@ describe('ConsumptionFormatter service', () => {
)
expect
(
result
).
toBeTruthy
()
})
it
(
'
shoud return false with comparison Date
'
,
()
=>
{
it
(
'
shou
l
d return false with comparison Date
'
,
()
=>
{
const
wrongTimePeriodComparison
:
TimePeriod
=
{
startDate
:
DateTime
.
fromISO
(
'
2020-09-05T00:00:00.000Z
'
,
{
zone
:
'
utc
'
,
...
...
@@ -48,7 +48,7 @@ describe('ConsumptionFormatter service', () => {
)
expect
(
result
).
toBeFalsy
()
})
it
(
'
shoud return false with comparison Date
'
,
()
=>
{
it
(
'
shou
l
d return false with comparison Date
'
,
()
=>
{
const
wrongTimePeriodComparison
:
TimePeriod
=
{
startDate
:
DateTime
.
fromISO
(
'
2020-09-05T00:00:00.000Z
'
,
{
zone
:
'
utc
'
,
...
...
@@ -63,7 +63,7 @@ describe('ConsumptionFormatter service', () => {
)
expect
(
result
).
toBeFalsy
()
})
it
(
'
shoud return false because of fluid
'
,
()
=>
{
it
(
'
shou
l
d return false because of fluid
'
,
()
=>
{
const
wrongFluidType
:
FluidType
[]
=
[]
const
result
=
consumptionValidatorService
.
ValidateGetGraphData
(
mockTimePeriod
,
...
...
@@ -72,7 +72,7 @@ describe('ConsumptionFormatter service', () => {
)
expect
(
result
).
toBeFalsy
()
})
it
(
'
shoud return false because of wrong TimePeriod
'
,
()
=>
{
it
(
'
shou
l
d return false because of wrong TimePeriod
'
,
()
=>
{
const
wrongTimePeriod
:
TimePeriod
=
{
startDate
:
DateTime
.
fromISO
(
'
2020-10-05T00:00:00.000Z
'
,
{
zone
:
'
utc
'
,
...
...
@@ -86,7 +86,7 @@ describe('ConsumptionFormatter service', () => {
)
expect
(
result
).
toBeFalsy
()
})
it
(
'
shoud return false because of HALF_AN_HOUR and ELECTRICITY
'
,
()
=>
{
it
(
'
shou
l
d return false because of HALF_AN_HOUR and ELECTRICITY
'
,
()
=>
{
const
result
=
consumptionValidatorService
.
ValidateGetGraphData
(
mockTimePeriod
,
TimeStep
.
HALF_AN_HOUR
,
...
...
@@ -94,7 +94,7 @@ describe('ConsumptionFormatter service', () => {
)
expect
(
result
).
toBeFalsy
()
})
it
(
'
shoud return false because of HALF_AN_HOUR and ValidateTimePeriodLength
'
,
()
=>
{
it
(
'
shou
l
d return false because of HALF_AN_HOUR and ValidateTimePeriodLength
'
,
()
=>
{
fluidTypes
=
[
0
]
//Only fluid without TimeStep incompatibilty
const
mockTimePeriodTooLong
:
TimePeriod
=
{
startDate
:
DateTime
.
fromISO
(
'
2020-10-01T00:00:00.000Z
'
,
{
...
...
@@ -109,7 +109,7 @@ describe('ConsumptionFormatter service', () => {
)
expect
(
result
).
toBeFalsy
()
})
it
(
'
shoud return false because of WEEK and ValidateTimePeriodLength
'
,
()
=>
{
it
(
'
shou
l
d return false because of WEEK and ValidateTimePeriodLength
'
,
()
=>
{
const
mockTimePeriodTooLong
:
TimePeriod
=
{
startDate
:
DateTime
.
fromISO
(
'
2020-10-01T00:00:00.000Z
'
,
{
zone
:
'
utc
'
,
...
...
@@ -123,7 +123,7 @@ describe('ConsumptionFormatter service', () => {
)
expect
(
result
).
toBeFalsy
()
})
it
(
'
shoud return false because of DAY and ValidateTimePeriodLength
'
,
()
=>
{
it
(
'
shou
l
d return false because of DAY and ValidateTimePeriodLength
'
,
()
=>
{
const
mockTimePeriodTooLong
:
TimePeriod
=
{
startDate
:
DateTime
.
fromISO
(
'
2020-10-01T00:00:00.000Z
'
,
{
zone
:
'
utc
'
,
...
...
@@ -137,7 +137,7 @@ describe('ConsumptionFormatter service', () => {
)
expect
(
result
).
toBeFalsy
()
})
it
(
'
shoud return false because of MONTH and ValidateTimePeriodLength
'
,
()
=>
{
it
(
'
shou
l
d return false because of MONTH and ValidateTimePeriodLength
'
,
()
=>
{
const
mockTimePeriodTooLong
:
TimePeriod
=
{
startDate
:
DateTime
.
fromISO
(
'
2018-10-01T00:00:00.000Z
'
,
{
zone
:
'
utc
'
,
...
...
@@ -151,7 +151,7 @@ describe('ConsumptionFormatter service', () => {
)
expect
(
result
).
toBeFalsy
()
})
it
(
'
shoud return false because of YEAR and ValidateTimePeriodLength
'
,
()
=>
{
it
(
'
shou
l
d return false because of YEAR and ValidateTimePeriodLength
'
,
()
=>
{
const
mockTimePeriodTooLong
:
TimePeriod
=
{
startDate
:
DateTime
.
fromISO
(
'
2009-10-01T00:00:00.000Z
'
,
{
zone
:
'
utc
'
,
...
...
src/services/converter.service.spec.ts
View file @
6d41cb24
...
...
@@ -8,32 +8,32 @@ describe('Converter service', () => {
describe
(
'
LoadToEuro method
'
,
()
=>
{
const
fluidConfig
=
configService
.
getFluidConfig
()
it
(
'
shoud return the load to euro for Electricity
'
,
()
=>
{
it
(
'
shou
l
d return the load to euro for Electricity
'
,
()
=>
{
const
expectedConversion
=
20
*
fluidConfig
[
FluidType
.
ELECTRICITY
].
coefficient
const
result
=
converterService
.
LoadToEuro
(
20
,
FluidType
.
ELECTRICITY
)
expect
(
result
).
toEqual
(
expectedConversion
)
})
it
(
'
shoud return the load to euro for Gas
'
,
()
=>
{
it
(
'
shou
l
d return the load to euro for Gas
'
,
()
=>
{
const
expectedConversion
=
20
*
fluidConfig
[
FluidType
.
GAS
].
coefficient
const
result
=
converterService
.
LoadToEuro
(
20
,
FluidType
.
GAS
)
expect
(
result
).
toEqual
(
expectedConversion
)
})
it
(
'
shoud return the load to euro for Water
'
,
()
=>
{
it
(
'
shou
l
d return the load to euro for Water
'
,
()
=>
{
const
expectedConversion
=
20
*
fluidConfig
[
FluidType
.
WATER
].
coefficient
const
result
=
converterService
.
LoadToEuro
(
20
,
FluidType
.
WATER
)
expect
(
result
).
toEqual
(
expectedConversion
)
})
it
(
'
shoud return the load to euro for Multifluid, no coeff apply
'
,
()
=>
{
it
(
'
shou
l
d return the load to euro for Multifluid, no coeff apply
'
,
()
=>
{
const
expectedConversion
=
20
const
result
=
converterService
.
LoadToEuro
(
20
,
FluidType
.
MULTIFLUID
)
expect
(
result
).
toEqual
(
expectedConversion
)
})
it
(
'
shoud return 0.01 if the load is below 0.01 euro
'
,
()
=>
{
it
(
'
shou
l
d return 0.01 if the load is below 0.01 euro
'
,
()
=>
{
const
expectedConversion
=
0.01
const
result
=
converterService
.
LoadToEuro
(
0.002
,
FluidType
.
WATER
)
expect
(
result
).
toEqual
(
expectedConversion
)
...
...
src/services/ecogesture.service.spec.ts
View file @
6d41cb24
...
...
@@ -20,7 +20,7 @@ describe('Ecogesture service', () => {
const
ecogestureService
=
new
EcogestureService
(
mockClient
)
describe
(
'
getAllEcogestures
'
,
()
=>
{
it
(
'
shoud return all ecogestures
'
,
async
()
=>
{
it
(
'
shou
l
d return all ecogestures
'
,
async
()
=>
{
const
mockQueryResult
:
QueryResult
<
Ecogesture
[]
>
=
{
data
:
ecogesturesData
,
bookmark
:
''
,
...
...
@@ -31,7 +31,7 @@ describe('Ecogesture service', () => {
const
result
=
await
ecogestureService
.
getAllEcogestures
()
expect
(
result
).
toEqual
(
ecogesturesData
)
})
it
(
'
shoud return empty array when no ecogestures stored
'
,
async
()
=>
{
it
(
'
shou
l
d return empty array when no ecogestures stored
'
,
async
()
=>
{
const
mockQueryResult
:
QueryResult
<
Ecogesture
[]
>
=
{
data
:
[],
bookmark
:
''
,
...
...
@@ -45,7 +45,7 @@ describe('Ecogesture service', () => {
})
describe
(
'
deleteAllEcogestures
'
,
()
=>
{
it
(
'
shoud return true when 3 ecogestures stored
'
,
async
()
=>
{
it
(
'
shou
l
d return true when 3 ecogestures stored
'
,
async
()
=>
{
const
mockQueryResult
:
QueryResult
<
Ecogesture
[]
>
=
{
data
:
ecogesturesData
,
bookmark
:
''
,
...
...
@@ -57,7 +57,7 @@ describe('Ecogesture service', () => {
expect
(
mockClient
.
destroy
).
toBeCalledTimes
(
3
)
expect
(
result
).
toBe
(
true
)
})
it
(
'
shoud return true when no ecogestures stored
'
,
async
()
=>
{
it
(
'
shou
l
d return true when no ecogestures stored
'
,
async
()
=>
{
const
mockQueryResult
:
QueryResult
<
Ecogesture
[]
>
=
{
data
:
[],
bookmark
:
''
,
...
...
@@ -68,7 +68,7 @@ describe('Ecogesture service', () => {
const
result
=
await
ecogestureService
.
deleteAllEcogestures
()
expect
(
result
).
toBe
(
true
)
})
it
(
'
shoud return false when error happened on deletion
'
,
async
()
=>
{
it
(
'
shou
l
d return false when error happened on deletion
'
,
async
()
=>
{
const
mockQueryResult
:
QueryResult
<
Ecogesture
[]
>
=
{
data
:
ecogesturesData
,
bookmark
:
''
,
...
...
@@ -84,7 +84,7 @@ describe('Ecogesture service', () => {
describe
(
'
filteredEcogestureList
'
,
()
=>
{
describe
(
'
usage heating
'
,
()
=>
{
it
(
'
shoud return ecogesture with electricity
'
,
async
()
=>
{
it
(
'
shou
l
d return ecogesture with electricity
'
,
async
()
=>
{
const
mockEcogestureList
:
Ecogesture
[]
=
ecogesturesHeatingData
const
mockProfileType
:
ProfileType
=
{
...
profileData
.
profileType
,
...
...
@@ -97,7 +97,7 @@ describe('Ecogesture service', () => {
)
expect
(
result
).
toEqual
([
mockEcogestureList
[
0
],
mockEcogestureList
[
2
]])
})
it
(
'
shoud return ecogesture with gas
'
,
async
()
=>
{
it
(
'
shou
l
d return ecogesture with gas
'
,
async
()
=>
{
const
mockEcogestureList
:
Ecogesture
[]
=
ecogesturesHeatingData
const
mockProfileType
:
ProfileType
=
{
...
profileData
.
profileType
,
...
...
@@ -110,7 +110,7 @@ describe('Ecogesture service', () => {
)
expect
(
result
).
toEqual
([
mockEcogestureList
[
1
],
mockEcogestureList
[
2
]])
})
it
(
'
shoud not return ecogesture when profile heating is collective
'
,
async
()
=>
{
it
(
'
shou
l
d not return ecogesture when profile heating is collective
'
,
async
()
=>
{
const
mockEcogestureList
:
Ecogesture
[]
=
ecogesturesHeatingData
const
mockProfileType
:
ProfileType
=
{
...
profileData
.
profileType
,
...
...
@@ -126,7 +126,7 @@ describe('Ecogesture service', () => {
})
describe
(
'
usage ECS
'
,
()
=>
{
it
(
'
shoud return ecogesture with electricity
'
,
async
()
=>
{
it
(
'
shou
l
d return ecogesture with electricity
'
,
async
()
=>
{
const
mockEcogestureList
:
Ecogesture
[]
=
ecogesturesECSData
const
mockProfileType
:
ProfileType
=
{
...
profileData
.
profileType
,
...
...
@@ -139,7 +139,7 @@ describe('Ecogesture service', () => {
)
expect
(
result
).
toEqual
([
mockEcogestureList
[
0
],
mockEcogestureList
[
2
]])
})
it
(
'
shoud return ecogesture with gas
'
,
async
()
=>
{
it
(
'
shou
l
d return ecogesture with gas
'
,
async
()
=>
{
const
mockEcogestureList
:
Ecogesture
[]
=
ecogesturesECSData
const
mockProfileType
:
ProfileType
=
{
...
profileData
.
profileType
,
...
...
@@ -152,7 +152,7 @@ describe('Ecogesture service', () => {
)
expect
(
result
).
toEqual
([
mockEcogestureList
[
1
],
mockEcogestureList
[
2
]])
})
it
(
'
shoud not return ecogesture when profile warming is collective
'
,
async
()
=>
{
it
(
'
shou
l
d not return ecogesture when profile warming is collective
'
,
async
()
=>
{
const
mockEcogestureList
:
Ecogesture
[]
=
ecogesturesECSData
const
mockProfileType
:
ProfileType
=
{
...
profileData
.
profileType
,
...
...
@@ -168,7 +168,7 @@ describe('Ecogesture service', () => {
})
describe
(
'
usage COOKING
'
,
()
=>
{
it
(
'
shoud return ecogesture with electricity
'
,
async
()
=>
{
it
(
'
shou
l
d return ecogesture with electricity
'
,
async
()
=>
{
const
mockEcogestureList
:
Ecogesture
[]
=
ecogesturesCookingData
const
mockProfileType
:
ProfileType
=
{
...
profileData
.
profileType
,
...
...
@@ -180,7 +180,7 @@ describe('Ecogesture service', () => {
)
expect
(
result
).
toEqual
([
mockEcogestureList
[
0
],
mockEcogestureList
[
2
]])
})
it
(
'
shoud return ecogesture with gas
'
,
async
()
=>
{
it
(
'
shou
l
d return ecogesture with gas
'
,
async
()
=>
{
const
mockEcogestureList
:
Ecogesture
[]
=
ecogesturesCookingData
const
mockProfileType
:
ProfileType
=
{
...
profileData
.
profileType
,
...
...
@@ -195,7 +195,7 @@ describe('Ecogesture service', () => {
})
describe
(
'
usage COLD_WATER
'
,
()
=>
{
it
(
'
shoud return all water ecogestures
'
,
async
()
=>
{
it
(
'
shou
l
d return all water ecogestures
'
,
async
()
=>
{
const
mockEcogestureList
:
Ecogesture
[]
=
ecogesturesColdWaterData
const
mockProfileType
:
ProfileType
=
{
...
profileData
.
profileType
,
...
...
@@ -207,7 +207,7 @@ describe('Ecogesture service', () => {
)
expect
(
result
).
toEqual
(
mockEcogestureList
)
})
it
(
'
shoud not return water ecogestures
'
,
async
()
=>
{
it
(
'
shou
l
d not return water ecogestures
'
,
async
()
=>
{
const
mockEcogestureList
:
Ecogesture
[]
=
ecogesturesColdWaterData
const
mockProfileType
:
ProfileType
=
{
...
profileData
.
profileType
,
...
...
@@ -222,7 +222,7 @@ describe('Ecogesture service', () => {
})
describe
(
'
usage ELECTRICITY_SPECIFIC
'
,
()
=>
{
it
(
'
shoud return all ecogestures
'
,
async
()
=>
{
it
(
'
shou
l
d return all ecogestures
'
,
async
()
=>
{
const
mockEcogestureList
:
Ecogesture
[]
=
ecogesturesElecSpecificData
const
mockProfileType
:
ProfileType
=
{
...
profileData
.
profileType
,
...
...
@@ -236,7 +236,7 @@ describe('Ecogesture service', () => {
})
describe
(
'
usage AIR_CONDITIONING
'
,
()
=>
{
it
(
'
shoud not return ecogestures
'
,
async
()
=>
{
it
(
'
shou
l
d not return ecogestures
'
,
async
()
=>
{
const
mockEcogestureList
:
Ecogesture
[]
=
ecogesturesAirConditioningData
const
mockProfileType
:
ProfileType
=
{
...
profileData
.
profileType
,
...
...
src/services/fluid.service.spec.ts
View file @
6d41cb24
...
...
@@ -57,7 +57,7 @@ describe('FLuid service', () => {
})
describe
(
'
getFluidStatus method
'
,
()
=>
{
it
(
'
shoud return fluid status for all fluids
'
,
async
()
=>
{
it
(
'
shou
l
d return fluid status for all fluids
'
,
async
()
=>
{
const
mockLastDataDates
:
(
DateTime
|
null
)[]
=
[
DateTime
.
local
().
setZone
(
'
utc
'
,
{
keepLocalTime
:
true
,
...
...
@@ -150,7 +150,7 @@ describe('FLuid service', () => {
expect
(
result
).
toEqual
(
mockResult
)
})
it
(
'
shoud return fluid status with NOT_CONNECTED status when no accounts
'
,
async
()
=>
{
it
(
'
shou
l
d return fluid status with NOT_CONNECTED status when no accounts
'
,
async
()
=>
{
const
mockLastDataDates
:
(
DateTime
|
null
)[]
=
[
DateTime
.
local
().
setZone
(
'
utc
'
,
{
keepLocalTime
:
true
,
...
...
@@ -243,7 +243,7 @@ describe('FLuid service', () => {
expect
(
result
).
toEqual
(
mockResult
)
})
it
(
'
shoud return fluid status with KONNECTOR_NOT_FOUND status when no konnector
'
,
async
()
=>
{
it
(
'
shou
l
d return fluid status with KONNECTOR_NOT_FOUND status when no konnector
'
,
async
()
=>
{
const
mockLastDataDates
:
(
DateTime
|
null
)[]
=
[
DateTime
.
local
().
setZone
(
'
utc
'
,
{
keepLocalTime
:
true
,
...
...
@@ -336,7 +336,7 @@ describe('FLuid service', () => {
expect
(
result
).
toEqual
(
mockResult
)
})
it
(
'
shoud return fluid status with NOT_CONNECTED status when no triggers
'
,
async
()
=>
{
it
(
'
shou
l
d return fluid status with NOT_CONNECTED status when no triggers
'
,
async
()
=>
{
const
mockLastDataDates
:
(
DateTime
|
null
)[]
=
[
DateTime
.
local
().
setZone
(
'
utc
'
,
{
keepLocalTime
:
true
,
...
...
@@ -429,7 +429,7 @@ describe('FLuid service', () => {
expect
(
result
).
toEqual
(
mockResult
)
})
it
(
'
shoud return fluid status with null laste date for water and gaz
'
,
async
()
=>
{
it
(
'
shou
l
d return fluid status with null laste date for water and gaz
'
,
async
()
=>
{
const
mockLastDataDates
:
(
DateTime
|
null
)[]
=
[
DateTime
.
local
(),
null
,
...
...
@@ -521,7 +521,7 @@ describe('FLuid service', () => {
})
describe
(
'
getOldFluidData method
'
,
()
=>
{
it
(
'
shoud return Electricity as old fluid
'
,
async
()
=>
{
it
(
'
shou
l
d return Electricity as old fluid
'
,
async
()
=>
{
const
mockFluidStatus
:
FluidStatus
[]
=
[
{
fluidType
:
FluidType
.
ELECTRICITY
,
...
...
@@ -552,7 +552,7 @@ describe('FLuid service', () => {
expect
(
result
).
toEqual
([
FluidType
.
ELECTRICITY
])
})
it
(
'
shoud return empty array as lastdatadate < 5 days
'
,
async
()
=>
{
it
(
'
shou
l
d return empty array as lastdatadate < 5 days
'
,
async
()
=>
{
const
mockFluidStatus
:
FluidStatus
[]
=
[
{
fluidType
:
FluidType
.
ELECTRICITY
,
...
...
@@ -585,7 +585,7 @@ describe('FLuid service', () => {
expect
(
result
).
toEqual
([])
})
it
(
'
shoud return empty array as status is NOT_CONNECTED
'
,
async
()
=>
{
it
(
'
shou
l
d return empty array as status is NOT_CONNECTED
'
,
async
()
=>
{
const
mockFluidStatus
:
FluidStatus
[]
=
[
{
fluidType
:
FluidType
.
ELECTRICITY
,
...
...
@@ -616,7 +616,7 @@ describe('FLuid service', () => {
expect
(
result
).
toEqual
([])
})
it
(
'
shoud return empty array as status is KONNECTOR_NOT_FOUND
'
,
async
()
=>
{
it
(
'
shou
l
d return empty array as status is KONNECTOR_NOT_FOUND
'
,
async
()
=>
{
const
mockFluidStatus
:
FluidStatus
[]
=
[
{
fluidType
:
FluidType
.
ELECTRICITY
,
...
...
@@ -647,7 +647,7 @@ describe('FLuid service', () => {
expect
(
result
).
toEqual
([])