diff --git a/test/createConnections.js b/scripts/createConnections.js similarity index 100% rename from test/createConnections.js rename to scripts/createConnections.js diff --git a/test/createDayDataFiles.js b/scripts/createDayDataFiles.js similarity index 100% rename from test/createDayDataFiles.js rename to scripts/createDayDataFiles.js diff --git a/test/data/dayData-elec.json b/scripts/data/dayData-elec.json similarity index 100% rename from test/data/dayData-elec.json rename to scripts/data/dayData-elec.json diff --git a/test/data/dayData-gas.json b/scripts/data/dayData-gas.json similarity index 100% rename from test/data/dayData-gas.json rename to scripts/data/dayData-gas.json diff --git a/test/data/dayData-water.json b/scripts/data/dayData-water.json similarity index 100% rename from test/data/dayData-water.json rename to scripts/data/dayData-water.json diff --git a/test/data/dayData.json b/scripts/data/dayData.json similarity index 100% rename from test/data/dayData.json rename to scripts/data/dayData.json diff --git a/test/importAccount.bat b/scripts/importAccount.bat similarity index 100% rename from test/importAccount.bat rename to scripts/importAccount.bat diff --git a/test/importData.bat b/scripts/importData.bat similarity index 100% rename from test/importData.bat rename to scripts/importData.bat diff --git a/src/components/Hooks/userInstanceSettings.tsx b/src/components/Hooks/userInstanceSettings.tsx index 91d22c9801cd5079e38b0e7d46dc7e6877ffaaf4..d4e6ae53399e71625b02f7a46443c46e4c4d7d5f 100644 --- a/src/components/Hooks/userInstanceSettings.tsx +++ b/src/components/Hooks/userInstanceSettings.tsx @@ -1,11 +1,15 @@ import { useState, useEffect } from 'react' import get from 'lodash/get' import { useClient } from 'cozy-client' +import { UserInstanceSettings, UserInstanceSettingsAttributes } from 'models' -const userInstanceSettings = () => { +const userInstanceSettings = (): UserInstanceSettings => { const client = useClient() - const [settings, setSettings] = useState({}) - const [fetchStatus, setFetchStatus] = useState('idle') + const [settings, setSettings] = useState<UserInstanceSettingsAttributes>({ + // eslint-disable-next-line @typescript-eslint/camelcase + public_name: '', + }) + const [fetchStatus, setFetchStatus] = useState<string>('idle') useEffect(() => { const fetchData = async () => { diff --git a/src/components/LegalNotice/LegalNoticeLink.spec.tsx b/src/components/LegalNotice/LegalNoticeLink.spec.tsx index 1e5c27d0cc5ec956b77a45e9d2d4fd73eb44b62f..7f01b8a67828fe2743da996a1990e573db32dd30 100644 --- a/src/components/LegalNotice/LegalNoticeLink.spec.tsx +++ b/src/components/LegalNotice/LegalNoticeLink.spec.tsx @@ -1,5 +1,3 @@ -'use strict' -/* eslint-env jest */ import React from 'react' import { shallow } from 'enzyme' import LegalNoticeLink from 'components/LegalNotice/LegalNoticeLink' diff --git a/src/components/LegalNotice/LegalNoticeView.spec.tsx b/src/components/LegalNotice/LegalNoticeView.spec.tsx index 3f8f4366d26392dad5ecb12d2645e523f5857520..d63efac8a14437c8c49ad0e10b4cd91f33940459 100644 --- a/src/components/LegalNotice/LegalNoticeView.spec.tsx +++ b/src/components/LegalNotice/LegalNoticeView.spec.tsx @@ -1,5 +1,3 @@ -'use strict' -/* eslint-env jest */ import React from 'react' import { shallow } from 'enzyme' import LegalNoticeView from 'components/LegalNotice/LegalNoticeView' diff --git a/src/components/Navbar/Navbar.spec.tsx b/src/components/Navbar/Navbar.spec.tsx index d4ce8fa2884d1c86b643a57522ddf8e408db8833..c8e5c85682f2b8da0b508de0eb222f9245a9ac91 100644 --- a/src/components/Navbar/Navbar.spec.tsx +++ b/src/components/Navbar/Navbar.spec.tsx @@ -1,5 +1,3 @@ -'use strict' -/* eslint-env jest */ import React from 'react' import { shallow } from 'enzyme' import Navbar from 'components/Navbar/Navbar' @@ -16,7 +14,6 @@ jest.mock('cozy-ui/transpiled/react/I18n', () => { } }) -jest.mock('recoil') const { useRecoilValue } = (Recoil as unknown) as typeof MockRecoil describe('Navbar component', () => { diff --git a/src/components/Options/OptionsView.spec.tsx b/src/components/Options/OptionsView.spec.tsx new file mode 100644 index 0000000000000000000000000000000000000000..a1fc5688d7e559de5cd87cf117d7ac545217cb88 --- /dev/null +++ b/src/components/Options/OptionsView.spec.tsx @@ -0,0 +1,15 @@ +import React from 'react' +import { shallow } from 'enzyme' +import OptionsView from 'components/Options/OptionsView' + +jest.mock( + 'components/Konnector/KonnectorViewerList', + () => 'KonnectorViewerList' +) + +describe('OptionsView component', () => { + it('should be rendered correctly', () => { + const component = shallow(<OptionsView />).getElement() + expect(component).toMatchSnapshot() + }) +}) diff --git a/src/components/Options/ReportOptions.spec.tsx b/src/components/Options/ReportOptions.spec.tsx new file mode 100644 index 0000000000000000000000000000000000000000..97a15f1e6372d91562e649c53dc043d43ad5514f --- /dev/null +++ b/src/components/Options/ReportOptions.spec.tsx @@ -0,0 +1,36 @@ +import React from 'react' +import { shallow } from 'enzyme' +import ReportOptions from 'components/Options/ReportOptions' +import * as MockRecoil from '../../../test/__mocks__/recoil' +import * as Recoil from 'recoil' +import { userProfileData } from '../../../test/__mocks__/userProfile.mock' + +jest.mock('cozy-ui/transpiled/react/I18n', () => { + return { + useI18n: jest.fn(() => { + return { + t: (str: string) => str, + } + }), + } +}) + +const { useRecoilState } = (Recoil as unknown) as typeof MockRecoil + +describe('ReportOptions component', () => { + it('should be rendered correctly', () => { + useRecoilState.mockReturnValue([userProfileData, () => null]) + const wrapper = shallow(<ReportOptions />).getElement() + expect(wrapper).toMatchSnapshot() + }) + + it('should ...', () => { + // TODO Complete test with havebenncall on updateUserProfileReport + useRecoilState.mockReturnValue([userProfileData, () => null]) + const wrapper = shallow(<ReportOptions />) + // const instance = wrapper.instance() + // jest.spyOn(instance, 'updateUserProfileReport') + wrapper.find('#monthly').simulate('click') + // expect(component).toMatchSnapshot() + }) +}) diff --git a/src/components/Options/__snapshots__/OptionsView.spec.tsx.snap b/src/components/Options/__snapshots__/OptionsView.spec.tsx.snap new file mode 100644 index 0000000000000000000000000000000000000000..bfb3103e215ecca9228008b0dea7adf7b25dca57 --- /dev/null +++ b/src/components/Options/__snapshots__/OptionsView.spec.tsx.snap @@ -0,0 +1,37 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`OptionsView component should be rendered correctly 1`] = ` +<React.Fragment> + <CozyBar + titleKey="COMMON.APP_OPTIONS_TITLE" + /> + <Header + desktopTitleKey="COMMON.APP_OPTIONS_TITLE" + setHeaderHeight={[Function]} + /> + <Content + height={0} + > + <KonnectorViewerList + isParam={true} + /> + <ReportOptions /> + <FAQLink /> + <LegalNoticeLink /> + <div + className="parameters-logos" + > + <StyledIcon + className="logo-grand-lyon-parameters" + icon="test-file-stub" + size={100} + /> + <img + className="logo-tiga-parameters" + src="test-file-stub" + /> + </div> + <Version /> + </Content> +</React.Fragment> +`; diff --git a/src/components/Options/__snapshots__/ReportOptions.spec.tsx.snap b/src/components/Options/__snapshots__/ReportOptions.spec.tsx.snap new file mode 100644 index 0000000000000000000000000000000000000000..380c5debc7f4fb5c0806f0e1ec79d27db83ca3c3 --- /dev/null +++ b/src/components/Options/__snapshots__/ReportOptions.spec.tsx.snap @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ReportOptions component should be rendered correctly 1`] = ` +<div + className="report-option-root" +> + <div + className="report-option-content" + > + <div + className="head text-14-normal-uppercase" + > + PROFILE.REPORT.TITLE + </div> + <form + action="" + className="radios" + > + <div + className="input" + > + <input + checked={false} + id="monthly" + name="report" + onChange={[Function]} + type="radio" + value="true" + /> + <label + htmlFor="monthly" + > + + PROFILE.REPORT.MONTHLY + </label> + </div> + <div + className="input" + > + <input + checked={true} + id="never" + name="report" + onChange={[Function]} + type="radio" + value="false" + /> + <label + htmlFor="never" + > + + PROFILE.REPORT.NEVER + </label> + </div> + </form> + </div> +</div> +`; diff --git a/src/components/Version/Version.spec.tsx b/src/components/Version/Version.spec.tsx index be325f3b0248bab39c8b6d0b5b1fd8052ab1a03d..4ee6c5a0ece7327a2389fb34e43671577464ba52 100644 --- a/src/components/Version/Version.spec.tsx +++ b/src/components/Version/Version.spec.tsx @@ -1,22 +1,7 @@ -'use strict' -/* eslint-env jest */ import React from 'react' import { shallow } from 'enzyme' -// import { RecoilRoot } from 'recoil' import Version from 'components/Version/Version' -jest.mock('cozy-client', () => { - return { - useClient: jest.fn(() => { - return { - appMetadata: { - version: '0.0.0', - }, - } - }), - } -}) - describe('Version component', () => { it('should be rendered correctly', () => { const component = shallow(<Version />).getElement() diff --git a/src/components/Version/__snapshots__/Version.spec.tsx.snap b/src/components/Version/__snapshots__/Version.spec.tsx.snap index c087d2c916dac1d088be590dfba0dbe339ae114a..05ce42fbf8a684a3bd93073e63915d9c9211dbd9 100644 --- a/src/components/Version/__snapshots__/Version.spec.tsx.snap +++ b/src/components/Version/__snapshots__/Version.spec.tsx.snap @@ -1,13 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Navbar component should be rendered correctly 1`] = ` -<div - className="version-root text-14-normal" -> - v 0.0.° -</div> -`; - exports[`Version component should be rendered correctly 1`] = ` <div className="version-root text-14-normal" diff --git a/src/components/Welcome/WelcomeModal.spec.tsx b/src/components/Welcome/WelcomeModal.spec.tsx new file mode 100644 index 0000000000000000000000000000000000000000..130805ed9e26cd64d7ef238d2e89615e176cb6e2 --- /dev/null +++ b/src/components/Welcome/WelcomeModal.spec.tsx @@ -0,0 +1,39 @@ +import React from 'react' +import { shallow } from 'enzyme' +import WelcomeModal from './WelcomeModal' + +jest.mock('cozy-ui/transpiled/react/I18n', () => { + return { + useI18n: jest.fn(() => { + return { + t: (str: string) => str, + } + }), + } +}) + +jest.mock('components/Hooks/userInstanceSettings', () => + jest.fn().mockReturnValue({ + // eslint-disable-next-line @typescript-eslint/camelcase + data: { public_name: 'User' }, + fetchStatus: 'loaded', + }) +) + +describe('WelcomeModal component', () => { + it('should be rendered correctly opened', () => { + const handleClose = jest.fn() + const component = shallow( + <WelcomeModal open={true} handleCloseClick={handleClose} /> + ).getElement() + expect(component).toMatchSnapshot() + }) + + it('should be rendered correctly closed', () => { + const handleClose = jest.fn() + const component = shallow( + <WelcomeModal open={false} handleCloseClick={handleClose} /> + ).getElement() + expect(component).toMatchSnapshot() + }) +}) diff --git a/src/components/Welcome/WelcomeModal.tsx b/src/components/Welcome/WelcomeModal.tsx index 73cfcaf84a86c7002d942d13c7bf6ab0610dc196..afffbfc47370609a6cd24b175fe471dd91f6a670 100644 --- a/src/components/Welcome/WelcomeModal.tsx +++ b/src/components/Welcome/WelcomeModal.tsx @@ -4,15 +4,15 @@ import Modal from 'components/CommonKit/Modal/Modal' import StyledButton from 'components/CommonKit/Button/StyledButton' import userInstanceSettings from 'components/Hooks/userInstanceSettings' -interface WelcomeModalContainerProps { +interface WelcomeModalProps { open: boolean handleCloseClick: () => void } -const WelcomeModalContainer: React.FC<WelcomeModalContainerProps> = ({ +const WelcomeModal: React.FC<WelcomeModalProps> = ({ open, handleCloseClick, -}: WelcomeModalContainerProps) => { +}: WelcomeModalProps) => { const { t } = useI18n() const { data: instanceSettings } = userInstanceSettings() @@ -27,9 +27,7 @@ const WelcomeModalContainer: React.FC<WelcomeModalContainerProps> = ({ {t('COMMON.WELCOME_MODAL_TITLE')} </div> <div className="wm-name text-24-bold"> - {instanceSettings.public_name - ? `${instanceSettings.public_name} !` - : null} + {`${instanceSettings.public_name} !`} </div> <div className="wm-perso text-18-bold"> @@ -46,4 +44,4 @@ const WelcomeModalContainer: React.FC<WelcomeModalContainerProps> = ({ ) } -export default WelcomeModalContainer +export default WelcomeModal diff --git a/src/components/Welcome/__snapshots__/WelcomeModal.spec.tsx.snap b/src/components/Welcome/__snapshots__/WelcomeModal.spec.tsx.snap new file mode 100644 index 0000000000000000000000000000000000000000..a05fcc036f3816ba440edddccb94800690de681d --- /dev/null +++ b/src/components/Welcome/__snapshots__/WelcomeModal.spec.tsx.snap @@ -0,0 +1,77 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`WelcomeModal component should be rendered correctly closed 1`] = ` +<React.Fragment> + <Modal + handleCloseClick={[MockFunction]} + open={false} + yellowBorder={true} + > + <div + className="wm-header text-24-bold" + > + COMMON.WELCOME_MODAL_TITLE + </div> + <div + className="wm-name text-24-bold" + > + User ! + </div> + <div + className="wm-perso text-18-bold" + > + COMMON.WELCOME_MODAL_PERSO + </div> + <div + className="wm-connect text-18-bold" + > + COMMON.WELCOME_MODAL_CONNECT + </div> + <StyledButton + className="button-ok" + color="primary" + onClick={[MockFunction]} + > + COMMON.MODAL_OK + </StyledButton> + </Modal> +</React.Fragment> +`; + +exports[`WelcomeModal component should be rendered correctly opened 1`] = ` +<React.Fragment> + <Modal + handleCloseClick={[MockFunction]} + open={true} + yellowBorder={true} + > + <div + className="wm-header text-24-bold" + > + COMMON.WELCOME_MODAL_TITLE + </div> + <div + className="wm-name text-24-bold" + > + User ! + </div> + <div + className="wm-perso text-18-bold" + > + COMMON.WELCOME_MODAL_PERSO + </div> + <div + className="wm-connect text-18-bold" + > + COMMON.WELCOME_MODAL_CONNECT + </div> + <StyledButton + className="button-ok" + color="primary" + onClick={[MockFunction]} + > + COMMON.MODAL_OK + </StyledButton> + </Modal> +</React.Fragment> +`; diff --git a/src/models/account.model.ts b/src/models/account.model.ts index e6f87335cd458822a6aac2606f2797b2cfc3240c..0e6ede6d7865eb4c45c99eca0d0e4dd1a64966bf 100644 --- a/src/models/account.model.ts +++ b/src/models/account.model.ts @@ -3,6 +3,7 @@ export interface Account extends AccountAttributes { id?: string _rev?: string _type?: string + // eslint-disable-next-line @typescript-eslint/no-explicit-any cozyMetadata?: Record<string, any> } @@ -12,6 +13,9 @@ export interface AccountAttributes { oauth?: AccountOAuthData identifier?: string state?: string | null + name?: string + // eslint-disable-next-line @typescript-eslint/no-explicit-any + oauth_callback_results?: Record<string, any> } export interface AccountAuthData { @@ -23,4 +27,6 @@ export interface AccountAuthData { export interface AccountOAuthData { access_token: string refresh_token: string + expires_at?: string + token_type?: string } diff --git a/src/models/index.ts b/src/models/index.ts index a3b55612c5d1a66d798cf120c9c677e87481439e..5cd40965db4009822d828c0e2e4c5159c1658f7a 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -11,4 +11,5 @@ export * from './modal.model' export * from './report.model' export * from './timePeriod.model' export * from './trigger.model' +export * from './userInstanceSettings.model' export * from './userProfile.model' diff --git a/src/models/trigger.model.ts b/src/models/trigger.model.ts index 75dbf3c9a92f5916aeed2b2a4e7b050db198f6d9..a8066eb4d9b971cb526c72eca3fa75b4a6beb064 100644 --- a/src/models/trigger.model.ts +++ b/src/models/trigger.model.ts @@ -1,5 +1,11 @@ export interface Trigger extends TriggerAttributes { _id: string + domain?: string + prefix?: string + debounce?: string + options?: string | null + // eslint-disable-next-line @typescript-eslint/no-explicit-any + cozyMetadata?: Record<string, any> } export interface TriggerAttributes { diff --git a/src/models/userInstanceSettings.model.ts b/src/models/userInstanceSettings.model.ts new file mode 100644 index 0000000000000000000000000000000000000000..d1e2936a942ee9e57a37a016ea0868168fc96ae8 --- /dev/null +++ b/src/models/userInstanceSettings.model.ts @@ -0,0 +1,18 @@ +export interface UserInstanceSettingsAttributes { + auth_mode?: string + auto_update?: boolean + context?: string + email?: string + locale?: string + oidc_id?: string + onboarding_finished?: boolean + public_name: string + tos?: string + tos_latest?: string + uuid?: string +} + +export interface UserInstanceSettings { + data: UserInstanceSettingsAttributes + fetchStatus: string +} diff --git a/src/services/__mocks__/accountsData.json b/src/services/__mocks__/accountsData.json deleted file mode 100644 index 30bc62929829c2e728719778f867c6b11965dc40..0000000000000000000000000000000000000000 --- a/src/services/__mocks__/accountsData.json +++ /dev/null @@ -1,67 +0,0 @@ -[ - { - "_id": "88e68b8450cee09fe2f077610901094d", - "_rev": "1-88e68b8450cee09fe2f077610901094d", - "account_type": "enedisgrandlyon", - "name": "", - "oauth": { - "access_token": "MY_ACCESS_TOCKEN", - "expires_at": "2020-10-09T08:00:00.285910671+02:00", - "refresh_token": "", - "token_type": "Bearer" - }, - "oauth_callback_results": { - "issued_at": "1592232569642", - "refresh_token_issued_at": "1592232569642", - "scope": "/my_eneids_scope", - "usage_points_id": "" - }, - "cozyMetadata": { - "createdAt": "2020-11-10T16:42:11.132Z", - "metadataVersion": 1, - "updatedAt": "2020-11-10T16:42:11.132Z" - } - }, - { - "_id": "90e68b8450cee09fe2f077610901094d", - "id": "90e68b8450cee09fe2f077610901094d", - "account_type": "eglgrandlyon", - "auth": { - "credentials_encrypted": "bmFjbHI5OoL+VNCT6JDFYea1dNiBGGNJM1zY0M4uWcjhALJcQT9uk9p9WPD7+1OryCAoYf9eaSE=", - "login": "test" - }, - "identifier": "login", - "state": null, - "_rev": "1-90e68b8450cee09fe2f077610901094d", - "_type": "io.cozy.accounts", - "cozyMetadata": { - "createdAt": "2020-11-10T16:42:11.132Z", - "createdByApp": "ecolyo", - "createdByAppVersion": "0.2.1", - "metadataVersion": 1, - "updatedAt": "2020-11-10T16:42:11.132Z" - } - }, - { - "_id": "89e68b8450cee09fe2f077610901094d", - "_rev": "1-89e68b8450cee09fe2f077610901094d", - "account_type": "grdfgrandlyon", - "name": "", - "oauth": { - "access_token": "MY_ACCESS_TOCKEN", - "expires_at": "2020-10-09T08:00:00.285910671+02:00", - "refresh_token": "", - "token_type": "Bearer" - }, - "oauth_callback_results": { - "id_token": "MY_ID_TOCKEN", - "pce": "12345678987654", - "scope": "/my_grdf_scope" - }, - "cozyMetadata": { - "createdAt": "2020-11-10T16:42:11.132Z", - "metadataVersion": 1, - "updatedAt": "2020-11-10T16:42:11.132Z" - } - } -] diff --git a/src/services/__mocks__/challengesTypeData.json b/src/services/__mocks__/challengesTypeData.json deleted file mode 100644 index fa09ecdb08cdad58ebf186c52d096d9a0efd2ef0..0000000000000000000000000000000000000000 --- a/src/services/__mocks__/challengesTypeData.json +++ /dev/null @@ -1,314 +0,0 @@ -[ - { - "id": "CHA00000001", - "_id": "CHA00000001", - "_type": "com.grandlyon.ecolyo.challengetype", - "_rev": "1-ae99679ff8a70a4de91071c9310df415", - "cozyMetadata": { - "createdAt": "2020-11-03T08:56:10.479Z", - "createdByApp": "ecolyo", - "createdByAppVersion": "0.2.1", - "metadataVersion": 1, - "updatedAt": "2020-11-03T08:56:10.479Z", - "updatedByApps": [ - { - "date": "2020-11-03T08:56:10.479Z", - "slug": "ecolyo", - "version": "0.2.1" - } - ] - }, - "description": "Connecter l'application Ecolyo à un distributeur d'énergie", - "duration": { - "days": 0 - }, - "fluidTypes": [0, 1, 2], - "level": 1, - "relationships": { - "availableEcogestures": { - "data": [ - { - "_id": "0085", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0092", - "_type": "com.grandlyon.ecolyo.ecogesture" - } - ] - } - }, - "title": "Ecolyo Royal", - "type": 1 - }, - { - "id": "CHA00000002", - "_id": "CHA00000002", - "_type": "com.grandlyon.ecolyo.challengetype", - "_rev": "1-d38ff490140e8b18829d88791d987938", - "cozyMetadata": { - "createdAt": "2020-11-03T08:56:10.541Z", - "createdByApp": "ecolyo", - "createdByAppVersion": "0.2.1", - "metadataVersion": 1, - "updatedAt": "2020-11-03T08:56:10.541Z", - "updatedByApps": [ - { - "date": "2020-11-03T08:56:10.541Z", - "slug": "ecolyo", - "version": "0.2.1" - } - ] - }, - "description": "Et si dans les 7 prochains jours vous réussissiez à consommer moins que dans les 7 derniers ?", - "duration": { - "days": 7 - }, - "fluidTypes": [0, 1, 2], - "level": 2, - "relationships": { - "availableEcogestures": { - "data": [ - { - "_id": "0032", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0034", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0041", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0042", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0043", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0045", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0050", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0058", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0064", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0066", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0071", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0078", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0082", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0093", - "_type": "com.grandlyon.ecolyo.ecogesture" - } - ] - } - }, - "title": "Coques en stock", - "type": 0 - }, - { - "id": "CHA00000003", - "_id": "CHA00000003", - "_type": "com.grandlyon.ecolyo.challengetype", - "_rev": "1-6cef2075f6e074123c836c69653423d6", - "cozyMetadata": { - "createdAt": "2020-11-03T08:56:10.571Z", - "createdByApp": "ecolyo", - "createdByAppVersion": "0.2.1", - "metadataVersion": 1, - "updatedAt": "2020-11-03T08:56:10.571Z", - "updatedByApps": [ - { - "date": "2020-11-03T08:56:10.571Z", - "slug": "ecolyo", - "version": "0.2.1" - } - ] - }, - "description": "Et si dans les 4 prochaines semaines vous réussissiez à consommer moins que dans les 4 dernières ?", - "duration": { - "days": 28 - }, - "fluidTypes": [0, 1, 2], - "level": 3, - "relationships": { - "availableEcogestures": { - "data": [ - { - "_id": "0032", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0034", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0041", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0042", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0043", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0045", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0050", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0058", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0064", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0066", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0071", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0078", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0082", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0093", - "_type": "com.grandlyon.ecolyo.ecogesture" - } - ] - } - }, - "title": "Méga Coques en stock", - "type": 0 - }, - { - "id": "CHA00000004", - "_id": "CHA00000004", - "_type": "com.grandlyon.ecolyo.challengetype", - "_rev": "1-cabdfd17ee34fa66628055be718668e5", - "cozyMetadata": { - "createdAt": "2020-11-03T08:56:10.606Z", - "createdByApp": "ecolyo", - "createdByAppVersion": "0.2.1", - "metadataVersion": 1, - "updatedAt": "2020-11-03T08:56:10.606Z", - "updatedByApps": [ - { - "date": "2020-11-03T08:56:10.606Z", - "slug": "ecolyo", - "version": "0.2.1" - } - ] - }, - "description": "Et si dans les 7 prochains jours vous réussissiez à consommer moins que dans les 7 derniers", - "duration": { - "days": 7 - }, - "fluidTypes": [0, 1, 2], - "level": 901, - "relationships": { - "availableEcogestures": { - "data": [ - { - "_id": "0032", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0034", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0041", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0042", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0043", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0045", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0050", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0058", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0064", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0066", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0071", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0078", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0082", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "_id": "0093", - "_type": "com.grandlyon.ecolyo.ecogesture" - } - ] - } - }, - "title": "Winter is leaving", - "type": 0 - } -] diff --git a/src/services/__mocks__/ecogesturesData.json b/src/services/__mocks__/ecogesturesData.json deleted file mode 100644 index 7cd185f6b2466cc98f8b1d50d2a3fd435af0dff1..0000000000000000000000000000000000000000 --- a/src/services/__mocks__/ecogesturesData.json +++ /dev/null @@ -1,44 +0,0 @@ -[ - { - "fluidTypes": [0], - "id": "0032", - "longDescription": "Bien souvent les chauffe-eau sont réglés pour une température de 70 °C dans le ballon, ce qui n’est pas économique et peut même être dangereux ! Au-dessus de 60 °C vous augmentez aussi l’entartrage. L’eau ne doit pas être trop froide non plus pour éviter le risque de prolifération de micro-organismes comme les légionelles. A noter : parfois l’accès au réglage n’est pas directement visible… il faut alors retirer le capot en plastique situé sous le chauffe-eau pour y accéder.", - "longName": "Je règle la température de mon eau chaude entre 55 et 60 °C.", - "nwh": 6, - "pack": 8, - "shortDescription": "", - "shortName": "Contrôle du nuage", - "usage": "Eau chaude sanitaire", - "_id": "0032", - "_rev": "1-67f1ea36efdd892c96bf64a8943154cd", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "fluidTypes": [1], - "id": "0034", - "longDescription": "Si on n'a pas transpiré la journée et qu'on ne sent pas mauvais, aucune obligation de se laver tous les jours. Il est même conseillé pour la flore de l'épiderme (la fameuse barrière contre certains pathogènes) de ne pas se laver tous les jours. Vous économiserez ainsi une quantité d'eau non négligeable.", - "longName": "Je décide de supprimer une douche par semaine.", - "nwh": 5, - "pack": 6, - "shortDescription": "", - "shortName": "Vague de sécheresse", - "usage": "Eau chaude sanitaire", - "_id": "0034", - "_rev": "1-ef7ddd778254e3b7d331a88fd17f606d", - "_type": "com.grandlyon.ecolyo.ecogesture" - }, - { - "fluidTypes": [1], - "id": "0037", - "longDescription": "Le terme 'mousseur' désigne la pièce qui est située au bout de votre robinet qui permet de canaliser le jet d’eau. La plupart des robinets sont équipés de mousseurs, mais ceux-ci ne réduisent pas le débit. Il existe différents types 'd’éco-mousseurs' qui limitent le débit à des niveaux variables. Choisissez votre matériel en fonction des besoins à chaque robinet : 5 L/min sera adapté pour un robinet servant uniquement à se laver les mains mais sera assez pénible si vous devez remplir un seau !", - "longName": "J'équipe mes robinets d’éco-mousseurs.", - "nwh": 4, - "pack": 0, - "shortDescription": "", - "shortName": "Super plombier", - "usage": "Eau chaude sanitaire", - "_id": "0037", - "_rev": "1-0b2761dd4aef79556c7aef144060fde6", - "_type": "com.grandlyon.ecolyo.ecogesture" - } -] diff --git a/src/services/__mocks__/fluidStatusData.json b/src/services/__mocks__/fluidStatusData.json deleted file mode 100644 index 3ebade9fd7c44b74db2c03b6682b28f830164e52..0000000000000000000000000000000000000000 --- a/src/services/__mocks__/fluidStatusData.json +++ /dev/null @@ -1,17 +0,0 @@ -[ - { - "fluidType": 0, - "status": "errored", - "lastDataDate": "2020-09-01T00:00:00.000" - }, - { - "fluidType": 1, - "status": "errored", - "lastDataDate": "2020-11-01T00:00:00.000" - }, - { - "fluidType": 2, - "status": "errored", - "lastDataDate": "2020-09-01T00:00:00.000" - } -] diff --git a/src/services/__mocks__/graphData.json b/src/services/__mocks__/graphData.json deleted file mode 100644 index 07923d9ae3a448525f7d961c0359daa28ecedb5d..0000000000000000000000000000000000000000 --- a/src/services/__mocks__/graphData.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "actualData": [ - { - "date": "2020-10-01T00:00:00.000+02:00", - "value": 69.18029999999999, - "valueDetail": [ - 45.127739999999996, - 0.9048899999999999, - 23.147669999999998 - ] - }, - { - "date": "2020-10-02T00:00:00.000+02:00", - "value": 61.65554999999999, - "valueDetail": [40.21918999999999, 0.8064649999999999, 20.629894999999998] - }, - { - "date": "2020-10-03T00:00:00.000+02:00", - "value": -1, - "valueDetail": null - } - ], - "comparisonData": [ - { - "date": "2020-09-01T00:00:00.000+02:00", - "value": 54.090509999999995, - "valueDetail": [35.284358, 0.707513, 18.098639] - }, - { - "date": "2020-09-02T00:00:00.000+02:00", - "value": 56.57427, - "valueDetail": [36.904565999999996, 0.740001, 18.929703] - }, - { - "date": "2020-09-03T00:00:00.000+02:00", - "value": -1, - "valueDetail": null - } - ] -} diff --git a/src/services/__mocks__/konnectorsData.json b/src/services/__mocks__/konnectorsData.json deleted file mode 100644 index 5aed97e6047b6a4ed98630238a27b1483a2e224b..0000000000000000000000000000000000000000 --- a/src/services/__mocks__/konnectorsData.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - { - "_id": "io.cozy.konnectors/enedisgrandlyon", - "name": "Enedis", - "slug": "enedisgrandlyon", - "state": "ready" - }, - { - "_id": "io.cozy.konnectors/eglgrandlyon", - "name": "EGL", - "slug": "eglgrandlyon", - "state": "ready" - }, - { - "_id": "io.cozy.konnectors/grdfgrandlyon", - "name": "GRDF", - "slug": "grdfgrandlyon", - "state": "ready" - } -] \ No newline at end of file diff --git a/src/services/__mocks__/loadDayData.json b/src/services/__mocks__/loadDayData.json deleted file mode 100644 index fa0395bbc5433916ec65659446174f0e2baa5888..0000000000000000000000000000000000000000 --- a/src/services/__mocks__/loadDayData.json +++ /dev/null @@ -1,50 +0,0 @@ -[ - { - "id": "bf1ce3a5774e140056714c4c200c093e", - "_id": "bf1ce3a5774e140056714c4c200c093e", - "_type": "com.grandlyon.enedis.day", - "_rev": "1-4fe971dff073a3c3c6cc12a0246e642e", - "day": 1, - "hour": 0, - "load": 25.25, - "minute": 0, - "month": 11, - "year": 2020 - }, - { - "id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_type": "com.grandlyon.enedis.day", - "_rev": "1-4fe971dff073a3c3c6cc12a0246e642e", - "day": 2, - "hour": 0, - "load": 20.5, - "minute": 0, - "month": 11, - "year": 2020 - }, - { - "id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_type": "com.grandlyon.enedis.day", - "_rev": "1-4fe971dff073a3c3c6cc12a0246e642e", - "day": 3, - "hour": 0, - "load": 30.33, - "minute": 0, - "month": 11, - "year": 2020 - }, - { - "id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_type": "com.grandlyon.enedis.day", - "_rev": "1-4fe971dff073a3c3c6cc12a0246e642e", - "day": 4, - "hour": 0, - "load": 1.22, - "minute": 0, - "month": 11, - "year": 2020 - } -] diff --git a/src/services/__mocks__/loadHourData.json b/src/services/__mocks__/loadHourData.json deleted file mode 100644 index 2804f3618144f80ebb4f8b59341e52394de75b44..0000000000000000000000000000000000000000 --- a/src/services/__mocks__/loadHourData.json +++ /dev/null @@ -1,62 +0,0 @@ -[ - { - "id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_type": "com.grandlyon.enedis.hour", - "_rev": "1-4fe971dff073a3c3c6cc12a0246e642e", - "day": 2, - "hour": 0, - "load": 4.5, - "minute": 0, - "month": 11, - "year": 2020 - }, - { - "id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_type": "com.grandlyon.enedis.hour", - "_rev": "1-4fe971dff073a3c3c6cc12a0246e642e", - "day": 2, - "hour": 1, - "load": 1.33, - "minute": 0, - "month": 11, - "year": 2020 - }, - { - "id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_type": "com.grandlyon.enedis.hour", - "_rev": "1-4fe971dff073a3c3c6cc12a0246e642e", - "day": 2, - "hour": 2, - "load": 3.22, - "minute": 0, - "month": 11, - "year": 2020 - }, - { - "id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_type": "com.grandlyon.enedis.hour", - "_rev": "1-4fe971dff073a3c3c6cc12a0246e642e", - "day": 2, - "hour": 3, - "load": 7.82, - "minute": 0, - "month": 11, - "year": 2020 - }, - { - "id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_type": "com.grandlyon.enedis.hour", - "_rev": "1-4fe971dff073a3c3c6cc12a0246e642e", - "day": 2, - "hour": 4, - "load": 1.23, - "minute": 0, - "month": 11, - "year": 2020 - } -] diff --git a/src/services/__mocks__/loadMinuteData.json b/src/services/__mocks__/loadMinuteData.json deleted file mode 100644 index 65e093d9c7dd3905f72e49b35298e00e439a88db..0000000000000000000000000000000000000000 --- a/src/services/__mocks__/loadMinuteData.json +++ /dev/null @@ -1,74 +0,0 @@ -[ - { - "id": "bf1ce3a5774e140056714c4c200c093e", - "_id": "bf1ce3a5774e140056714c4c200c093e", - "_type": "com.grandlyon.enedis.minute", - "_rev": "1-4fe971dff073a3c3c6cc12a0246e642e", - "day": 1, - "hour": 23, - "load": 2.25, - "minute": 30, - "month": 11, - "year": 2020 - }, - { - "id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_type": "com.grandlyon.enedis.minute", - "_rev": "1-4fe971dff073a3c3c6cc12a0246e642e", - "day": 2, - "hour": 0, - "load": 4.5, - "minute": 0, - "month": 11, - "year": 2020 - }, - { - "id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_type": "com.grandlyon.enedis.minute", - "_rev": "1-4fe971dff073a3c3c6cc12a0246e642e", - "day": 2, - "hour": 0, - "load": 1.33, - "minute": 30, - "month": 11, - "year": 2020 - }, - { - "id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_type": "com.grandlyon.enedis.minute", - "_rev": "1-4fe971dff073a3c3c6cc12a0246e642e", - "day": 2, - "hour": 1, - "load": 3.22, - "minute": 0, - "month": 11, - "year": 2020 - }, - { - "id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_type": "com.grandlyon.enedis.minute", - "_rev": "1-4fe971dff073a3c3c6cc12a0246e642e", - "day": 2, - "hour": 1, - "load": 7.82, - "minute": 30, - "month": 11, - "year": 2020 - }, - { - "id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_type": "com.grandlyon.enedis.minute", - "_rev": "1-4fe971dff073a3c3c6cc12a0246e642e", - "day": 2, - "hour": 2, - "load": 1.23, - "minute": 0, - "month": 11, - "year": 2020 - } -] diff --git a/src/services/__mocks__/loadMonthData.json b/src/services/__mocks__/loadMonthData.json deleted file mode 100644 index fd9d2458d76eeee6d3cceeb2d7bb03e8f47975cc..0000000000000000000000000000000000000000 --- a/src/services/__mocks__/loadMonthData.json +++ /dev/null @@ -1,38 +0,0 @@ -[ - { - "id": "bf1ce3a5774e140056714c4c200c093e", - "_id": "bf1ce3a5774e140056714c4c200c093e", - "_type": "com.grandlyon.enedis.month", - "_rev": "1-4fe971dff073a3c3c6cc12a0246e642e", - "day": 1, - "hour": 0, - "load": 125.25, - "minute": 0, - "month": 9, - "year": 2020 - }, - { - "id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_type": "com.grandlyon.enedis.month", - "_rev": "1-4fe971dff073a3c3c6cc12a0246e642e", - "day": 1, - "hour": 0, - "load": 220.5, - "minute": 0, - "month": 10, - "year": 2020 - }, - { - "id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_type": "com.grandlyon.enedis.month", - "_rev": "1-4fe971dff073a3c3c6cc12a0246e642e", - "day": 1, - "hour": 0, - "load": 130.33, - "minute": 0, - "month": 11, - "year": 2020 - } -] diff --git a/src/services/__mocks__/loadYearData.json b/src/services/__mocks__/loadYearData.json deleted file mode 100644 index 86180661bc2f561cecf5616b144d7b1caf7826b3..0000000000000000000000000000000000000000 --- a/src/services/__mocks__/loadYearData.json +++ /dev/null @@ -1,38 +0,0 @@ -[ - { - "id": "bf1ce3a5774e140056714c4c200c093e", - "_id": "bf1ce3a5774e140056714c4c200c093e", - "_type": "com.grandlyon.enedis.year", - "_rev": "1-4fe971dff073a3c3c6cc12a0246e642e", - "day": 1, - "hour": 0, - "load": 125.25, - "minute": 0, - "month": 1, - "year": 2018 - }, - { - "id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_type": "com.grandlyon.enedis.year", - "_rev": "1-4fe971dff073a3c3c6cc12a0246e642e", - "day": 0, - "hour": 0, - "load": 220.5, - "minute": 0, - "month": 0, - "year": 2019 - }, - { - "id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_id": "cf7dc6f44a19b354f99b01ba1a0b4840", - "_type": "com.grandlyon.enedis.year", - "_rev": "1-4fe971dff073a3c3c6cc12a0246e642e", - "day": 1, - "hour": 0, - "load": 130.33, - "minute": 0, - "month": 1, - "year": 2020 - } -] diff --git a/src/services/__mocks__/triggerStateData.json b/src/services/__mocks__/triggerStateData.json deleted file mode 100644 index c0d19f45d3a1a6edaa92a3b4cbb0d85333e61c07..0000000000000000000000000000000000000000 --- a/src/services/__mocks__/triggerStateData.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "trigger_id": "238ba37b8bc8130bd323edb5c1005c8f", - "status": "errored", - "last_execution": "2020-11-13T10:03:16.4121536Z", - "last_executed_job_id": "238ba37b8bc8130bd323edb5c1006b56", - "last_failure": "2020-11-13T10:03:16.4121536Z", - "last_failed_job_id": "238ba37b8bc8130bd323edb5c1006b56", - "last_error": "fork/exec : no such file or directory", - "last_manual_execution": "2020-11-13T10:03:16.4121536Z", - "last_manual_job_id": "238ba37b8bc8130bd323edb5c1006b56" -} diff --git a/src/services/__mocks__/triggersData.json b/src/services/__mocks__/triggersData.json deleted file mode 100644 index 18a2b6f6d81fe1935fe1952a7b435138d0bced0e..0000000000000000000000000000000000000000 --- a/src/services/__mocks__/triggersData.json +++ /dev/null @@ -1,65 +0,0 @@ -[ - { - "_id": "3ed832cec67e6e0b2c6382edd30df11c", - "domain": "cozy.tools:8080", - "prefix": "cozy35ba44d2d1749e6f21646edce51e7190", - "type": "@cron", - "worker": "konnector", - "arguments": "0 47 8 * * *", - "debounce": "", - "options": null, - "message": { - "account": "88e68b8450cee09fe2f077610901094d", - "konnector": "enedisgrandlyon" - }, - "cozyMetadata": { - "doctypeVersion": "1", - "metadataVersion": 1, - "createdAt": "2020-10-09T08:00:00.6092798Z", - "createdByApp": "ecolyo", - "updatedAt": "2020-10-09T08:00:00.6092798Z" - } - }, - { - "_id": "5ed832cec67e6e0b2c6382edd30df11c", - "domain": "cozy.tools:8080", - "prefix": "cozy35ba44d2d1749e6f21646edce51e7190", - "type": "@cron", - "worker": "konnector", - "arguments": "0 47 8 * * *", - "debounce": "", - "options": null, - "message": { - "account": "90e68b8450cee09fe2f077610901094d", - "konnector": "eglgrandlyon" - }, - "cozyMetadata": { - "doctypeVersion": "1", - "metadataVersion": 1, - "createdAt": "2020-10-09T08:00:00.6092798Z", - "createdByApp": "ecolyo", - "updatedAt": "2020-10-09T08:00:00.6092798Z" - } - }, - { - "_id": "4ed832cec67e6e0b2c6382edd30df11c", - "domain": "cozy.tools:8080", - "prefix": "cozy35ba44d2d1749e6f21646edce51e7190", - "type": "@cron", - "worker": "konnector", - "arguments": "0 47 8 * * *", - "debounce": "", - "options": null, - "message": { - "account": "89e68b8450cee09fe2f077610901094d", - "konnector": "grdfgrandlyon" - }, - "cozyMetadata": { - "doctypeVersion": "1", - "metadataVersion": 1, - "createdAt": "2020-10-09T08:00:00.6092798Z", - "createdByApp": "ecolyo", - "updatedAt": "2020-10-09T08:00:00.6092798Z" - } - } -] \ No newline at end of file diff --git a/src/services/__mocks__/userChallengeData.json b/src/services/__mocks__/userChallengeData.json deleted file mode 100644 index 4ec0e4072ea9c0514845f2c9c6d2c75c14ebb55b..0000000000000000000000000000000000000000 --- a/src/services/__mocks__/userChallengeData.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "id": "4d9403218ef13e65b2e3a8ad1700c9f0", - "startingDate": "0001-01-01T00:00:00.000Z", - "endingDate": "2020-11-17T00:00:00.000+01:00", - "state": 0, - "selectedEcogestures": [ - { - "fluidTypes": [0], - "id": "0032", - "longDescription": "Bien souvent les chauffe-eau sont réglés pour une température de 70 °C dans le ballon, ce qui n’est pas économique et peut même être dangereux ! Au-dessus de 60 °C vous augmentez aussi l’entartrage. L’eau ne doit pas être trop froide non plus pour éviter le risque de prolifération de micro-organismes comme les légionelles. A noter : parfois l’accès au réglage n’est pas directement visible… il faut alors retirer le capot en plastique situé sous le chauffe-eau pour y accéder.", - "longName": "Je règle la température de mon eau chaude entre 55 et 60 °C.", - "nwh": 6, - "pack": 8, - "shortDescription": "", - "shortName": "Contrôle du nuage", - "usage": "Eau chaude sanitaire", - "_id": "0032", - "_rev": "1-67f1ea36efdd892c96bf64a8943154cd", - "_type": "com.grandlyon.ecolyo.ecogesture" - } - ], - "challengeType": { - "id": "CHA00000001", - "type": 1, - "title": "Ecolyo Royal", - "description": "Connecter l'application Ecolyo à un distributeur d'énergie", - "level": 1, - "duration": { - "days": 0 - }, - "fluidTypes": [0, 1, 2], - "availableEcogestures": [ - { - "fluidTypes": [0], - "id": "0032", - "longDescription": "Bien souvent les chauffe-eau sont réglés pour une température de 70 °C dans le ballon, ce qui n’est pas économique et peut même être dangereux ! Au-dessus de 60 °C vous augmentez aussi l’entartrage. L’eau ne doit pas être trop froide non plus pour éviter le risque de prolifération de micro-organismes comme les légionelles. A noter : parfois l’accès au réglage n’est pas directement visible… il faut alors retirer le capot en plastique situé sous le chauffe-eau pour y accéder.", - "longName": "Je règle la température de mon eau chaude entre 55 et 60 °C.", - "nwh": 6, - "pack": 8, - "shortDescription": "", - "shortName": "Contrôle du nuage", - "usage": "Eau chaude sanitaire", - "_id": "0032", - "_rev": "1-67f1ea36efdd892c96bf64a8943154cd", - "_type": "com.grandlyon.ecolyo.ecogesture" - } - ] - }, - "maxEnergy": -1, - "currentEnergy": -1, - "badge": 1, - "fluidTypes": [0, 1, 2] -} diff --git a/src/services/account.service.spec.ts b/src/services/account.service.spec.ts index e1430004c45d4e668d3d9d62809c3ffe475cd07b..80030f0dc8fb802bba78b08d8cb78bb95d64a292 100644 --- a/src/services/account.service.spec.ts +++ b/src/services/account.service.spec.ts @@ -1,9 +1,9 @@ import { QueryResult } from 'cozy-client' import { AccountAuthData, Account } from 'models' -import mockClient from './__mocks__/client' +import mockClient from '../../test/__mocks__/client' import AccountService from './account.service' -import accountData from './__mocks__/accountsData.json' -import konnectorData from './__mocks__/konnectorsData.json' +import { accountsData } from '../../test/__mocks__/accountsData.mock' +import { konnectorsData } from '../../test/__mocks__/konnectorsData.mock' jest.mock('cozy-harvest-lib/dist/connections/accounts') import * as harvestLibAccounts from 'cozy-harvest-lib/dist/connections/accounts' @@ -11,32 +11,30 @@ const mockHavestLibAccounts = harvestLibAccounts as jest.Mocked< typeof harvestLibAccounts > -const mockAccounts: Account[] = JSON.parse(JSON.stringify(accountData)) - describe('Account service', () => { const accountService = new AccountService(mockClient) describe('createAccount method', () => { it('should return created account for login type', async () => { - mockHavestLibAccounts.createAccount.mockResolvedValueOnce(mockAccounts[2]) + mockHavestLibAccounts.createAccount.mockResolvedValueOnce(accountsData[2]) const mockAuthData: AccountAuthData = { login: 'login', password: 'password', } const result = await accountService.createAccount( - konnectorData[2], + konnectorsData[2], mockAuthData ) - expect(result).toEqual(mockAccounts[2]) + expect(result).toEqual(accountsData[2]) }) }) describe('getAccount method', () => { it('should return account', async () => { - mockHavestLibAccounts.fetchAccount.mockResolvedValueOnce(mockAccounts[2]) + mockHavestLibAccounts.fetchAccount.mockResolvedValueOnce(accountsData[2]) const mockId = 'io.cozy.konnectors/eglgrandlyon' const result = await accountService.getAccount(mockId) - expect(result).toBe(mockAccounts[2]) + expect(result).toBe(accountsData[2]) }) it('should throw error when fetchAccount unsuccessfully', async () => { @@ -53,7 +51,7 @@ describe('Account service', () => { describe('getAccountByType method', () => { it('should return account with account_type equals to eglgrandlyon', async () => { const mockQueryResult: QueryResult<Account[]> = { - data: [mockAccounts[2]], + data: [accountsData[2]], bookmark: '', next: false, skip: 0, @@ -61,7 +59,7 @@ describe('Account service', () => { mockClient.query.mockResolvedValueOnce(mockQueryResult) const mockType = 'eglgrandlyon' const result = await accountService.getAccountByType(mockType) - expect(result).toEqual(mockAccounts[2]) + expect(result).toEqual(accountsData[2]) }) it('should return null when no account find', async () => { @@ -80,15 +78,15 @@ describe('Account service', () => { describe('updateAccount method', () => { it('should return updated account when updateAccount successfully', async () => { - mockHavestLibAccounts.updateAccount.mockResolvedValueOnce(mockAccounts[2]) - const result = await accountService.updateAccount(mockAccounts[2]) - expect(result).toEqual(mockAccounts[2]) + mockHavestLibAccounts.updateAccount.mockResolvedValueOnce(accountsData[2]) + const result = await accountService.updateAccount(accountsData[2]) + expect(result).toEqual(accountsData[2]) }) it('should throw error when updateAccount unsuccessfully', async () => { mockHavestLibAccounts.updateAccount.mockRejectedValueOnce(new Error()) try { - await accountService.updateAccount(mockAccounts[2]) + await accountService.updateAccount(accountsData[2]) } catch (error) { expect(error).toEqual(new Error('Update account failed')) } @@ -97,15 +95,15 @@ describe('Account service', () => { describe('deleteAccount method', () => { it('should return true when destroy successfully', async () => { - mockHavestLibAccounts.deleteAccount.mockResolvedValueOnce(mockAccounts[2]) - const result = await accountService.deleteAccount(mockAccounts[2]) + mockHavestLibAccounts.deleteAccount.mockResolvedValueOnce(accountsData[2]) + const result = await accountService.deleteAccount(accountsData[2]) expect(result).toBe(true) }) it('should throw error when destroy unsuccessfully', async () => { mockHavestLibAccounts.deleteAccount.mockRejectedValueOnce(new Error()) try { - await accountService.deleteAccount(mockAccounts[2]) + await accountService.deleteAccount(accountsData[2]) } catch (error) { expect(error).toEqual(new Error('Delete account failed')) } diff --git a/src/services/connection.service.spec.ts b/src/services/connection.service.spec.ts index 80abf8afd491c8e3e4330f528bc9e66957e617cd..657c4d15fa1a97563b6d84826735b1660490e424 100644 --- a/src/services/connection.service.spec.ts +++ b/src/services/connection.service.spec.ts @@ -1,8 +1,8 @@ import ConnectionService from './connection.service' -import mockClient from './__mocks__/client' -import konnectorsData from './__mocks__/konnectorsData.json' -import accountsData from './__mocks__/accountsData.json' -import triggerData from './__mocks__/triggersData.json' +import mockClient from '../../test/__mocks__/client' +import { konnectorsData } from '../../test/__mocks__/konnectorsData.mock' +import { accountsData } from '../../test/__mocks__/accountsData.mock' +import { triggersData } from '../../test/__mocks__/triggersData.mock' const mockGetKonnector = jest.fn() jest.mock('./konnector.service', () => { @@ -38,8 +38,8 @@ describe('Connection service', () => { it('shoud return created Trigger', async () => { mockGetKonnector.mockResolvedValueOnce(konnectorsData[0]) mockCreateAccount.mockResolvedValueOnce(accountsData[0]) - mockCreateTrigger.mockResolvedValueOnce(triggerData[0]) - const mockResult = { account: accountsData[0], trigger: triggerData[0] } + mockCreateTrigger.mockResolvedValueOnce(triggersData[0]) + const mockResult = { account: accountsData[0], trigger: triggersData[0] } const result = await connectionService.connectNewUser( konnectorsData[0]._id, 'login', diff --git a/src/services/consumption.service.spec.ts b/src/services/consumption.service.spec.ts index 271e2f4d04fcbfee7d8119b2f93012d83448714e..f1f36e4c07fe4ef609613331bc8b60a4c17ced68 100644 --- a/src/services/consumption.service.spec.ts +++ b/src/services/consumption.service.spec.ts @@ -1,5 +1,5 @@ import ConsumptionDataManager from './consumption.service' -import mockClient from './__mocks__/client' +import mockClient from '../../test/__mocks__/client' import { TimeStep } from 'enum/timeStep.enum' import { DateTime } from 'luxon' import { FluidType } from 'enum/fluid.enum' @@ -63,7 +63,6 @@ describe('Consuption service', () => { expect(result).toBeNull() }) it('shoud return a mapped data for one fluid', async () => { - console.log(fluidTypes) mockFetchFluidData.mockResolvedValueOnce(mockFetchDataActual) mockFetchFluidData.mockResolvedValueOnce(mockFetchDataComparison) const mockResult = { diff --git a/src/services/consumptionValidator.service.spec.ts b/src/services/consumptionValidator.service.spec.ts index 40b8216a1215d6298f73491c99c8af616a1fa836..063229635c80fd8adfb5b4dc5d299eb2db497aae 100644 --- a/src/services/consumptionValidator.service.spec.ts +++ b/src/services/consumptionValidator.service.spec.ts @@ -1,9 +1,8 @@ import ConsumptionValidatorService from './consumptionValidator.service' -import mockClient from './__mocks__/client' import { TimeStep } from 'enum/timeStep.enum' import { DateTime } from 'luxon' import { FluidType } from 'enum/fluid.enum' -import { Dataload, TimePeriod } from 'models' +import { TimePeriod } from 'models' const mockTimePeriod: TimePeriod = { startDate: DateTime.fromISO('2020-10-01T00:00:00.000'), diff --git a/src/services/ecogesture.service.spec.ts b/src/services/ecogesture.service.spec.ts index c50a2aafae5da1be11570f2af8a912aa9db5b15d..606feb388d0402d14083c292644e327a3938fa8d 100644 --- a/src/services/ecogesture.service.spec.ts +++ b/src/services/ecogesture.service.spec.ts @@ -1,8 +1,8 @@ import { QueryResult } from 'cozy-client' import { Ecogesture } from 'models' import EcogestureService from './ecogesture.service' -import mockClient from './__mocks__/client' -import ecogesturesData from './__mocks__/ecogesturesData.json' +import mockClient from '../../test/__mocks__/client' +import { ecogesturesData } from '../../test/__mocks__/ecogesturesData.mock' describe('Ecogesture service', () => { const ecogestureService = new EcogestureService(mockClient) diff --git a/src/services/fluid.service.spec.ts b/src/services/fluid.service.spec.ts index 1b856e7b956b684d57f9738d127975d432088afa..4f6e0423f60fb34d41385853e4fc368cd447fff7 100644 --- a/src/services/fluid.service.spec.ts +++ b/src/services/fluid.service.spec.ts @@ -1,9 +1,9 @@ import FluidService from './fluid.service' -import mockClient from './__mocks__/client' -import accountsData from './__mocks__/accountsData.json' -import konnectorsData from './__mocks__/konnectorsData.json' -import triggersData from './__mocks__/triggersData.json' -import triggerStateData from './__mocks__/triggerStateData.json' +import mockClient from '../../test/__mocks__/client' +import { accountsData } from '../../test/__mocks__/accountsData.mock' +import { konnectorsData } from '../../test/__mocks__/konnectorsData.mock' +import { triggersData } from '../../test/__mocks__/triggersData.mock' +import { triggerStateData } from '../../test/__mocks__/triggerStateData.mock' import { DateTime } from 'luxon' import { FluidType } from 'enum/fluid.enum' import { FluidStatus } from 'models' diff --git a/src/services/initialization.service.spec.ts b/src/services/initialization.service.spec.ts index 4dc7a5f94781113d04ad133c7e3ee3aca4f178ed..4fb015737a44a45de140cfcfd59816be246eeaa0 100644 --- a/src/services/initialization.service.spec.ts +++ b/src/services/initialization.service.spec.ts @@ -1,12 +1,13 @@ import { QueryResult } from 'cozy-client' -import { DateTime, Duration } from 'luxon' +import { DateTime } from 'luxon' import { FluidStatus, UserChallenge, UserProfile } from 'models' import InitializationService from './initialization.service' -import mockClient from './__mocks__/client' -import mockEcogesturesEntityData from './__mocks__/ecogesturesData.json' -import mockChallengesTypeEntityData from './__mocks__/challengesTypeData.json' -import mockUserChallengeEntityData from './__mocks__/userChallengeData.json' -import { userProfileEntityData } from './__mocks__/userProfile.mock' +import mockClient from '../../test/__mocks__/client' +import { ecogesturesData } from '../../test/__mocks__/ecogesturesData.mock' +import { challengesTypeData } from '../../test/__mocks__/challengesTypeData.mock' +import { userChallengeData } from '../../test/__mocks__/userChallengeData.mock' +import { userProfileData } from '../../test/__mocks__/userProfile.mock' +import { fluidStatusData } from '../../test/__mocks__/fluidStatusData.mock' import challengeTypeData from 'db/challengeTypeData.json' import ecogestureData from 'db/ecogestureData.json' @@ -93,18 +94,6 @@ jest.mock('./fluid.service', () => { }) }) -const mockUserChallengeData: UserChallenge = { - ...mockUserChallengeEntityData, - startingDate: DateTime.fromISO(mockUserChallengeEntityData.startingDate), - endingDate: DateTime.fromISO(mockUserChallengeEntityData.endingDate), - challengeType: { - ...mockUserChallengeEntityData.challengeType, - duration: Duration.fromObject( - mockUserChallengeEntityData.challengeType.duration - ), - }, -} - describe('Initialization service', () => { const initializationService = new InitializationService(mockClient) @@ -145,9 +134,9 @@ describe('Initialization service', () => { describe('initUserProfile method', () => { it('shoud return the userProfil when existing', async () => { - mockGetUserProfile.mockResolvedValue(userProfileEntityData) + mockGetUserProfile.mockResolvedValue(userProfileData) const result: UserProfile | null = await initializationService.initUserProfile() - expect(result).toEqual(userProfileEntityData) + expect(result).toEqual(userProfileData) }) it('shoud create and return the userProfil when no existing', async () => { @@ -159,10 +148,10 @@ describe('Initialization service', () => { } mockGetUserProfile .mockResolvedValueOnce(null) - .mockResolvedValueOnce(userProfileEntityData) + .mockResolvedValueOnce(userProfileData) mockClient.create.mockResolvedValue(mockQueryResult) const result: UserProfile | null = await initializationService.initUserProfile() - expect(result).toEqual(userProfileEntityData) + expect(result).toEqual(userProfileData) }) it('shoud throw error when the userProfile is not created', async () => { @@ -234,7 +223,7 @@ describe('Initialization service', () => { } mockClient.create.mockResolvedValue(mockQueryResult) const mockUserProfil = { - ...userProfileEntityData, + ...userProfileData, challengeTypeHash: hashFile(challengeTypeData), } mockUpdateUserProfile.mockResolvedValueOnce(mockUserProfil) @@ -250,7 +239,7 @@ describe('Initialization service', () => { it('shoud throw an error when challengeType should be created and created challenge number does not match', async () => { mockGetAllChallengeTypeEntities .mockResolvedValueOnce(null) - .mockResolvedValueOnce(mockChallengesTypeEntityData) + .mockResolvedValueOnce(challengesTypeData) const mockQueryResult: QueryResult<boolean> = { data: true, bookmark: '', @@ -320,7 +309,7 @@ describe('Initialization service', () => { } mockClient.create.mockResolvedValue(mockQueryResult) const mockUserProfil = { - ...userProfileEntityData, + ...userProfileData, challengeTypeHash: hashFile(challengeTypeData), } mockUpdateUserProfile.mockResolvedValueOnce(mockUserProfil) @@ -334,7 +323,7 @@ describe('Initialization service', () => { it('shoud throw an error when challengeType should be updated and created challenge number does not match', async () => { mockGetAllChallengeTypeEntities .mockResolvedValueOnce(challengeTypeData) - .mockResolvedValueOnce(mockChallengesTypeEntityData) + .mockResolvedValueOnce(challengesTypeData) mockDeleteChallengeTypeEntities.mockResolvedValue(true) const mockQueryResult: QueryResult<boolean> = { data: true, @@ -411,7 +400,7 @@ describe('Initialization service', () => { } mockClient.create.mockResolvedValue(mockQueryResult) const mockUserProfil = { - ...userProfileEntityData, + ...userProfileData, ecogestureHash: hashFile(ecogestureData), } mockUpdateUserProfile.mockResolvedValueOnce(mockUserProfil) @@ -425,7 +414,7 @@ describe('Initialization service', () => { it('shoud throw an error when ecogestures should be created and created ecogestures number does not match', async () => { mockGetAllEcogestures .mockResolvedValueOnce(null) - .mockResolvedValueOnce(mockEcogesturesEntityData) + .mockResolvedValueOnce(ecogesturesData) const mockQueryResult: QueryResult<boolean> = { data: true, bookmark: '', @@ -489,7 +478,7 @@ describe('Initialization service', () => { } mockClient.create.mockResolvedValue(mockQueryResult) const mockUserProfil = { - ...userProfileEntityData, + ...userProfileData, ecogestureHash: hashFile(ecogestureData), } mockUpdateUserProfile.mockResolvedValueOnce(mockUserProfil) @@ -503,7 +492,7 @@ describe('Initialization service', () => { it('shoud throw an error when ecogestures should be updated and created ecogestures number does not match', async () => { mockGetAllEcogestures .mockResolvedValueOnce(ecogestureData) - .mockResolvedValueOnce(mockEcogesturesEntityData) + .mockResolvedValueOnce(ecogesturesData) mockDeleteAllEcogestures.mockResolvedValue(true) const mockQueryResult: QueryResult<boolean> = { data: true, @@ -573,14 +562,14 @@ describe('Initialization service', () => { }) it('should return true and userProfile when no report', async () => { - mockUpdateUserProfile.mockResolvedValueOnce(userProfileEntityData) + mockUpdateUserProfile.mockResolvedValueOnce(userProfileData) const result: { result: boolean userProfile: UserProfile | null } = await initializationService.initReport(null) expect(result).toEqual({ result: true, - userProfile: userProfileEntityData, + userProfile: userProfileData, }) }) @@ -590,14 +579,14 @@ describe('Initialization service', () => { haveSeenLastReport: false, sendReportNotification: true, } - mockUpdateUserProfile.mockResolvedValueOnce(userProfileEntityData) + mockUpdateUserProfile.mockResolvedValueOnce(userProfileData) const result: { result: boolean userProfile: UserProfile | null } = await initializationService.initReport(mockUserReport) expect(result).toEqual({ result: true, - userProfile: userProfileEntityData, + userProfile: userProfileData, }) }) @@ -636,15 +625,15 @@ describe('Initialization service', () => { describe('initUserChallenge method', () => { it('shoud return userchallenges when userchallenges already existing', async () => { - mockGetAllUserChallenges.mockResolvedValueOnce(mockUserChallengeData) + mockGetAllUserChallenges.mockResolvedValueOnce(userChallengeData) const result: UserChallenge[] = await initializationService.initUserChallenge() - expect(result).toEqual(mockUserChallengeData) + expect(result).toEqual(userChallengeData) }) it('shoud return userchallenges when userchallenge should be created', async () => { mockGetAllUserChallenges .mockResolvedValueOnce([]) - .mockResolvedValueOnce(mockUserChallengeData) + .mockResolvedValueOnce(userChallengeData) const mockQueryResult: QueryResult<boolean> = { data: true, bookmark: '', @@ -653,7 +642,7 @@ describe('Initialization service', () => { } mockClient.create.mockResolvedValue(mockQueryResult) const result: UserChallenge[] = await initializationService.initUserChallenge() - expect(result).toEqual(mockUserChallengeData) + expect(result).toEqual(userChallengeData) }) it('shoud throw error when userchallenge should be created and userchallenge is not updated', async () => { @@ -731,26 +720,9 @@ describe('Initialization service', () => { describe('initFluidStatus method', () => { it('shoud return all fluids type', async () => { - const mockFluidStatusData: FluidStatus[] = [ - { - fluidType: 0, - status: 'errored', - lastDataDate: DateTime.fromISO('2020-09-01T00:00:00.000'), - }, - { - fluidType: 1, - status: 'errored', - lastDataDate: DateTime.fromISO('2020-09-01T00:00:00.000'), - }, - { - fluidType: 2, - status: 'errored', - lastDataDate: DateTime.fromISO('2020-09-01T00:00:00.000'), - }, - ] - mockGetFluidStatus.mockResolvedValueOnce(mockFluidStatusData) + mockGetFluidStatus.mockResolvedValueOnce(fluidStatusData) const result: FluidStatus[] = await initializationService.initFluidStatus() - expect(result).toEqual(mockFluidStatusData) + expect(result).toEqual(fluidStatusData) }) it('shoud throw an error when null is retrieved as status', async () => { @@ -778,9 +750,9 @@ describe('Initialization service', () => { describe('initCurrentChallenge method', () => { it('should return updated current Challenge', async () => { - mockGetCurrentChallenge.mockResolvedValueOnce(mockUserChallengeData) + mockGetCurrentChallenge.mockResolvedValueOnce(userChallengeData) const mockUpdatedUserChallenge = { - ...mockUserChallengeData, + ...userChallengeData, maxmaxEnergy: 100, } mockUpdateCurrentChallengeProgress.mockResolvedValueOnce( @@ -808,7 +780,7 @@ describe('Initialization service', () => { }) it('should throw error if current challenge failed to be updated', async () => { - mockGetCurrentChallenge.mockResolvedValueOnce(mockUserChallengeData) + mockGetCurrentChallenge.mockResolvedValueOnce(userChallengeData) mockUpdateCurrentChallengeProgress.mockRejectedValueOnce(new Error()) let error try { @@ -824,7 +796,7 @@ describe('Initialization service', () => { it('should return true if isCurrentChallengeOver return true', async () => { mockIsCurrentChallengeOver.mockResolvedValueOnce(true) const result: boolean = await initializationService.isCurrentChallengeOver( - mockUserChallengeData + userChallengeData ) expect(result).toBe(true) }) @@ -832,7 +804,7 @@ describe('Initialization service', () => { it('should return false if isCurrentChallengeOver return false', async () => { mockIsCurrentChallengeOver.mockResolvedValueOnce(false) const result: boolean = await initializationService.isCurrentChallengeOver( - mockUserChallengeData + userChallengeData ) expect(result).toBe(false) }) @@ -840,11 +812,11 @@ describe('Initialization service', () => { describe('checkAchievement method', () => { it('should return UserChallenge from the id', async () => { - mockCheckAchievement.mockResolvedValueOnce(mockUserChallengeData) + mockCheckAchievement.mockResolvedValueOnce(userChallengeData) const result: UserChallenge | null = await initializationService.checkAchievement( '4d9403218ef13e65b2e3a8ad1700c9f0' ) - expect(result).toEqual(mockUserChallengeData) + expect(result).toEqual(userChallengeData) }) }) }) diff --git a/src/services/konnector.service.spec.ts b/src/services/konnector.service.spec.ts index 9ef12d71d9aeb094da54439a5e583dc8f3e805df..4cead0793814810c2361092ec11349887b6cba67 100644 --- a/src/services/konnector.service.spec.ts +++ b/src/services/konnector.service.spec.ts @@ -1,10 +1,10 @@ import KonnectorService from './konnector.service' import { Konnector } from 'models' -import mockClient from './__mocks__/client' -import accountsData from './__mocks__/accountsData.json' -import konnectorsData from './__mocks__/konnectorsData.json' -import triggersData from './__mocks__/triggersData.json' -import triggerStateData from './__mocks__/triggerStateData.json' +import mockClient from '../../test/__mocks__/client' +import { accountsData } from '../../test/__mocks__/accountsData.mock' +import { konnectorsData } from '../../test/__mocks__/konnectorsData.mock' +import { triggersData } from '../../test/__mocks__/triggersData.mock' +import { triggerStateData } from '../../test/__mocks__/triggerStateData.mock' import { QueryResult } from 'cozy-client' const mockGetTrigger = jest.fn() diff --git a/src/services/konnectorStatus.service.spec.ts b/src/services/konnectorStatus.service.spec.ts index 212c173c9253669667a03b46bdffdc9e39b4a5cc..62b694902837c7429b879529c54628e068df658b 100644 --- a/src/services/konnectorStatus.service.spec.ts +++ b/src/services/konnectorStatus.service.spec.ts @@ -1,6 +1,6 @@ import KonnectorStatusService from './konnectorStatus.service' -import mockClient from './__mocks__/client' -import accountsData from './__mocks__/accountsData.json' +import mockClient from '../../test/__mocks__/client' +import { accountsData } from '../../test/__mocks__/accountsData.mock' const mockGetAccountByType = jest.fn() jest.mock('./account.service', () => { diff --git a/src/services/mail.service.spec.ts b/src/services/mail.service.spec.ts index 58532aa2cd1afaf09f5ba7cef5caf4d0bf592c2c..34150672274a13a74bb505ea3d2f4ead1652b79f 100644 --- a/src/services/mail.service.spec.ts +++ b/src/services/mail.service.spec.ts @@ -1,5 +1,5 @@ import MailService from './mail.service' -import mockClient from './__mocks__/client' +import mockClient from '../../test/__mocks__/client' describe('Mail service', () => { const mailService = new MailService() diff --git a/src/services/queryRunner.service.spec.ts b/src/services/queryRunner.service.spec.ts index 6228f83f6a950f40e5b6e34e556747ee5ad0e86f..cb1c2d72a513387fcdf07ad1e5452a1769316fe1 100644 --- a/src/services/queryRunner.service.spec.ts +++ b/src/services/queryRunner.service.spec.ts @@ -4,12 +4,12 @@ import { TimeStep } from 'enum/timeStep.enum' import { DateTime } from 'luxon' import { Dataload, DataloadEntity } from 'models' import QueryRunner from './queryRunner.service' -import mockClient from './__mocks__/client' -import loadYearData from './__mocks__/loadYearData.json' -import loadMonthData from './__mocks__/loadMonthData.json' -import loadDayData from './__mocks__/loadDayData.json' -import loadHourData from './__mocks__/loadHourData.json' -import loadMinuteData from './__mocks__/loadMinuteData.json' +import mockClient from '../../test/__mocks__/client' +import { loadYearData } from '../../test/__mocks__/loadYearData.mock' +import { loadMonthData } from '../../test/__mocks__/loadMonthData.mock' +import { loadDayData } from '../../test/__mocks__/loadDayData.mock' +import { loadHourData } from '../../test/__mocks__/loadHourData.mock' +import { loadMinuteData } from '../../test/__mocks__/loadMinuteData.mock' describe('queryRunner service', () => { const queryRunner = new QueryRunner(mockClient) diff --git a/src/services/triggers.service.spec.ts b/src/services/triggers.service.spec.ts index 3ebc651476acf0cbf82ae8379720ce7effe4f785..43ae414b73e9f47234ac81d8d23149fd7d6d058f 100644 --- a/src/services/triggers.service.spec.ts +++ b/src/services/triggers.service.spec.ts @@ -1,11 +1,11 @@ import { QueryResult } from 'cozy-client' import { Trigger, TriggerState } from 'models' -import mockClient from './__mocks__/client' +import mockClient from '../../test/__mocks__/client' import TriggerService from './triggers.service' -import accountsData from './__mocks__/accountsData.json' -import konnectorsData from './__mocks__/konnectorsData.json' -import triggersData from './__mocks__/triggersData.json' -import triggerStateData from './__mocks__/triggerStateData.json' +import { accountsData } from '../../test/__mocks__/accountsData.mock' +import { konnectorsData } from '../../test/__mocks__/konnectorsData.mock' +import { triggersData } from '../../test/__mocks__/triggersData.mock' +import { triggerStateData } from '../../test/__mocks__/triggerStateData.mock' const mockCreateTrigger = jest.fn() jest.mock('cozy-harvest-lib/dist/connections/triggers', () => { diff --git a/src/services/userProfile.service.spec.ts b/src/services/userProfile.service.spec.ts index 161e457b298f132c13e3eecdafe873a84d8591d2..1e944097d181c69fb50d7d3310055f56900346f3 100644 --- a/src/services/userProfile.service.spec.ts +++ b/src/services/userProfile.service.spec.ts @@ -1,7 +1,7 @@ import UserProfileService from './userProfile.service' import { Client, QueryResult } from 'cozy-client' import { UserProfile } from 'models' -import { userProfileEntityData } from './__mocks__/userProfile.mock' +import { userProfileData } from '../../test/__mocks__/userProfile.mock' import { DateTime } from 'luxon' const mockClient = ({ @@ -18,22 +18,22 @@ describe('UserProfile service', () => { describe('getUserProfile', () => { it('shoud return the user profile', async () => { const mockQueryResult: QueryResult<UserProfile[]> = { - data: [userProfileEntityData], + data: [userProfileData], bookmark: '', next: false, skip: 0, } mockClient.query.mockResolvedValueOnce(mockQueryResult) const result = await userProfileService.getUserProfile() - expect(result).toEqual(userProfileEntityData) + expect(result).toEqual(userProfileData) }) it('shoud return the user profile from string haveSeenOldFluidModal', async () => { const userProfile = { - ...userProfileEntityData, + ...userProfileData, haveSeenOldFluidModal: '2020-11-09T11:27:30.073+01:00', report: { - ...userProfileEntityData.report, + ...userProfileData.report, monthlyReportDate: '2020-11-03T00:00:00.000+01:00', }, } @@ -46,12 +46,12 @@ describe('UserProfile service', () => { } mockClient.query.mockResolvedValueOnce(mockQueryResult) const resultUserProfile = { - ...userProfileEntityData, + ...userProfileData, haveSeenOldFluidModal: DateTime.fromISO( '2020-11-09T11:27:30.073+01:00' ), report: { - ...userProfileEntityData.report, + ...userProfileData.report, monthlyReportDate: DateTime.fromISO('2020-11-03T00:00:00.000+01:00'), }, } @@ -75,10 +75,10 @@ describe('UserProfile service', () => { describe('updateUserProfile', () => { it('shoud return an updated user profile', async () => { const userProfile = { - ...userProfileEntityData, + ...userProfileData, haveSeenOldFluidModal: '2020-11-09T11:27:30.073+01:00', report: { - ...userProfileEntityData.report, + ...userProfileData.report, monthlyReportDate: '2020-11-03T00:00:00.000+01:00', }, } @@ -103,12 +103,12 @@ describe('UserProfile service', () => { } mockClient.save.mockResolvedValueOnce(mockUpdatedQueryResult) const resultUserProfile = { - ...userProfileEntityData, + ...userProfileData, haveSeenOldFluidModal: DateTime.fromISO( '2020-11-09T11:27:30.073+01:00' ), report: { - ...userProfileEntityData.report, + ...userProfileData.report, monthlyReportDate: DateTime.fromISO('2020-11-03T00:00:00.000+01:00'), }, haveSeenFavoriteModal: false, @@ -122,7 +122,7 @@ describe('UserProfile service', () => { it('shoud return null if no user profile found', async () => { const mockQueryResult: QueryResult<UserProfile[]> = { - data: [userProfileEntityData], + data: [userProfileData], bookmark: '', next: false, skip: 0, diff --git a/test/__mocks__/accountsData.mock.ts b/test/__mocks__/accountsData.mock.ts new file mode 100644 index 0000000000000000000000000000000000000000..a4f24d97273ad4d134736aecdb14aa8b7f8ac637 --- /dev/null +++ b/test/__mocks__/accountsData.mock.ts @@ -0,0 +1,71 @@ +/* eslint-disable @typescript-eslint/camelcase */ +import { Account } from 'models' + +export const accountsData: Account[] = [ + { + _id: '88e68b8450cee09fe2f077610901094d', + _rev: '1-88e68b8450cee09fe2f077610901094d', + account_type: 'enedisgrandlyon', + name: '', + oauth: { + access_token: 'MY_ACCESS_TOCKEN', + expires_at: '2020-10-09T08:00:00.285910671+02:00', + refresh_token: '', + token_type: 'Bearer', + }, + oauth_callback_results: { + issued_at: '1592232569642', + refresh_token_issued_at: '1592232569642', + scope: '/my_eneids_scope', + usage_points_id: '', + }, + cozyMetadata: { + createdAt: '2020-11-10T16:42:11.132Z', + metadataVersion: 1, + updatedAt: '2020-11-10T16:42:11.132Z', + }, + }, + { + _id: '90e68b8450cee09fe2f077610901094d', + id: '90e68b8450cee09fe2f077610901094d', + account_type: 'eglgrandlyon', + auth: { + credentials_encrypted: + 'bmFjbHI5OoL+VNCT6JDFYea1dNiBGGNJM1zY0M4uWcjhALJcQT9uk9p9WPD7+1OryCAoYf9eaSE=', + login: 'test', + }, + identifier: 'login', + state: null, + _rev: '1-90e68b8450cee09fe2f077610901094d', + _type: 'io.cozy.accounts', + cozyMetadata: { + createdAt: '2020-11-10T16:42:11.132Z', + createdByApp: 'ecolyo', + createdByAppVersion: '0.2.1', + metadataVersion: 1, + updatedAt: '2020-11-10T16:42:11.132Z', + }, + }, + { + _id: '89e68b8450cee09fe2f077610901094d', + _rev: '1-89e68b8450cee09fe2f077610901094d', + account_type: 'grdfgrandlyon', + name: '', + oauth: { + access_token: 'MY_ACCESS_TOCKEN', + expires_at: '2020-10-09T08:00:00.285910671+02:00', + refresh_token: '', + token_type: 'Bearer', + }, + oauth_callback_results: { + id_token: 'MY_ID_TOCKEN', + pce: '12345678987654', + scope: '/my_grdf_scope', + }, + cozyMetadata: { + createdAt: '2020-11-10T16:42:11.132Z', + metadataVersion: 1, + updatedAt: '2020-11-10T16:42:11.132Z', + }, + }, +] diff --git a/test/__mocks__/challengesTypeData.mock.ts b/test/__mocks__/challengesTypeData.mock.ts new file mode 100644 index 0000000000000000000000000000000000000000..b66d7217b14d635aa7e9daa451c2038a780f76fb --- /dev/null +++ b/test/__mocks__/challengesTypeData.mock.ts @@ -0,0 +1,319 @@ +import { ChallengeType } from 'models' + +export const challengesTypeData: ChallengeType[] = [ + { + id: 'CHA00000001', + _id: 'CHA00000001', + _type: 'com.grandlyon.ecolyo.challengetype', + _rev: '1-ae99679ff8a70a4de91071c9310df415', + cozyMetadata: { + createdAt: '2020-11-03T08:56:10.479Z', + createdByApp: 'ecolyo', + createdByAppVersion: '0.2.1', + metadataVersion: 1, + updatedAt: '2020-11-03T08:56:10.479Z', + updatedByApps: [ + { + date: '2020-11-03T08:56:10.479Z', + slug: 'ecolyo', + version: '0.2.1', + }, + ], + }, + description: "Connecter l'application Ecolyo à un distributeur d'énergie", + duration: { + days: 0, + }, + fluidTypes: [0, 1, 2], + level: 1, + relationships: { + availableEcogestures: { + data: [ + { + _id: '0085', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0092', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + ], + }, + }, + title: 'Ecolyo Royal', + type: 1, + }, + { + id: 'CHA00000002', + _id: 'CHA00000002', + _type: 'com.grandlyon.ecolyo.challengetype', + _rev: '1-d38ff490140e8b18829d88791d987938', + cozyMetadata: { + createdAt: '2020-11-03T08:56:10.541Z', + createdByApp: 'ecolyo', + createdByAppVersion: '0.2.1', + metadataVersion: 1, + updatedAt: '2020-11-03T08:56:10.541Z', + updatedByApps: [ + { + date: '2020-11-03T08:56:10.541Z', + slug: 'ecolyo', + version: '0.2.1', + }, + ], + }, + description: + 'Et si dans les 7 prochains jours vous réussissiez à consommer moins que dans les 7 derniers ?', + duration: { + days: 7, + }, + fluidTypes: [0, 1, 2], + level: 2, + relationships: { + availableEcogestures: { + data: [ + { + _id: '0032', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0034', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0041', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0042', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0043', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0045', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0050', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0058', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0064', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0066', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0071', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0078', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0082', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0093', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + ], + }, + }, + title: 'Coques en stock', + type: 0, + }, + { + id: 'CHA00000003', + _id: 'CHA00000003', + _type: 'com.grandlyon.ecolyo.challengetype', + _rev: '1-6cef2075f6e074123c836c69653423d6', + cozyMetadata: { + createdAt: '2020-11-03T08:56:10.571Z', + createdByApp: 'ecolyo', + createdByAppVersion: '0.2.1', + metadataVersion: 1, + updatedAt: '2020-11-03T08:56:10.571Z', + updatedByApps: [ + { + date: '2020-11-03T08:56:10.571Z', + slug: 'ecolyo', + version: '0.2.1', + }, + ], + }, + description: + 'Et si dans les 4 prochaines semaines vous réussissiez à consommer moins que dans les 4 dernières ?', + duration: { + days: 28, + }, + fluidTypes: [0, 1, 2], + level: 3, + relationships: { + availableEcogestures: { + data: [ + { + _id: '0032', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0034', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0041', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0042', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0043', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0045', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0050', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0058', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0064', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0066', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0071', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0078', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0082', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0093', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + ], + }, + }, + title: 'Méga Coques en stock', + type: 0, + }, + { + id: 'CHA00000004', + _id: 'CHA00000004', + _type: 'com.grandlyon.ecolyo.challengetype', + _rev: '1-cabdfd17ee34fa66628055be718668e5', + cozyMetadata: { + createdAt: '2020-11-03T08:56:10.606Z', + createdByApp: 'ecolyo', + createdByAppVersion: '0.2.1', + metadataVersion: 1, + updatedAt: '2020-11-03T08:56:10.606Z', + updatedByApps: [ + { + date: '2020-11-03T08:56:10.606Z', + slug: 'ecolyo', + version: '0.2.1', + }, + ], + }, + description: + 'Et si dans les 7 prochains jours vous réussissiez à consommer moins que dans les 7 derniers', + duration: { + days: 7, + }, + fluidTypes: [0, 1, 2], + level: 901, + relationships: { + availableEcogestures: { + data: [ + { + _id: '0032', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0034', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0041', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0042', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0043', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0045', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0050', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0058', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0064', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0066', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0071', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0078', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0082', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + _id: '0093', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + ], + }, + }, + title: 'Winter is leaving', + type: 0, + }, +] diff --git a/src/services/__mocks__/client.ts b/test/__mocks__/client.ts similarity index 100% rename from src/services/__mocks__/client.ts rename to test/__mocks__/client.ts diff --git a/test/__mocks__/consumptionDailyDataFormatterMock.json b/test/__mocks__/consumptionDailyDataFormatterMock.json deleted file mode 100644 index f1755a69326db74ac25617a891d36bbc7022a8fe..0000000000000000000000000000000000000000 --- a/test/__mocks__/consumptionDailyDataFormatterMock.json +++ /dev/null @@ -1,134 +0,0 @@ -[ - { - "date": "2018-07-01T00:00:00.000+02:00", - "value": 242.23 - }, - { - "date": "2018-07-02T00:00:00.000+02:00", - "value": 230.2 - }, - { - "date": "2018-07-03T00:00:00.000+02:00", - "value": 225.13 - }, - { - "date": "2018-07-04T00:00:00.000+02:00", - "value": 220.63 - }, - { - "date": "2018-07-05T00:00:00.000+02:00", - "value": 204.53 - }, - { - "date": "2018-07-06T00:00:00.000+02:00", - "value": 211.86 - }, - { - "date": "2018-07-07T00:00:00.000+02:00", - "value": 276.19 - }, - { - "date": "2018-07-08T00:00:00.000+02:00", - "value": 243.36 - }, - { - "date": "2018-07-09T00:00:00.000+02:00", - "value": 228.01 - }, - { - "date": "2018-07-10T00:00:00.000+02:00", - "value": 230.6 - }, - { - "date": "2018-07-11T00:00:00.000+02:00", - "value": 289.81 - }, - { - "date": "2018-07-12T00:00:00.000+02:00", - "value": 213.03 - }, - { - "date": "2018-07-13T00:00:00.000+02:00", - "value": 207.2 - }, - { - "date": "2018-07-14T00:00:00.000+02:00", - "value": 222.39 - }, - { - "date": "2018-07-15T00:00:00.000+02:00", - "value": 245.71 - }, - { - "date": "2018-07-16T00:00:00.000+02:00", - "value": 284.31 - }, - { - "date": "2018-07-17T00:00:00.000+02:00", - "value": 234.3 - }, - { - "date": "2018-07-18T00:00:00.000+02:00", - "value": 247.73 - }, - { - "date": "2018-07-19T00:00:00.000+02:00", - "value": 224.49 - }, - { - "date": "2018-07-20T00:00:00.000+02:00", - "value": 230.49 - }, - { - "date": "2018-07-21T00:00:00.000+02:00", - "value": 220.45 - }, - { - "date": "2018-07-22T00:00:00.000+02:00", - "value": 228.83 - }, - { - "date": "2018-07-23T00:00:00.000+02:00", - "value": 194.61 - }, - { - "date": "2018-07-24T00:00:00.000+02:00", - "value": 234 - }, - { - "date": "2018-07-25T00:00:00.000+02:00", - "value": 237.11 - }, - { - "date": "2018-07-26T00:00:00.000+02:00", - "value": 230.89 - }, - { - "date": "2018-07-27T00:00:00.000+02:00", - "value": 207.7 - }, - { - "date": "2018-07-28T00:00:00.000+02:00", - "value": 200.38 - }, - { - "date": "2018-07-29T00:00:00.000+02:00", - "value": 224.47 - }, - { - "date": "2018-07-30T00:00:00.000+02:00", - "value": 230.87 - }, - { - "date": "2018-07-31T00:00:00.000+02:00", - "value": 213.52 - }, - { - "date": "2018-08-01T00:00:00.000+02:00", - "value": 188.64 - }, - { - "date": "2018-08-02T00:00:00.000+02:00", - "value": 221.18 - } -] \ No newline at end of file diff --git a/test/__mocks__/consumptionHalfHourlyDataFormatterMock.json b/test/__mocks__/consumptionHalfHourlyDataFormatterMock.json deleted file mode 100644 index 55ae0be02a01292144d534f4e3a77c3236b52512..0000000000000000000000000000000000000000 --- a/test/__mocks__/consumptionHalfHourlyDataFormatterMock.json +++ /dev/null @@ -1,194 +0,0 @@ -[ - { - "date": "2018-06-20T00:00:00.000+02:00", - "value": 1.3 - }, - { - "date": "2018-06-20T00:30:00.000+02:00", - "value": 3.58 - }, - { - "date": "2018-06-20T01:00:00.000+02:00", - "value": 5.71 - }, - { - "date": "2018-06-20T01:30:00.000+02:00", - "value": 2.56 - }, - { - "date": "2018-06-20T02:00:00.000+02:00", - "value": 1.52 - }, - { - "date": "2018-06-20T02:30:00.000+02:00", - "value": 2.16 - }, - { - "date": "2018-06-20T03:00:00.000+02:00", - "value": 2.19 - }, - { - "date": "2018-06-20T03:30:00.000+02:00", - "value": 4.21 - }, - { - "date": "2018-06-20T04:00:00.000+02:00", - "value": 3.7 - }, - { - "date": "2018-06-20T04:30:00.000+02:00", - "value": 5.93 - }, - { - "date": "2018-06-20T05:00:00.000+02:00", - "value": 6.24 - }, - { - "date": "2018-06-20T05:30:00.000+02:00", - "value": 6.45 - }, - { - "date": "2018-06-20T06:00:00.000+02:00", - "value": 6.87 - }, - { - "date": "2018-06-20T06:30:00.000+02:00", - "value": 5.83 - }, - { - "date": "2018-06-20T07:00:00.000+02:00", - "value": 6.45 - }, - { - "date": "2018-06-20T07:30:00.000+02:00", - "value": 8.67 - }, - { - "date": "2018-06-20T08:00:00.000+02:00", - "value": 7.79 - }, - { - "date": "2018-06-20T08:30:00.000+02:00", - "value": 5.34 - }, - { - "date": "2018-06-20T09:00:00.000+02:00", - "value": 8.78 - }, - { - "date": "2018-06-20T09:30:00.000+02:00", - "value": 2.75 - }, - { - "date": "2018-06-20T10:00:00.000+02:00", - "value": 3.32 - }, - { - "date": "2018-06-20T10:30:00.000+02:00", - "value": 3.56 - }, - { - "date": "2018-06-20T11:00:00.000+02:00", - "value": 5.25 - }, - { - "date": "2018-06-20T11:30:00.000+02:00", - "value": 9.85 - }, - { - "date": "2018-06-20T12:00:00.000+02:00", - "value": 5.74 - }, - { - "date": "2018-06-20T12:30:00.000+02:00", - "value": 6.45 - }, - { - "date": "2018-06-20T13:00:00.000+02:00", - "value": 2.71 - }, - { - "date": "2018-06-20T13:30:00.000+02:00", - "value": 0.65 - }, - { - "date": "2018-06-20T14:00:00.000+02:00", - "value": 5.09 - }, - { - "date": "2018-06-20T14:30:00.000+02:00", - "value": 4.2 - }, - { - "date": "2018-06-20T15:00:00.000+02:00", - "value": 3.59 - }, - { - "date": "2018-06-20T15:30:00.000+02:00", - "value": 3.62 - }, - { - "date": "2018-06-20T16:00:00.000+02:00", - "value": 2.09 - }, - { - "date": "2018-06-20T16:30:00.000+02:00", - "value": 8.92 - }, - { - "date": "2018-06-20T17:00:00.000+02:00", - "value": 6.61 - }, - { - "date": "2018-06-20T17:30:00.000+02:00", - "value": 7.75 - }, - { - "date": "2018-06-20T18:00:00.000+02:00", - "value": 0.3 - }, - { - "date": "2018-06-20T18:30:00.000+02:00", - "value": 2.56 - }, - { - "date": "2018-06-20T19:00:00.000+02:00", - "value": 5.72 - }, - { - "date": "2018-06-20T19:30:00.000+02:00", - "value": 5.11 - }, - { - "date": "2018-06-20T20:00:00.000+02:00", - "value": 4.42 - }, - { - "date": "2018-06-20T20:30:00.000+02:00", - "value": 0.4 - }, - { - "date": "2018-06-20T21:00:00.000+02:00", - "value": 1.58 - }, - { - "date": "2018-06-20T21:30:00.000+02:00", - "value": 7.03 - }, - { - "date": "2018-06-20T22:00:00.000+02:00", - "value": 4.31 - }, - { - "date": "2018-06-20T22:30:00.000+02:00", - "value": 1.09 - }, - { - "date": "2018-06-20T23:00:00.000+02:00", - "value": 1.48 - }, - { - "date": "2018-06-20T23:30:00.000+02:00", - "value": 1.9 - } -] \ No newline at end of file diff --git a/test/__mocks__/consumptionMonthlyDataFormatterMock.json b/test/__mocks__/consumptionMonthlyDataFormatterMock.json deleted file mode 100644 index 7946a67970b9bf411f44d3b30eb62d684ab52b25..0000000000000000000000000000000000000000 --- a/test/__mocks__/consumptionMonthlyDataFormatterMock.json +++ /dev/null @@ -1,35 +0,0 @@ -[ - { - "date": "2018-07-01T00:00:00.000+02:00", - "value": 7135.03 - }, - { - "date": "2018-08-01T00:00:00.000+02:00", - "value": 7303.99 - }, - { - "date": "2018-09-01T00:00:00.000+02:00", - "value": 7093.63 - }, - { - "date": "2018-10-01T00:00:00.000+02:00", - "value": 7530.36 - }, - { - "date": "2018-11-01T00:00:00.000+01:00", - "value": 7148.76 - }, - { - "dump": "2018-12-1", - "date": "2018-12-01T00:00:00.000+01:00", - "value": -1 - }, - { - "date": "2019-01-01T00:00:00.000+01:00", - "value": 7761.84 - }, - { - "date": "2019-02-01T00:00:00.000+01:00", - "value": 6616.19 - } -] \ No newline at end of file diff --git a/test/__mocks__/datachartData.mock.ts b/test/__mocks__/datachartData.mock.ts new file mode 100644 index 0000000000000000000000000000000000000000..52491972d93c34793f18f65117b463166e9c42d0 --- /dev/null +++ b/test/__mocks__/datachartData.mock.ts @@ -0,0 +1,39 @@ +import { Datachart } from 'models' +import { DateTime } from 'luxon' + +export const graphData: Datachart = { + actualData: [ + { + date: DateTime.fromISO('2020-10-01T00:00:00.000'), + value: 69.18029999999999, + valueDetail: [45.127739999999996, 0.9048899999999999, 23.147669999999998], + }, + { + date: DateTime.fromISO('2020-10-02T00:00:00.000'), + value: 61.65554999999999, + valueDetail: [40.21918999999999, 0.8064649999999999, 20.629894999999998], + }, + { + date: DateTime.fromISO('2020-10-03T00:00:00.000'), + value: -1, + valueDetail: null, + }, + ], + comparisonData: [ + { + date: DateTime.fromISO('2020-09-01T00:00:00.000'), + value: 54.090509999999995, + valueDetail: [35.284358, 0.707513, 18.098639], + }, + { + date: DateTime.fromISO('2020-09-02T00:00:00.000'), + value: 56.57427, + valueDetail: [36.904565999999996, 0.740001, 18.929703], + }, + { + date: DateTime.fromISO('2020-09-03T00:00:00.000'), + value: -1, + valueDetail: null, + }, + ], +} diff --git a/test/__mocks__/ecogesturesData.mock.ts b/test/__mocks__/ecogesturesData.mock.ts new file mode 100644 index 0000000000000000000000000000000000000000..422803d782862d5f5ee9de9c4b2147c25fdd2d49 --- /dev/null +++ b/test/__mocks__/ecogesturesData.mock.ts @@ -0,0 +1,49 @@ +import { Ecogesture } from 'models' + +export const ecogesturesData: Ecogesture[] = [ + { + fluidTypes: [0], + id: '0032', + longDescription: + 'Bien souvent les chauffe-eau sont réglés pour une température de 70 °C dans le ballon, ce qui n’est pas économique et peut même être dangereux ! Au-dessus de 60 °C vous augmentez aussi l’entartrage. L’eau ne doit pas être trop froide non plus pour éviter le risque de prolifération de micro-organismes comme les légionelles. A noter : parfois l’accès au réglage n’est pas directement visible… il faut alors retirer le capot en plastique situé sous le chauffe-eau pour y accéder.', + longName: 'Je règle la température de mon eau chaude entre 55 et 60 °C.', + nwh: 6, + pack: 8, + shortDescription: '', + shortName: 'Contrôle du nuage', + usage: 'Eau chaude sanitaire', + _id: '0032', + _rev: '1-67f1ea36efdd892c96bf64a8943154cd', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + fluidTypes: [1], + id: '0034', + longDescription: + "Si on n'a pas transpiré la journée et qu'on ne sent pas mauvais, aucune obligation de se laver tous les jours. Il est même conseillé pour la flore de l'épiderme (la fameuse barrière contre certains pathogènes) de ne pas se laver tous les jours. Vous économiserez ainsi une quantité d'eau non négligeable.", + longName: 'Je décide de supprimer une douche par semaine.', + nwh: 5, + pack: 6, + shortDescription: '', + shortName: 'Vague de sécheresse', + usage: 'Eau chaude sanitaire', + _id: '0034', + _rev: '1-ef7ddd778254e3b7d331a88fd17f606d', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, + { + fluidTypes: [1], + id: '0037', + longDescription: + "Le terme 'mousseur' désigne la pièce qui est située au bout de votre robinet qui permet de canaliser le jet d’eau. La plupart des robinets sont équipés de mousseurs, mais ceux-ci ne réduisent pas le débit. Il existe différents types 'd’éco-mousseurs' qui limitent le débit à des niveaux variables. Choisissez votre matériel en fonction des besoins à chaque robinet : 5 L/min sera adapté pour un robinet servant uniquement à se laver les mains mais sera assez pénible si vous devez remplir un seau !", + longName: "J'équipe mes robinets d’éco-mousseurs.", + nwh: 4, + pack: 0, + shortDescription: '', + shortName: 'Super plombier', + usage: 'Eau chaude sanitaire', + _id: '0037', + _rev: '1-0b2761dd4aef79556c7aef144060fde6', + _type: 'com.grandlyon.ecolyo.ecogesture', + }, +] diff --git a/test/__mocks__/enedis-dayMock.json b/test/__mocks__/enedis-dayMock.json deleted file mode 100644 index cc3b4ec8c1f4a7d9cde42e7e3dab354e2b52c16c..0000000000000000000000000000000000000000 --- a/test/__mocks__/enedis-dayMock.json +++ /dev/null @@ -1,170 +0,0 @@ - [ - { - "id": "70fddfc40223272bd74c286d7c053aa6", - "_id": "70fddfc40223272bd74c286d7c053aa6", - "_type": "com.grandlyon.enedis.day", - "_rev": "1-8e5976963701b9d98fb1ddbf6648469b", - "day": 11, - "hour": 0, - "load": 7.341, - "minute": 0, - "month": 2, - "year": 2019 - }, - { - "id": "70fddfc40223272bd74c286d7c0520f7", - "_id": "70fddfc40223272bd74c286d7c0520f7", - "_type": "com.grandlyon.enedis.day", - "_rev": "1-33fc0ac1cd570c92288dfb655011e744", - "day": 12, - "hour": 0, - "load": 12.633, - "minute": 0, - "month": 2, - "year": 2019 - }, - { - "id": "70fddfc40223272bd74c286d7c052bb4", - "_id": "70fddfc40223272bd74c286d7c052bb4", - "_type": "com.grandlyon.enedis.day", - "_rev": "1-a131eaf0a1793ccb1f909bf1e051f5e4", - "day": 13, - "hour": 0, - "load": 12.566, - "minute": 0, - "month": 2, - "year": 2019 - }, - { - "id": "70fddfc40223272bd74c286d7c056647", - "_id": "70fddfc40223272bd74c286d7c056647", - "_type": "com.grandlyon.enedis.day", - "_rev": "1-a4573af893bc614648d4ea6cf85a2a4b", - "day": 14, - "hour": 0, - "load": 8.972, - "minute": 0, - "month": 2, - "year": 2019 - }, - { - "id": "70fddfc40223272bd74c286d7c05a874", - "_id": "70fddfc40223272bd74c286d7c05a874", - "_type": "com.grandlyon.enedis.day", - "_rev": "1-05c1451ba54d5a44b6af86470d04e319", - "day": 15, - "hour": 0, - "load": 13.703, - "minute": 0, - "month": 2, - "year": 2019 - }, - { - "id": "70fddfc40223272bd74c286d7c059c94", - "_id": "70fddfc40223272bd74c286d7c059c94", - "_type": "com.grandlyon.enedis.day", - "_rev": "1-fd13c972c85329e61bb86a22f29e0260", - "day": 16, - "hour": 0, - "load": 11.801, - "minute": 0, - "month": 2, - "year": 2019 - }, - { - "id": "70fddfc40223272bd74c286d7c05bd72", - "_id": "70fddfc40223272bd74c286d7c05bd72", - "_type": "com.grandlyon.enedis.day", - "_rev": "1-f041e50562e991828edd23cf40321709", - "day": 17, - "hour": 0, - "load": 14.282, - "minute": 0, - "month": 2, - "year": 2019 - }, - { - "id": "70fddfc40223272bd74c286d7c05af31", - "_id": "70fddfc40223272bd74c286d7c05af31", - "_type": "com.grandlyon.enedis.day", - "_rev": "1-47d9d3d3b8abcc835eb7636af317fb22", - "day": 18, - "hour": 0, - "load": 16.594, - "minute": 0, - "month": 2, - "year": 2019 - }, - { - "id": "70fddfc40223272bd74c286d7c05bd76", - "_id": "70fddfc40223272bd74c286d7c05bd76", - "_type": "com.grandlyon.enedis.day", - "_rev": "1-7b6aa26a76d7ea9a78968e50dc160cd6", - "day": 19, - "hour": 0, - "load": 9.59, - "minute": 0, - "month": 2, - "year": 2019 - }, - { - "id": "70fddfc40223272bd74c286d7c05c353", - "_id": "70fddfc40223272bd74c286d7c05c353", - "_type": "com.grandlyon.enedis.day", - "_rev": "1-9c3dbf64d5f54972711bcd3b10256e36", - "day": 20, - "hour": 0, - "load": 11.709, - "minute": 0, - "month": 2, - "year": 2019 - }, - { - "id": "70fddfc40223272bd74c286d7c05c9a1", - "_id": "70fddfc40223272bd74c286d7c05c9a1", - "_type": "com.grandlyon.enedis.day", - "_rev": "1-264ca0611717e7feb8e49dd0625c38a2", - "day": 21, - "hour": 0, - "load": 10.951, - "minute": 0, - "month": 2, - "year": 2019 - }, - { - "id": "70fddfc40223272bd74c286d7c05d922", - "_id": "70fddfc40223272bd74c286d7c05d922", - "_type": "com.grandlyon.enedis.day", - "_rev": "1-0d14a1a058b9ca9780db9bd2ab3b3c2d", - "day": 22, - "hour": 0, - "load": 22.652, - "minute": 0, - "month": 2, - "year": 2019 - }, - { - "id": "70fddfc40223272bd74c286d7c05fa63", - "_id": "70fddfc40223272bd74c286d7c05fa63", - "_type": "com.grandlyon.enedis.day", - "_rev": "1-d1367b96c9a986ed4dadecbb36719f61", - "day": 23, - "hour": 0, - "load": 13.099, - "minute": 0, - "month": 2, - "year": 2019 - }, - { - "id": "70fddfc40223272bd74c286d7c05e659", - "_id": "70fddfc40223272bd74c286d7c05e659", - "_type": "com.grandlyon.enedis.day", - "_rev": "1-a50e07164ec413a26e0f3d82eadf2abf", - "day": 24, - "hour": 0, - "load": 19.892, - "minute": 0, - "month": 2, - "year": 2019 - } - ] diff --git a/test/__mocks__/fluidStatusData.mock.ts b/test/__mocks__/fluidStatusData.mock.ts new file mode 100644 index 0000000000000000000000000000000000000000..69c78d2d1812b5c1e50b048df1827a86174e203b --- /dev/null +++ b/test/__mocks__/fluidStatusData.mock.ts @@ -0,0 +1,20 @@ +import { DateTime } from 'luxon' +import { FluidStatus } from 'models' + +export const fluidStatusData: FluidStatus[] = [ + { + fluidType: 0, + status: 'errored', + lastDataDate: DateTime.fromISO('2020-09-01T00:00:00.000'), + }, + { + fluidType: 1, + status: 'errored', + lastDataDate: DateTime.fromISO('2020-09-01T00:00:00.000'), + }, + { + fluidType: 2, + status: 'errored', + lastDataDate: DateTime.fromISO('2020-09-01T00:00:00.000'), + }, +] diff --git a/test/__mocks__/konnectorsData.mock.ts b/test/__mocks__/konnectorsData.mock.ts new file mode 100644 index 0000000000000000000000000000000000000000..d9e70b5cb87c0e0c870df11ec771db034fd187a7 --- /dev/null +++ b/test/__mocks__/konnectorsData.mock.ts @@ -0,0 +1,22 @@ +import { Konnector } from 'models' + +export const konnectorsData: Konnector[] = [ + { + _id: 'io.cozy.konnectors/enedisgrandlyon', + name: 'Enedis', + slug: 'enedisgrandlyon', + state: 'ready', + }, + { + _id: 'io.cozy.konnectors/eglgrandlyon', + name: 'EGL', + slug: 'eglgrandlyon', + state: 'ready', + }, + { + _id: 'io.cozy.konnectors/grdfgrandlyon', + name: 'GRDF', + slug: 'grdfgrandlyon', + state: 'ready', + }, +] diff --git a/test/__mocks__/loadDayData.mock.ts b/test/__mocks__/loadDayData.mock.ts new file mode 100644 index 0000000000000000000000000000000000000000..3d669c28c38268500254e6b5cfc69bf590940da7 --- /dev/null +++ b/test/__mocks__/loadDayData.mock.ts @@ -0,0 +1,52 @@ +import { DataloadEntity } from 'models' + +export const loadDayData: DataloadEntity[] = [ + { + id: 'bf1ce3a5774e140056714c4c200c093e', + _id: 'bf1ce3a5774e140056714c4c200c093e', + _type: 'com.grandlyon.enedis.day', + _rev: '1-4fe971dff073a3c3c6cc12a0246e642e', + day: 1, + hour: 0, + load: 25.25, + minute: 0, + month: 11, + year: 2020, + }, + { + id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _type: 'com.grandlyon.enedis.day', + _rev: '1-4fe971dff073a3c3c6cc12a0246e642e', + day: 2, + hour: 0, + load: 20.5, + minute: 0, + month: 11, + year: 2020, + }, + { + id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _type: 'com.grandlyon.enedis.day', + _rev: '1-4fe971dff073a3c3c6cc12a0246e642e', + day: 3, + hour: 0, + load: 30.33, + minute: 0, + month: 11, + year: 2020, + }, + { + id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _type: 'com.grandlyon.enedis.day', + _rev: '1-4fe971dff073a3c3c6cc12a0246e642e', + day: 4, + hour: 0, + load: 1.22, + minute: 0, + month: 11, + year: 2020, + }, +] diff --git a/test/__mocks__/loadHourData.mock.ts b/test/__mocks__/loadHourData.mock.ts new file mode 100644 index 0000000000000000000000000000000000000000..68f43c0a199da2ad9998a0a19bb26152b729d146 --- /dev/null +++ b/test/__mocks__/loadHourData.mock.ts @@ -0,0 +1,64 @@ +import { DataloadEntity } from 'models' + +export const loadHourData: DataloadEntity[] = [ + { + id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _type: 'com.grandlyon.enedis.hour', + _rev: '1-4fe971dff073a3c3c6cc12a0246e642e', + day: 2, + hour: 0, + load: 4.5, + minute: 0, + month: 11, + year: 2020, + }, + { + id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _type: 'com.grandlyon.enedis.hour', + _rev: '1-4fe971dff073a3c3c6cc12a0246e642e', + day: 2, + hour: 1, + load: 1.33, + minute: 0, + month: 11, + year: 2020, + }, + { + id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _type: 'com.grandlyon.enedis.hour', + _rev: '1-4fe971dff073a3c3c6cc12a0246e642e', + day: 2, + hour: 2, + load: 3.22, + minute: 0, + month: 11, + year: 2020, + }, + { + id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _type: 'com.grandlyon.enedis.hour', + _rev: '1-4fe971dff073a3c3c6cc12a0246e642e', + day: 2, + hour: 3, + load: 7.82, + minute: 0, + month: 11, + year: 2020, + }, + { + id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _type: 'com.grandlyon.enedis.hour', + _rev: '1-4fe971dff073a3c3c6cc12a0246e642e', + day: 2, + hour: 4, + load: 1.23, + minute: 0, + month: 11, + year: 2020, + }, +] diff --git a/test/__mocks__/loadMinuteData.mock.ts b/test/__mocks__/loadMinuteData.mock.ts new file mode 100644 index 0000000000000000000000000000000000000000..02dc8cdfaa2864e74cf2c8581f260c772682c7e1 --- /dev/null +++ b/test/__mocks__/loadMinuteData.mock.ts @@ -0,0 +1,76 @@ +import { DataloadEntity } from 'models' + +export const loadMinuteData: DataloadEntity[] = [ + { + id: 'bf1ce3a5774e140056714c4c200c093e', + _id: 'bf1ce3a5774e140056714c4c200c093e', + _type: 'com.grandlyon.enedis.minute', + _rev: '1-4fe971dff073a3c3c6cc12a0246e642e', + day: 1, + hour: 23, + load: 2.25, + minute: 30, + month: 11, + year: 2020, + }, + { + id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _type: 'com.grandlyon.enedis.minute', + _rev: '1-4fe971dff073a3c3c6cc12a0246e642e', + day: 2, + hour: 0, + load: 4.5, + minute: 0, + month: 11, + year: 2020, + }, + { + id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _type: 'com.grandlyon.enedis.minute', + _rev: '1-4fe971dff073a3c3c6cc12a0246e642e', + day: 2, + hour: 0, + load: 1.33, + minute: 30, + month: 11, + year: 2020, + }, + { + id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _type: 'com.grandlyon.enedis.minute', + _rev: '1-4fe971dff073a3c3c6cc12a0246e642e', + day: 2, + hour: 1, + load: 3.22, + minute: 0, + month: 11, + year: 2020, + }, + { + id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _type: 'com.grandlyon.enedis.minute', + _rev: '1-4fe971dff073a3c3c6cc12a0246e642e', + day: 2, + hour: 1, + load: 7.82, + minute: 30, + month: 11, + year: 2020, + }, + { + id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _type: 'com.grandlyon.enedis.minute', + _rev: '1-4fe971dff073a3c3c6cc12a0246e642e', + day: 2, + hour: 2, + load: 1.23, + minute: 0, + month: 11, + year: 2020, + }, +] diff --git a/test/__mocks__/loadMonthData.mock.ts b/test/__mocks__/loadMonthData.mock.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc869cb7eda7d64ecc2b7c75a8b9e7122f8be311 --- /dev/null +++ b/test/__mocks__/loadMonthData.mock.ts @@ -0,0 +1,40 @@ +import { DataloadEntity } from 'models' + +export const loadMonthData: DataloadEntity[] = [ + { + id: 'bf1ce3a5774e140056714c4c200c093e', + _id: 'bf1ce3a5774e140056714c4c200c093e', + _type: 'com.grandlyon.enedis.month', + _rev: '1-4fe971dff073a3c3c6cc12a0246e642e', + day: 1, + hour: 0, + load: 125.25, + minute: 0, + month: 9, + year: 2020, + }, + { + id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _type: 'com.grandlyon.enedis.month', + _rev: '1-4fe971dff073a3c3c6cc12a0246e642e', + day: 1, + hour: 0, + load: 220.5, + minute: 0, + month: 10, + year: 2020, + }, + { + id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _type: 'com.grandlyon.enedis.month', + _rev: '1-4fe971dff073a3c3c6cc12a0246e642e', + day: 1, + hour: 0, + load: 130.33, + minute: 0, + month: 11, + year: 2020, + }, +] diff --git a/test/__mocks__/loadYearData.mock.ts b/test/__mocks__/loadYearData.mock.ts new file mode 100644 index 0000000000000000000000000000000000000000..467b33c64452ed7bc3f74a4d986d1a94d6afb1a2 --- /dev/null +++ b/test/__mocks__/loadYearData.mock.ts @@ -0,0 +1,40 @@ +import { DataloadEntity } from 'models' + +export const loadYearData: DataloadEntity[] = [ + { + id: 'bf1ce3a5774e140056714c4c200c093e', + _id: 'bf1ce3a5774e140056714c4c200c093e', + _type: 'com.grandlyon.enedis.year', + _rev: '1-4fe971dff073a3c3c6cc12a0246e642e', + day: 1, + hour: 0, + load: 125.25, + minute: 0, + month: 1, + year: 2018, + }, + { + id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _type: 'com.grandlyon.enedis.year', + _rev: '1-4fe971dff073a3c3c6cc12a0246e642e', + day: 0, + hour: 0, + load: 220.5, + minute: 0, + month: 0, + year: 2019, + }, + { + id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _id: 'cf7dc6f44a19b354f99b01ba1a0b4840', + _type: 'com.grandlyon.enedis.year', + _rev: '1-4fe971dff073a3c3c6cc12a0246e642e', + day: 1, + hour: 0, + load: 130.33, + minute: 0, + month: 1, + year: 2020, + }, +] diff --git a/test/__mocks__/recoil.ts b/test/__mocks__/recoil.ts index 31355bbbdc5a851f6ed77885b33162d556a130d1..e9f0888637b1b12d155a8a68227ff68dc6274894 100644 --- a/test/__mocks__/recoil.ts +++ b/test/__mocks__/recoil.ts @@ -2,3 +2,4 @@ export const atom = jest.fn() export const selector = jest.fn() export const useRecoilValue = jest.fn() export const useSetRecoilState = jest.fn() +export const useRecoilState = jest.fn() diff --git a/test/__mocks__/triggerDataMock.json b/test/__mocks__/triggerDataMock.json deleted file mode 100644 index 0c699826f6b9af0d58046171168db069592a26a5..0000000000000000000000000000000000000000 --- a/test/__mocks__/triggerDataMock.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "type": "@cron", - "id": "70b2fcc31ae9adb95c3ce0a344001941", - "attributes": { - "_id": "70b2fcc31ae9adb95c3ce0a344001941", - "_rev": "1-d84be387304c880015172c1e541c6f2b", - "domain": "cozy.tools:8080", - "prefix": "cozy35ba44d2d1749e6f21646edce51e7190", - "type": "@cron", - "worker": "konnector", - "arguments": "0 47 0 * * *", - "debounce": "", - "options": null, - "message": { - "account": "70b2fcc31ae9adb95c3ce0a34400185c", - "konnector": "enedis-scraping-connector" - }, - "current_state": { - "trigger_id": "70b2fcc31ae9adb95c3ce0a344001941", - "status": "errored", - "last_execution": "2020-01-16T15:53:50.2310024Z", - "last_executed_job_id": "70b2fcc31ae9adb95c3ce0a34400204a", - "last_failure": "2020-01-16T15:53:50.2310024Z", - "last_failed_job_id": "70b2fcc31ae9adb95c3ce0a34400204a", - "last_error": "fork/exec : no such file or directory", - "last_manual_execution": "2020-01-16T15:53:50.2310024Z", - "last_manual_job_id": "70b2fcc31ae9adb95c3ce0a34400204a" - }, - "cozyMetadata": { - "doctypeVersion": "1", - "metadataVersion": 1, - "createdAt": "2020-01-16T15:53:50.0323739Z", - "createdByApp": "ecolyo", - "updatedAt": "2020-01-16T15:53:50.0323739Z" - } - }, - "meta": {}, - "links": { - "self": "/jobs/triggers/70b2fcc31ae9adb95c3ce0a344001941" - }, - "_id": "70b2fcc31ae9adb95c3ce0a344001941", - "_type": "io.cozy.triggers", - "_rev": "1-d84be387304c880015172c1e541c6f2b", - "domain": "cozy.tools:8080", - "prefix": "cozy35ba44d2d1749e6f21646edce51e7190", - "worker": "konnector", - "arguments": "0 47 0 * * *", - "debounce": "", - "options": null, - "message": { - "account": "70b2fcc31ae9adb95c3ce0a34400185c", - "konnector": "enedis-scraping-connector" - }, - "current_state": { - "trigger_id": "70b2fcc31ae9adb95c3ce0a344001941", - "status": "errored", - "last_execution": "2020-01-16T15:53:50.2310024Z", - "last_executed_job_id": "70b2fcc31ae9adb95c3ce0a34400204a", - "last_failure": "2020-01-16T15:53:50.2310024Z", - "last_failed_job_id": "70b2fcc31ae9adb95c3ce0a34400204a", - "last_error": "fork/exec : no such file or directory", - "last_manual_execution": "2020-01-16T15:53:50.2310024Z", - "last_manual_job_id": "70b2fcc31ae9adb95c3ce0a34400204a" - }, - "cozyMetadata": { - "doctypeVersion": "1", - "metadataVersion": 1, - "createdAt": "2020-01-16T15:53:50.0323739Z", - "createdByApp": "ecolyo", - "updatedAt": "2020-01-16T15:53:50.0323739Z" - } -} diff --git a/test/__mocks__/triggerStateData.mock.ts b/test/__mocks__/triggerStateData.mock.ts new file mode 100644 index 0000000000000000000000000000000000000000..f921419f45ffe068bc02216f477b242971fe6bcd --- /dev/null +++ b/test/__mocks__/triggerStateData.mock.ts @@ -0,0 +1,14 @@ +/* eslint-disable @typescript-eslint/camelcase */ +import { TriggerState } from 'models' + +export const triggerStateData: TriggerState = { + trigger_id: '238ba37b8bc8130bd323edb5c1005c8f', + status: 'errored', + last_execution: '2020-11-13T10:03:16.4121536Z', + last_executed_job_id: '238ba37b8bc8130bd323edb5c1006b56', + last_failure: '2020-11-13T10:03:16.4121536Z', + last_failed_job_id: '238ba37b8bc8130bd323edb5c1006b56', + last_error: 'fork/exec : no such file or directory', + last_manual_execution: '2020-11-13T10:03:16.4121536Z', + last_manual_job_id: '238ba37b8bc8130bd323edb5c1006b56', +} diff --git a/test/__mocks__/triggersData.mock.ts b/test/__mocks__/triggersData.mock.ts new file mode 100644 index 0000000000000000000000000000000000000000..76dbb299a133d110e7f1eee74a341d79193a2b80 --- /dev/null +++ b/test/__mocks__/triggersData.mock.ts @@ -0,0 +1,67 @@ +import { Trigger } from 'models' + +export const triggersData: Trigger[] = [ + { + _id: '3ed832cec67e6e0b2c6382edd30df11c', + domain: 'cozy.tools:8080', + prefix: 'cozy35ba44d2d1749e6f21646edce51e7190', + type: '@cron', + worker: 'konnector', + arguments: '0 47 8 * * *', + debounce: '', + options: null, + message: { + account: '88e68b8450cee09fe2f077610901094d', + konnector: 'enedisgrandlyon', + }, + cozyMetadata: { + doctypeVersion: '1', + metadataVersion: 1, + createdAt: '2020-10-09T08:00:00.6092798Z', + createdByApp: 'ecolyo', + updatedAt: '2020-10-09T08:00:00.6092798Z', + }, + }, + { + _id: '5ed832cec67e6e0b2c6382edd30df11c', + domain: 'cozy.tools:8080', + prefix: 'cozy35ba44d2d1749e6f21646edce51e7190', + type: '@cron', + worker: 'konnector', + arguments: '0 47 8 * * *', + debounce: '', + options: null, + message: { + account: '90e68b8450cee09fe2f077610901094d', + konnector: 'eglgrandlyon', + }, + cozyMetadata: { + doctypeVersion: '1', + metadataVersion: 1, + createdAt: '2020-10-09T08:00:00.6092798Z', + createdByApp: 'ecolyo', + updatedAt: '2020-10-09T08:00:00.6092798Z', + }, + }, + { + _id: '4ed832cec67e6e0b2c6382edd30df11c', + domain: 'cozy.tools:8080', + prefix: 'cozy35ba44d2d1749e6f21646edce51e7190', + type: '@cron', + worker: 'konnector', + arguments: '0 47 8 * * *', + debounce: '', + options: null, + message: { + account: '89e68b8450cee09fe2f077610901094d', + konnector: 'grdfgrandlyon', + }, + cozyMetadata: { + doctypeVersion: '1', + metadataVersion: 1, + createdAt: '2020-10-09T08:00:00.6092798Z', + createdByApp: 'ecolyo', + updatedAt: '2020-10-09T08:00:00.6092798Z', + }, + }, +] diff --git a/src/services/__mocks__/userProfile.mock.ts b/test/__mocks__/userProfile.mock.ts similarity index 93% rename from src/services/__mocks__/userProfile.mock.ts rename to test/__mocks__/userProfile.mock.ts index 4f0d87abfeadb0a0fa5af23ff40dec94cf82dbea..3ebe2cd2cc8d44325bd935252706a24bfcafa05c 100644 --- a/src/services/__mocks__/userProfile.mock.ts +++ b/test/__mocks__/userProfile.mock.ts @@ -1,6 +1,6 @@ import { DateTime } from 'luxon' -export const userProfileEntityData = { +export const userProfileData = { _id: '4d9403218ef13e65b2e3a8ad1700bc41', _rev: '16-57473da4fc26315247c217083175dfa0', challengeTypeHash: '1136feb6185c7643e071d14180c0e95782aa4ba3', diff --git a/test/services/ConsumptionDataFormatter.spec.ts.old b/test/services/ConsumptionDataFormatter.spec.ts.old deleted file mode 100644 index 6d8cbaf780c7f4d0ac5b2fd1b6767e74c7e6eb51..0000000000000000000000000000000000000000 --- a/test/services/ConsumptionDataFormatter.spec.ts.old +++ /dev/null @@ -1,87 +0,0 @@ -'use strict' -import ConsumptionFormatterService from '../../src/services/consumptionFormatter.service' -import consumptionHalfHourlyData from '../__mocks__/consumptionHalfHourlyDataFormatterMock' -import consumptionDailyData from '../__mocks__/consumptionDailyDataFormatterMock' -import consumptionMonthlyData from '../__mocks__/consumptionMonthlyDataFormatterMock' -import { DateTime } from 'luxon' - -import { TimeStep } from '../../src/enum/timeStep.enum' - -describe('Consumption Data Formatter service tests', () => { - beforeEach(() => { - jest.resetAllMocks() - }) - - const consumptionFormatterService = new ConsumptionFormatterService() - - const halfHourlyData = JSON.parse(JSON.stringify(consumptionHalfHourlyData)) - - const mappedHalfHourlyData = halfHourlyData.map(item => ({ - date: DateTime.fromISO(item.date), - value: item.value, - })) - - const dailyData = JSON.parse(JSON.stringify(consumptionDailyData)) - - const mappeddailyDataData = dailyData.map(item => ({ - date: DateTime.fromISO(item.date), - value: item.value, - })) - - const monthlyData = JSON.parse(JSON.stringify(consumptionMonthlyData)) - - const mappedMonthlyData = monthlyData.map(item => ({ - date: DateTime.fromISO(item.date), - value: item.value, - })) - - const dayTimePeriod = { - startDate: DateTime.local(2018, 6, 20), - endDate: DateTime.local(2018, 6, 20, 23, 30), - } - - const daytimeStep = TimeStep.HALF_AN_HOUR - - const monthTimePeriod = { - startDate: DateTime.local(2018, 7, 1), - endDate: DateTime.local(2018, 8, 2), - } - - const monthTimeStep = TimeStep.DAY - - const yearTimePeriod = { - startDate: DateTime.local(2018, 7, 1), - endDate: DateTime.local(2019, 2, 6), - } - - const yearTimeStep = TimeStep.MONTH - - const sumReducer = (acc, dataLoad) => acc + dataLoad.value - - it('formatGraphData', () => { - const halfHourResult = consumptionFormatterService.formatGraphData( - mappedHalfHourlyData, - dayTimePeriod, - daytimeStep - ) - const dayResult = consumptionFormatterService.formatGraphData( - mappeddailyDataData, - monthTimePeriod, - monthTimeStep - ) - const monthResult = consumptionFormatterService.formatGraphData( - mappedMonthlyData, - yearTimePeriod, - yearTimeStep - ) - - expect(halfHourResult.length).toBe(48) - expect(halfHourResult.reduce(sumReducer, 0)).toBe(213.33000000000004) - - expect(dayResult.length).toBe(33) - expect(dayResult.reduce(sumReducer, 0)).toBe(7544.85) - - expect(monthResult.length).toBe(8) - expect(monthResult.reduce(sumReducer, 0)).toBe(50588.8) - }) -}) diff --git a/test/services/ConsumptionDataManager.spec.ts.old b/test/services/ConsumptionDataManager.spec.ts.old deleted file mode 100644 index 6e244d9f211fd300d62dbf47fb4efe0282ec6aa3..0000000000000000000000000000000000000000 --- a/test/services/ConsumptionDataManager.spec.ts.old +++ /dev/null @@ -1,26 +0,0 @@ -'use strict' -//import ConsumptionDataManager from '../../src/services/consumptionDataManagerService' -/*import { DateTime } from 'luxon' -import { TimeStep } from '../../src/services/dataConsumptionContracts' - -// client needs to be mocked correctely to test the CDM -const mockClient = { - query: jest.fn(), - get: jest.fn(), -}*/ - -describe('Consumption Data Manager', () => { - beforeEach(() => { - jest.resetAllMocks() - }) - - //const cdm = new ConsumptionDataManager(mockClient); - - it('GetGraphData', () => { - expect(true).toBe(true) - }) - - it('FetchLastDateData', () => { - expect(true).toBe(true) - }) -}) diff --git a/test/services/ConsumptionDataValidator.spec.ts.old b/test/services/ConsumptionDataValidator.spec.ts.old deleted file mode 100644 index ec8d8104fffe97507c34de982ea8d57791753ae4..0000000000000000000000000000000000000000 --- a/test/services/ConsumptionDataValidator.spec.ts.old +++ /dev/null @@ -1,99 +0,0 @@ -'use strict' -import ConsumptionValidatorService from '../../src/services/consumptionValidator.service' -import { DateTime } from 'luxon' -import { FluidType } from '../../src/enum/fluid.enum' -import { TimeStep } from '../../src/enum/timeStep.enum' - -describe('Consumption Data Validator service tests', () => { - beforeEach(() => { - jest.resetAllMocks() - }) - - const consumptionValidatorService = new ConsumptionValidatorService() - - /* -consumptionValidatorService.ValidateGetGraphData( - timePeriod, - timeStep, - fluidTypes, - compareTimePeriod -) - - const yearTimeStep = TimeStep.MONTH - - const sumReducer = (acc, dataLoad) => acc + dataLoad.value*/ - - it('matching fluidTypes and TimeStep', () => { - const timePeriod = { - startDate: DateTime.local(2018, 1, 1), - endDate: DateTime.local(2018, 1, 2), - } - /*const compareTimePeriod = { - startDate: DateTime.local(2018, 1, 2), - endDate: DateTime.local(2018, 1, 3), - }*/ - - expect( - consumptionValidatorService.ValidateGetGraphData( - timePeriod, - TimeStep.HALF_AN_HOUR, - [FluidType.WATER] - ) - ).toBe(false) - - expect( - consumptionValidatorService.ValidateGetGraphData( - timePeriod, - TimeStep.HALF_AN_HOUR, - [FluidType.ELECTRICITY] - ) - ).toBe(true) - - expect( - consumptionValidatorService.ValidateGetGraphData( - timePeriod, - TimeStep.HALF_AN_HOUR, - [FluidType.WATER] - ) - ).toBe(false) - - expect( - consumptionValidatorService.ValidateGetGraphData( - timePeriod, - TimeStep.HOUR, - [FluidType.ELECTRICITY] - ) - ).toBe(false) - - expect( - consumptionValidatorService.ValidateGetGraphData( - timePeriod, - TimeStep.HOUR, - [FluidType.GAS] - ) - ).toBe(true) - - expect( - consumptionValidatorService.ValidateGetGraphData( - timePeriod, - TimeStep.HOUR, - [FluidType.WATER] - ) - ).toBe(false) - }) - - it('comparing timePeriod starting and ending dates', () => { - const timePeriod = { - startDate: DateTime.local(2018, 1, 2), - endDate: DateTime.local(2018, 1, 1), - } - - expect( - consumptionValidatorService.ValidateGetGraphData( - timePeriod, - TimeStep.HALF_AN_HOUR, - [FluidType.ELECTRICITY] - ) - ).toBe(false) - }) -}) diff --git a/test/services/FluidService.spec.js.old b/test/services/FluidService.spec.js.old deleted file mode 100644 index b019855e240cc5841916d4f5f2d8c81c6c90291b..0000000000000000000000000000000000000000 --- a/test/services/FluidService.spec.js.old +++ /dev/null @@ -1,28 +0,0 @@ -'use strict' -import FluidService from '../../src/services/fluid.service' -import data from '../__mocks__/enedis-dayMock.json' -/* eslint-env jest */ - -const mockClient = { - find: jest.fn(), - create: jest.fn(), - destory: jest.fn(), -} - -describe('Fluid service tests', () => { - beforeEach(() => { - // reset all jest mock calls data before each test - jest.resetAllMocks() - }) - - it('should return last two week electricity', () => { - const fluidService = new FluidService(mockClient) - //console.log(data) - const indicators = fluidService.processElectricityData(data) - expect(indicators.consumptionValue).toBe(104) - /*expect(indicators.eucilidanComparator).toBe( - "Vous avez consommé un max d'ampoules !" - )*/ - expect(indicators.weeklyCompareValue).toBe(-29) - }) -}) diff --git a/test/services/QueryRunner.spec.ts.old b/test/services/QueryRunner.spec.ts.old deleted file mode 100644 index 132c2849aa3c41784309a95ff9c8ffbe3ec0bc0e..0000000000000000000000000000000000000000 --- a/test/services/QueryRunner.spec.ts.old +++ /dev/null @@ -1,26 +0,0 @@ -'use strict' -//import QuerryRunner from '../../src/services/queryRunnerService' -/*import { DateTime } from 'luxon' -import { TimeStep } from '../../src/services/dataConsumptionContracts' - -// client needs to be mocked correctely to test the CDM -const mockClient = { - query: jest.fn(), - get: jest.fn(), -}*/ - -describe('Querry Runner', () => { - beforeEach(() => { - jest.resetAllMocks() - }) - - //const qr = new QuerryRunner(mockClient); - - it('fetchFluidData', () => { - expect(true).toBe(true) - }) - - it('getLastDateData', () => { - expect(true).toBe(true) - }) -}) diff --git a/test/services/TriggerService.spec.js.old b/test/services/TriggerService.spec.js.old deleted file mode 100644 index 1882b5d5ddaa9de26b5542f09c4f81a79cbcba38..0000000000000000000000000000000000000000 --- a/test/services/TriggerService.spec.js.old +++ /dev/null @@ -1,22 +0,0 @@ -'use strict' -import { TriggerService } from '../../src/services/triggersService' -import triggerData from '../__mocks__/triggerDataMock.json' - -const trigger = JSON.parse(JSON.stringify(triggerData)) - -describe('Trigger service tests', () => { - beforeEach(() => { - // reset all jest mock calls data before each test - jest.resetAllMocks() - }) - - it('fetch State', () => { - const state = TriggerService.fetchStateFromTrigger(trigger) - expect(state.status).toBe('errored') - }) - - it('fetch Date', () => { - const date = TriggerService.fetchDateFromTrigger(trigger) - expect(date).toBe('2020 M01 16 16:53') - }) -}) diff --git a/test/services/_/consumptionDailyDataFormatterMock.json b/test/services/_/consumptionDailyDataFormatterMock.json deleted file mode 100644 index f1755a69326db74ac25617a891d36bbc7022a8fe..0000000000000000000000000000000000000000 --- a/test/services/_/consumptionDailyDataFormatterMock.json +++ /dev/null @@ -1,134 +0,0 @@ -[ - { - "date": "2018-07-01T00:00:00.000+02:00", - "value": 242.23 - }, - { - "date": "2018-07-02T00:00:00.000+02:00", - "value": 230.2 - }, - { - "date": "2018-07-03T00:00:00.000+02:00", - "value": 225.13 - }, - { - "date": "2018-07-04T00:00:00.000+02:00", - "value": 220.63 - }, - { - "date": "2018-07-05T00:00:00.000+02:00", - "value": 204.53 - }, - { - "date": "2018-07-06T00:00:00.000+02:00", - "value": 211.86 - }, - { - "date": "2018-07-07T00:00:00.000+02:00", - "value": 276.19 - }, - { - "date": "2018-07-08T00:00:00.000+02:00", - "value": 243.36 - }, - { - "date": "2018-07-09T00:00:00.000+02:00", - "value": 228.01 - }, - { - "date": "2018-07-10T00:00:00.000+02:00", - "value": 230.6 - }, - { - "date": "2018-07-11T00:00:00.000+02:00", - "value": 289.81 - }, - { - "date": "2018-07-12T00:00:00.000+02:00", - "value": 213.03 - }, - { - "date": "2018-07-13T00:00:00.000+02:00", - "value": 207.2 - }, - { - "date": "2018-07-14T00:00:00.000+02:00", - "value": 222.39 - }, - { - "date": "2018-07-15T00:00:00.000+02:00", - "value": 245.71 - }, - { - "date": "2018-07-16T00:00:00.000+02:00", - "value": 284.31 - }, - { - "date": "2018-07-17T00:00:00.000+02:00", - "value": 234.3 - }, - { - "date": "2018-07-18T00:00:00.000+02:00", - "value": 247.73 - }, - { - "date": "2018-07-19T00:00:00.000+02:00", - "value": 224.49 - }, - { - "date": "2018-07-20T00:00:00.000+02:00", - "value": 230.49 - }, - { - "date": "2018-07-21T00:00:00.000+02:00", - "value": 220.45 - }, - { - "date": "2018-07-22T00:00:00.000+02:00", - "value": 228.83 - }, - { - "date": "2018-07-23T00:00:00.000+02:00", - "value": 194.61 - }, - { - "date": "2018-07-24T00:00:00.000+02:00", - "value": 234 - }, - { - "date": "2018-07-25T00:00:00.000+02:00", - "value": 237.11 - }, - { - "date": "2018-07-26T00:00:00.000+02:00", - "value": 230.89 - }, - { - "date": "2018-07-27T00:00:00.000+02:00", - "value": 207.7 - }, - { - "date": "2018-07-28T00:00:00.000+02:00", - "value": 200.38 - }, - { - "date": "2018-07-29T00:00:00.000+02:00", - "value": 224.47 - }, - { - "date": "2018-07-30T00:00:00.000+02:00", - "value": 230.87 - }, - { - "date": "2018-07-31T00:00:00.000+02:00", - "value": 213.52 - }, - { - "date": "2018-08-01T00:00:00.000+02:00", - "value": 188.64 - }, - { - "date": "2018-08-02T00:00:00.000+02:00", - "value": 221.18 - } -] \ No newline at end of file diff --git a/test/services/_/consumptionHalfHourlyDataFormatterMock.json b/test/services/_/consumptionHalfHourlyDataFormatterMock.json deleted file mode 100644 index 55ae0be02a01292144d534f4e3a77c3236b52512..0000000000000000000000000000000000000000 --- a/test/services/_/consumptionHalfHourlyDataFormatterMock.json +++ /dev/null @@ -1,194 +0,0 @@ -[ - { - "date": "2018-06-20T00:00:00.000+02:00", - "value": 1.3 - }, - { - "date": "2018-06-20T00:30:00.000+02:00", - "value": 3.58 - }, - { - "date": "2018-06-20T01:00:00.000+02:00", - "value": 5.71 - }, - { - "date": "2018-06-20T01:30:00.000+02:00", - "value": 2.56 - }, - { - "date": "2018-06-20T02:00:00.000+02:00", - "value": 1.52 - }, - { - "date": "2018-06-20T02:30:00.000+02:00", - "value": 2.16 - }, - { - "date": "2018-06-20T03:00:00.000+02:00", - "value": 2.19 - }, - { - "date": "2018-06-20T03:30:00.000+02:00", - "value": 4.21 - }, - { - "date": "2018-06-20T04:00:00.000+02:00", - "value": 3.7 - }, - { - "date": "2018-06-20T04:30:00.000+02:00", - "value": 5.93 - }, - { - "date": "2018-06-20T05:00:00.000+02:00", - "value": 6.24 - }, - { - "date": "2018-06-20T05:30:00.000+02:00", - "value": 6.45 - }, - { - "date": "2018-06-20T06:00:00.000+02:00", - "value": 6.87 - }, - { - "date": "2018-06-20T06:30:00.000+02:00", - "value": 5.83 - }, - { - "date": "2018-06-20T07:00:00.000+02:00", - "value": 6.45 - }, - { - "date": "2018-06-20T07:30:00.000+02:00", - "value": 8.67 - }, - { - "date": "2018-06-20T08:00:00.000+02:00", - "value": 7.79 - }, - { - "date": "2018-06-20T08:30:00.000+02:00", - "value": 5.34 - }, - { - "date": "2018-06-20T09:00:00.000+02:00", - "value": 8.78 - }, - { - "date": "2018-06-20T09:30:00.000+02:00", - "value": 2.75 - }, - { - "date": "2018-06-20T10:00:00.000+02:00", - "value": 3.32 - }, - { - "date": "2018-06-20T10:30:00.000+02:00", - "value": 3.56 - }, - { - "date": "2018-06-20T11:00:00.000+02:00", - "value": 5.25 - }, - { - "date": "2018-06-20T11:30:00.000+02:00", - "value": 9.85 - }, - { - "date": "2018-06-20T12:00:00.000+02:00", - "value": 5.74 - }, - { - "date": "2018-06-20T12:30:00.000+02:00", - "value": 6.45 - }, - { - "date": "2018-06-20T13:00:00.000+02:00", - "value": 2.71 - }, - { - "date": "2018-06-20T13:30:00.000+02:00", - "value": 0.65 - }, - { - "date": "2018-06-20T14:00:00.000+02:00", - "value": 5.09 - }, - { - "date": "2018-06-20T14:30:00.000+02:00", - "value": 4.2 - }, - { - "date": "2018-06-20T15:00:00.000+02:00", - "value": 3.59 - }, - { - "date": "2018-06-20T15:30:00.000+02:00", - "value": 3.62 - }, - { - "date": "2018-06-20T16:00:00.000+02:00", - "value": 2.09 - }, - { - "date": "2018-06-20T16:30:00.000+02:00", - "value": 8.92 - }, - { - "date": "2018-06-20T17:00:00.000+02:00", - "value": 6.61 - }, - { - "date": "2018-06-20T17:30:00.000+02:00", - "value": 7.75 - }, - { - "date": "2018-06-20T18:00:00.000+02:00", - "value": 0.3 - }, - { - "date": "2018-06-20T18:30:00.000+02:00", - "value": 2.56 - }, - { - "date": "2018-06-20T19:00:00.000+02:00", - "value": 5.72 - }, - { - "date": "2018-06-20T19:30:00.000+02:00", - "value": 5.11 - }, - { - "date": "2018-06-20T20:00:00.000+02:00", - "value": 4.42 - }, - { - "date": "2018-06-20T20:30:00.000+02:00", - "value": 0.4 - }, - { - "date": "2018-06-20T21:00:00.000+02:00", - "value": 1.58 - }, - { - "date": "2018-06-20T21:30:00.000+02:00", - "value": 7.03 - }, - { - "date": "2018-06-20T22:00:00.000+02:00", - "value": 4.31 - }, - { - "date": "2018-06-20T22:30:00.000+02:00", - "value": 1.09 - }, - { - "date": "2018-06-20T23:00:00.000+02:00", - "value": 1.48 - }, - { - "date": "2018-06-20T23:30:00.000+02:00", - "value": 1.9 - } -] \ No newline at end of file diff --git a/test/services/_/triggerDataMock.json b/test/services/_/triggerDataMock.json deleted file mode 100644 index 0c699826f6b9af0d58046171168db069592a26a5..0000000000000000000000000000000000000000 --- a/test/services/_/triggerDataMock.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "type": "@cron", - "id": "70b2fcc31ae9adb95c3ce0a344001941", - "attributes": { - "_id": "70b2fcc31ae9adb95c3ce0a344001941", - "_rev": "1-d84be387304c880015172c1e541c6f2b", - "domain": "cozy.tools:8080", - "prefix": "cozy35ba44d2d1749e6f21646edce51e7190", - "type": "@cron", - "worker": "konnector", - "arguments": "0 47 0 * * *", - "debounce": "", - "options": null, - "message": { - "account": "70b2fcc31ae9adb95c3ce0a34400185c", - "konnector": "enedis-scraping-connector" - }, - "current_state": { - "trigger_id": "70b2fcc31ae9adb95c3ce0a344001941", - "status": "errored", - "last_execution": "2020-01-16T15:53:50.2310024Z", - "last_executed_job_id": "70b2fcc31ae9adb95c3ce0a34400204a", - "last_failure": "2020-01-16T15:53:50.2310024Z", - "last_failed_job_id": "70b2fcc31ae9adb95c3ce0a34400204a", - "last_error": "fork/exec : no such file or directory", - "last_manual_execution": "2020-01-16T15:53:50.2310024Z", - "last_manual_job_id": "70b2fcc31ae9adb95c3ce0a34400204a" - }, - "cozyMetadata": { - "doctypeVersion": "1", - "metadataVersion": 1, - "createdAt": "2020-01-16T15:53:50.0323739Z", - "createdByApp": "ecolyo", - "updatedAt": "2020-01-16T15:53:50.0323739Z" - } - }, - "meta": {}, - "links": { - "self": "/jobs/triggers/70b2fcc31ae9adb95c3ce0a344001941" - }, - "_id": "70b2fcc31ae9adb95c3ce0a344001941", - "_type": "io.cozy.triggers", - "_rev": "1-d84be387304c880015172c1e541c6f2b", - "domain": "cozy.tools:8080", - "prefix": "cozy35ba44d2d1749e6f21646edce51e7190", - "worker": "konnector", - "arguments": "0 47 0 * * *", - "debounce": "", - "options": null, - "message": { - "account": "70b2fcc31ae9adb95c3ce0a34400185c", - "konnector": "enedis-scraping-connector" - }, - "current_state": { - "trigger_id": "70b2fcc31ae9adb95c3ce0a344001941", - "status": "errored", - "last_execution": "2020-01-16T15:53:50.2310024Z", - "last_executed_job_id": "70b2fcc31ae9adb95c3ce0a34400204a", - "last_failure": "2020-01-16T15:53:50.2310024Z", - "last_failed_job_id": "70b2fcc31ae9adb95c3ce0a34400204a", - "last_error": "fork/exec : no such file or directory", - "last_manual_execution": "2020-01-16T15:53:50.2310024Z", - "last_manual_job_id": "70b2fcc31ae9adb95c3ce0a34400204a" - }, - "cozyMetadata": { - "doctypeVersion": "1", - "metadataVersion": 1, - "createdAt": "2020-01-16T15:53:50.0323739Z", - "createdByApp": "ecolyo", - "updatedAt": "2020-01-16T15:53:50.0323739Z" - } -} diff --git a/tsconfig.json b/tsconfig.json index 23eca91b15f1fd1d72067b1b6882fb92af925a47..e35a29797c481d1dcb9c165f4c85d81c4b1bd5f3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,6 +20,6 @@ ] }, "include": [ - "src/**/*" + "src/**/*", "test/**/*" ] }