Skip to content
Snippets Groups Projects
Commit bc0b9a70 authored by Yoan VALLET's avatar Yoan VALLET
Browse files

feat: create mock for client

parent 5ece0f7e
Branches
Tags
1 merge request!139Features/unit tests
import { Client } from 'cozy-client'
const mockClient = ({
query: jest.fn(),
create: jest.fn(),
save: jest.fn(),
destroy: jest.fn(),
collection: jest.fn().mockReturnValue({
create: jest.fn(),
}),
getStackClient: jest.fn().mockReturnValue({
fetchJSON: jest.fn(),
}),
} as unknown) as jest.Mocked<Client>
export default mockClient
import { Client, QueryResult } from 'cozy-client' import { QueryResult } from 'cozy-client'
import { AccountAuthData, Konnector, Account } from 'models' import { AccountAuthData, Account } from 'models'
import mockClient from './__mocks__/client'
import AccountService from './account.service' import AccountService from './account.service'
import accountData from './__mocks__/accountsData.json' import accountData from './__mocks__/accountsData.json'
import konnectorData from './__mocks__/konnectorsData.json' import konnectorData from './__mocks__/konnectorsData.json'
const mockClient = ({
query: jest.fn(),
create: jest.fn(),
save: jest.fn(),
destroy: jest.fn(),
} as unknown) as jest.Mocked<Client>
jest.mock('cozy-harvest-lib/dist/connections/accounts') jest.mock('cozy-harvest-lib/dist/connections/accounts')
import * as harvestLibAccounts from 'cozy-harvest-lib/dist/connections/accounts' import * as harvestLibAccounts from 'cozy-harvest-lib/dist/connections/accounts'
const mockHavestLibAccounts = harvestLibAccounts as jest.Mocked< const mockHavestLibAccounts = harvestLibAccounts as jest.Mocked<
......
import { Client, QueryResult } from 'cozy-client' import { QueryResult } from 'cozy-client'
import { Ecogesture } from 'models' import { Ecogesture } from 'models'
import EcogestureService from './ecogesture.service' import EcogestureService from './ecogesture.service'
import mockClient from './__mocks__/client'
import ecogesturesData from './__mocks__/ecogesturesData.json' import ecogesturesData from './__mocks__/ecogesturesData.json'
const mockClient = ({
query: jest.fn(),
create: jest.fn(),
destroy: jest.fn(),
} as unknown) as jest.Mocked<Client>
describe('Ecogesture service', () => { describe('Ecogesture service', () => {
const ecogestureService = new EcogestureService(mockClient) const ecogestureService = new EcogestureService(mockClient)
......
import PerformanceIndicatorService from './performanceIndicator.service' import PerformanceIndicatorService from './performanceIndicator.service'
import { PerformanceIndicator } from 'models' import { PerformanceIndicator } from 'models'
import { DateTime } from 'luxon'
import { FluidType } from 'enum/fluid.enum'
describe('performanceIndicator service', () => { describe('performanceIndicator service', () => {
describe('aggregatePerformanceIndicators method', () => { describe('aggregatePerformanceIndicators method', () => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment