Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • build
  • build-dev
  • build-test
  • dev
  • lint/testing-libraby-plugin
  • master
  • renovate/copy-webpack-plugin-13.x
  • renovate/couchdb-3.x
  • renovate/cozy-client-49.x
  • renovate/cozy-device-helper-3.x
  • renovate/cozy-flags-4.x
  • renovate/cozy-harvest-lib-32.x
  • renovate/cozy-harvest-lib-9.x
  • renovate/cozy-realtime-5.x
  • renovate/cozy-scripts-8.x
  • renovate/devdependencies-(non-major)
  • renovate/eslint-9.x
  • renovate/eslint-config-prettier-10.x
  • renovate/eslint-plugin-testing-library-7.x
  • renovate/major-react-monorepo
  • renovate/major-react-router-monorepo
  • renovate/major-typescript-eslint-monorepo
  • renovate/react-19.x
  • renovate/react-dom-19.x
  • renovate/react-inspector-6.x
  • renovate/sass-loader-16.x
  • 0.1.0
  • 0.1.1
  • 0.1.2
  • 0.1.6
  • 0.1.7
  • 1.0.2
  • 1.0.3
  • 1.0.5
  • 1.0.6
  • 1.0.7
  • 1.0.8
  • 1.0.9
  • 1.1.0
  • 1.2.0
  • 1.2.1
  • 1.2.4-beta.1
  • V1.11.0
  • v1.10.0
  • v1.10.1
  • v1.10.2
  • v1.12.0
  • v1.12.1
  • v1.2.0
  • v1.2.1
  • v1.2.2
  • v1.2.3
  • v1.2.4
  • v1.2.4-beta.1
  • v1.3.0
  • v1.4.0
  • v1.4.1
  • v1.4.2
  • v1.4.3
  • v1.4.4
  • v1.5.0
  • v1.5.1
  • v1.6.0
  • v1.6.1
  • v1.6.2
  • v1.6.3
  • v1.6.4
  • v1.6.5
  • v1.7.0
  • v1.7.1
  • v1.7.2
  • v1.7.3
  • v1.7.4
  • v1.8.0
  • v1.8.1
  • v1.8.2
  • v1.8.3
  • v1.9.0
  • v1.9.1
  • v1.9.2
  • v1.9.3
  • v1.9.4
  • v2.0.0
  • v2.0.1
  • v2.0.2
  • v2.1.0
  • v2.1.1
  • v2.2.0
  • v2.2.1
  • v2.2.2
  • v2.3.0
  • v2.3.1
  • v2.4.0
  • v2.5.0
  • v2.5.1
  • v2.6.0
  • v2.7.0
  • v2.7.1
  • v2.7.2
  • v2.8.0
  • v3.0.0
  • v3.1.0
  • v3.1.1
103 results

Target

Select target project
  • web-et-numerique/factory/llle_project/ecolyo
1 result
Select Git revision
  • build
  • build-dev
  • build-test
  • dev
  • lint/testing-libraby-plugin
  • master
  • renovate/copy-webpack-plugin-13.x
  • renovate/couchdb-3.x
  • renovate/cozy-client-49.x
  • renovate/cozy-device-helper-3.x
  • renovate/cozy-flags-4.x
  • renovate/cozy-harvest-lib-32.x
  • renovate/cozy-harvest-lib-9.x
  • renovate/cozy-realtime-5.x
  • renovate/cozy-scripts-8.x
  • renovate/devdependencies-(non-major)
  • renovate/eslint-9.x
  • renovate/eslint-config-prettier-10.x
  • renovate/eslint-plugin-testing-library-7.x
  • renovate/major-react-monorepo
  • renovate/major-react-router-monorepo
  • renovate/major-typescript-eslint-monorepo
  • renovate/react-19.x
  • renovate/react-dom-19.x
  • renovate/react-inspector-6.x
  • renovate/sass-loader-16.x
  • 0.1.0
  • 0.1.1
  • 0.1.2
  • 0.1.6
  • 0.1.7
  • 1.0.2
  • 1.0.3
  • 1.0.5
  • 1.0.6
  • 1.0.7
  • 1.0.8
  • 1.0.9
  • 1.1.0
  • 1.2.0
  • 1.2.1
  • 1.2.4-beta.1
  • V1.11.0
  • v1.10.0
  • v1.10.1
  • v1.10.2
  • v1.12.0
  • v1.12.1
  • v1.2.0
  • v1.2.1
  • v1.2.2
  • v1.2.3
  • v1.2.4
  • v1.2.4-beta.1
  • v1.3.0
  • v1.4.0
  • v1.4.1
  • v1.4.2
  • v1.4.3
  • v1.4.4
  • v1.5.0
  • v1.5.1
  • v1.6.0
  • v1.6.1
  • v1.6.2
  • v1.6.3
  • v1.6.4
  • v1.6.5
  • v1.7.0
  • v1.7.1
  • v1.7.2
  • v1.7.3
  • v1.7.4
  • v1.8.0
  • v1.8.1
  • v1.8.2
  • v1.8.3
  • v1.9.0
  • v1.9.1
  • v1.9.2
  • v1.9.3
  • v1.9.4
  • v2.0.0
  • v2.0.1
  • v2.0.2
  • v2.1.0
  • v2.1.1
  • v2.2.0
  • v2.2.1
  • v2.2.2
  • v2.3.0
  • v2.3.1
  • v2.4.0
  • v2.5.0
  • v2.5.1
  • v2.6.0
  • v2.7.0
  • v2.7.1
  • v2.7.2
  • v2.8.0
  • v3.0.0
  • v3.1.0
  • v3.1.1
103 results
Show changes
Showing
with 118 additions and 123 deletions
......@@ -63,7 +63,7 @@ describe('FeedbackModal component', () => {
</Provider>
)
wrapper.find('.btn-highlight').first().simulate('click')
expect(window.open).toBeCalledTimes(1)
expect(window.open).toHaveBeenCalledTimes(1)
expect(global.open).toHaveBeenCalledWith(`${__SAU_LINK__}?version=0.0.0`)
})
})
......
......@@ -77,9 +77,9 @@ describe('TimeStepSelector component', () => {
</Provider>
)
wrapper.find('#day').first().simulate('click')
expect(setCurrentTimeStepSpy).toBeCalledTimes(1)
expect(setCurrentTimeStepSpy).toHaveBeenCalledTimes(1)
expect(setCurrentTimeStepSpy).toHaveBeenCalledWith(TimeStep.DAY)
expect(setCurrentIndexSpy).toBeCalledTimes(1)
expect(setCurrentIndexSpy).toHaveBeenCalledTimes(1)
})
it('should go to todays day with timestep week', () => {
const store = createMockEcolyoStore({
......@@ -96,9 +96,9 @@ describe('TimeStepSelector component', () => {
</Provider>
)
wrapper.find(Button).first().simulate('click')
expect(setCurrentTimeStepSpy).toBeCalledTimes(1)
expect(setCurrentTimeStepSpy).toHaveBeenCalledTimes(1)
expect(setCurrentTimeStepSpy).toHaveBeenCalledWith(TimeStep.WEEK)
expect(setCurrentIndexSpy).toBeCalledTimes(2)
expect(setSelectedDateSpy).toBeCalledTimes(1)
expect(setCurrentIndexSpy).toHaveBeenCalledTimes(2)
expect(setSelectedDateSpy).toHaveBeenCalledTimes(1)
})
})
......@@ -26,7 +26,7 @@ describe('exportDoneModal component', () => {
it('should display error message', () => undefined)
it('should close modal ', () => {
it('should close modal', () => {
const wrapper = mount(
<Provider store={store}>
<ExportDoneModal
......
......@@ -28,7 +28,7 @@ describe('ExportLoadingModal component', () => {
expect(toJson(wrapper)).toMatchSnapshot()
})
it('should cancel download ', () => {
it('should cancel download', () => {
const wrapper = mount(
<Provider store={store}>
<ExportLoadingModal
......
......@@ -25,7 +25,7 @@ describe('exportStartModal component', () => {
expect(toJson(wrapper)).toMatchSnapshot()
})
it('should close modal ', () => {
it('should close modal', () => {
const wrapper = mount(
<Provider store={store}>
<ExportStartModal
......
......@@ -42,7 +42,7 @@ describe('ReportOptions component', () => {
</Provider>
)
wrapper.find(Button).first().simulate('click')
expect(updateProfileSpy).toBeCalledTimes(1)
expect(updateProfileSpy).toHaveBeenCalledTimes(1)
expect(updateProfileSpy).toHaveBeenCalledWith({
sendAnalysisNotification: false,
})
......@@ -56,7 +56,7 @@ describe('ReportOptions component', () => {
</Provider>
)
wrapper.find(Button).first().simulate('click')
expect(updateProfileSpy).toBeCalledTimes(1)
expect(updateProfileSpy).toHaveBeenCalledTimes(1)
expect(updateProfileSpy).toHaveBeenCalledWith({
sendAnalysisNotification: true,
})
......@@ -85,7 +85,7 @@ describe('ReportOptions component', () => {
.find('input')
.first()
.simulate('change', { target: { checked: 'true' } })
expect(updateProfileSpy).toBeCalledTimes(1)
expect(updateProfileSpy).toHaveBeenCalledTimes(1)
expect(updateProfileSpy).toHaveBeenCalledWith({
sendConsumptionAlert: true,
})
......
......@@ -80,12 +80,11 @@ describe('QuizCustomQuestionContent component', () => {
</Provider>
)
const answer = questionEntity.answers[0].answerLabel
expect(
wrapper
.find({ type: 'radio' })
.at(0)
.simulate('change', { target: { value: answer } })
)
wrapper
.find({ type: 'radio' })
.at(0)
.simulate('change', { target: { value: answer } })
expect(wrapper.find(Button).exists()).toBeTruthy()
wrapper.find('.btn-secondary-negative').forEach(node => {
node.simulate('click')
......
......@@ -71,7 +71,7 @@ describe('WelcomeModal component', () => {
</Provider>
)
component.find(Button).first().simulate('click')
expect(mockSendMail).toBeCalled()
expect(mockSendMail).toHaveBeenCalled()
expect(updateProfileSpy).toHaveBeenCalledWith({
isFirstConnection: false,
onboarding: {
......@@ -87,7 +87,7 @@ describe('WelcomeModal component', () => {
</Provider>
)
component.find(IconButton).first().simulate('click')
expect(mockSendMail).toBeCalled()
expect(mockSendMail).toHaveBeenCalled()
expect(updateProfileSpy).toHaveBeenCalledWith({
isFirstConnection: false,
onboarding: {
......
......@@ -4,6 +4,7 @@ import { Profile } from 'models'
import { Notes } from 'models/releaseNotes.model'
import { Schema } from 'models/schema.models'
import mockClient from 'tests/__mocks__/client.mock'
import { getError } from 'tests/__mocks__/testUtils'
import * as Migrate from './migration'
import { MIGRATION_RESULT_FAILED } from './migration.data'
import { MigrationService } from './migration.service'
......@@ -47,7 +48,7 @@ describe('Migration service', () => {
]
mockClient.query.mockResolvedValue(mockQueryResult)
await ms.runMigrations(migrations)
expect(migrateSpy).toBeCalledTimes(1)
expect(migrateSpy).toHaveBeenCalledTimes(1)
})
it('should run migrations with one fail', async () => {
......@@ -79,7 +80,7 @@ describe('Migration service', () => {
mockClient.query.mockResolvedValue(mockQueryResult)
await ms.runMigrations(migrations)
expect(migrateSpyOneFail).toBeCalledTimes(2)
expect(migrateSpyOneFail).toHaveBeenCalledTimes(2)
})
it('should not run migrations with two fail', async () => {
......@@ -112,13 +113,10 @@ describe('Migration service', () => {
.spyOn(Migrate, 'migrate')
.mockResolvedValueOnce(result)
.mockResolvedValueOnce(result)
try {
await ms.runMigrations(migrations)
expect(migrateSpyTwoFailsKo).toBeCalledTimes(1)
expect(migrateSpy).toBeCalledTimes(1)
} catch (error) {
expect(error).toEqual(new Error())
}
const error = await getError(async () => ms.runMigrations(migrations))
expect(migrateSpyTwoFailsKo).toHaveBeenCalledTimes(2)
expect(migrateSpy).toHaveBeenCalledTimes(2)
expect(error).toEqual(new Error())
})
it('should skip migrations if schema number is up to date', async () => {
......@@ -145,7 +143,7 @@ describe('Migration service', () => {
mockClient.query.mockResolvedValue(mockQueryResult)
await ms.runMigrations(migrations)
expect(migrateSpy).toBeCalledTimes(0)
expect(migrateSpy).toHaveBeenCalledTimes(0)
})
it('should run 2 migrations properly from a fresh instance and dont show releasenotes', async () => {
const schema: Schema = { _id: '1', version: 0 }
......@@ -182,7 +180,7 @@ describe('Migration service', () => {
mockClient.query.mockResolvedValue(mockQueryResult)
const res = await ms.runMigrations(migrations)
expect(migrateSpy).toBeCalledTimes(2)
expect(migrateSpy).toHaveBeenCalledTimes(2)
expect(res.show).toBeFalsy()
})
})
......@@ -30,13 +30,13 @@ describe('migration logger', () => {
},
}
it('it should return noop', () => {
it('should return noop', () => {
const result: MigrationResult = { type: MIGRATION_RESULT_NOOP, errors: [] }
const reply = migrationLog(migration, result)
expect(reply).toEqual('--- Removing mailToken from profil => NOOP')
})
it('it should return noop', () => {
it('should return Complete', () => {
const result: MigrationResult = {
type: MIGRATION_RESULT_COMPLETE,
errors: [],
......@@ -45,7 +45,7 @@ describe('migration logger', () => {
expect(reply).toEqual('--- Removing mailToken from profil => Complete')
})
it('it should return noop', () => {
it('should return Failed', () => {
const result: MigrationResult = {
type: MIGRATION_RESULT_FAILED,
errors: [],
......@@ -73,7 +73,7 @@ describe('migration', () => {
},
}
it('it should return schema does not exist', async () => {
it('should return schema does not exist', async () => {
const mockQueryResult: QueryResult<Schema[]> = {
data: [],
bookmark: '',
......@@ -94,7 +94,7 @@ describe('migration', () => {
expect(result).toEqual({ type: MIGRATION_RESULT_NOOP, errors: [] })
})
it('it should return migration failed', async () => {
it('should return migration failed', async () => {
const mockQueryResult: QueryResult<Schema[]> = {
data: [],
bookmark: '',
......@@ -120,7 +120,7 @@ describe('migration', () => {
})
})
it('it should return migration complete', async () => {
it('should return migration complete', async () => {
const mockQueryResultWithoutAnySchema: QueryResult<Schema[]> = {
data: [],
bookmark: '',
......@@ -152,7 +152,7 @@ describe('migration', () => {
})
})
it('it should return migration noop', async () => {
it('should return migration noop', async () => {
const migrationTest: Migration = {
baseSchemaVersion: 0,
targetSchemaVersion: 1,
......@@ -197,7 +197,7 @@ describe('migration', () => {
})
describe('migration create', () => {
it('it should return migration complete for creation', async () => {
it('should return migration complete for creation', async () => {
const migrationTestCreate: Migration = {
baseSchemaVersion: 0,
targetSchemaVersion: 1,
......
......@@ -5,6 +5,7 @@ import { Account, AccountAuthData } from 'models'
import { accountsData } from 'tests/__mocks__/accountsData.mock'
import mockClient from 'tests/__mocks__/client.mock'
import { konnectorsData } from 'tests/__mocks__/konnectorsData.mock'
import { getError } from 'tests/__mocks__/testUtils'
import { triggersEnedisData } from 'tests/__mocks__/triggersData.mock'
import AccountService from './account.service'
......@@ -49,11 +50,10 @@ describe('Account service', () => {
it('should throw error when fetchAccount unsuccessfully', async () => {
mockHavestLibAccounts.fetchAccount.mockRejectedValueOnce(new Error())
const mockId = 'io.cozy.konnectors/eglgrandlyon'
try {
await accountService.getAccount(mockId)
} catch (error) {
expect(error).toEqual(new Error('Get account failed'))
}
const error = await getError(async () =>
accountService.getAccount(mockId)
)
expect(error).toEqual(new Error('Get account failed'))
})
})
......@@ -130,11 +130,10 @@ describe('Account service', () => {
it('should throw error when updateAccount unsuccessfully', async () => {
mockHavestLibAccounts.updateAccount.mockRejectedValueOnce(new Error())
try {
await accountService.updateAccount(accountsData[2])
} catch (error) {
expect(error).toEqual(new Error('Update account failed'))
}
const error = await getError(async () =>
accountService.updateAccount(accountsData[2])
)
expect(error).toEqual(new Error('Update account failed'))
})
})
......@@ -147,11 +146,10 @@ describe('Account service', () => {
it('should throw error when destroy unsuccessfully', async () => {
mockHavestLibAccounts.deleteAccount.mockRejectedValueOnce(new Error())
try {
await accountService.deleteAccount(accountsData[2])
} catch (error) {
expect(error).toEqual(new Error('Delete account failed'))
}
const error = await getError(async () =>
accountService.deleteAccount(accountsData[2])
)
expect(error).toEqual(new Error('Delete account failed'))
})
})
......
......@@ -42,6 +42,7 @@ import {
} from 'tests/__mocks__/explorationData.mock'
import { fluidStatusData } from 'tests/__mocks__/fluidStatusData.mock'
import { quizEntity, userQuiz } from 'tests/__mocks__/quizData.mock'
import { getError } from 'tests/__mocks__/testUtils'
import {
userChallengeData,
userChallengeDefault,
......@@ -255,11 +256,10 @@ describe('Challenge service', () => {
}
mockClient.query.mockResolvedValueOnce(mockQueryResult)
mockClient.destroy.mockRejectedValue(new Error())
try {
await challengeService.deleteAllChallengeEntities()
} catch (error) {
expect(error).toEqual(new Error())
}
const error = await getError(async () =>
challengeService.deleteAllChallengeEntities()
)
expect(error).toEqual(new Error())
})
})
......@@ -307,12 +307,11 @@ describe('Challenge service', () => {
expect(result).toEqual(expectedResult)
})
it('should throw an error because create failed', async () => {
mockClient.create.mockRejectedValue(new Error())
try {
await challengeService.initChallengeDuelProgress(userChallengeData[0])
} catch (error) {
expect(error).toEqual(new Error())
}
mockClient.save.mockRejectedValue(new Error())
const error = await getError(async () =>
challengeService.initChallengeDuelProgress(userChallengeData[0])
)
expect(error).toEqual(new Error())
})
})
......@@ -332,11 +331,10 @@ describe('Challenge service', () => {
})
it('should throw an error because create failed', async () => {
mockClient.create.mockRejectedValue(new Error())
try {
await challengeService.startUserChallenge(userChallengeData[0])
} catch (error) {
expect(error).toEqual(new Error())
}
const error = await getError(async () =>
challengeService.startUserChallenge(userChallengeData[0])
)
expect(error).toEqual(new Error())
})
})
......@@ -374,14 +372,15 @@ describe('Challenge service', () => {
)
expect(result).toEqual(userChallengeData[0])
})
it('should throw error when failed to save the updateUserChallenge', () => {
it('should throw error when failed to save the updateUserChallenge', async () => {
mockClient.save.mockRejectedValueOnce(new Error())
expect(
const error = await getError(async () =>
challengeService.updateUserChallenge(
userChallengeData[0],
UserChallengeUpdateFlag.DUEL_START
)
).rejects.toEqual(new Error())
)
expect(error).toEqual(new Error())
})
})
......@@ -486,7 +485,7 @@ describe('Challenge service', () => {
)
expect(result).toEqual({ isDone: true, isWin: true })
})
it('should return isDone = true, isWin = false when userConsumption >= threshold ', async () => {
it('should return isDone = true, isWin = false when userConsumption >= threshold', async () => {
const updatedUserChallenge = {
...userChallenge,
duel: {
......@@ -572,7 +571,7 @@ describe('Challenge service', () => {
expect(result).toEqual({ isDone: true, isWin: true })
})
it('should return isDone = true and isWin = false when all data are available and userConsumption >= threshold ', async () => {
it('should return isDone = true and isWin = false when all data are available and userConsumption >= threshold', async () => {
const updatedUserChallenge = {
...userChallenge,
duel: {
......
......@@ -518,10 +518,8 @@ export default class ChallengeService {
}> {
const consumptionService = new ConsumptionDataManager(this._client)
try {
const dataloads: Dataload[] = await this.getUserChallengeDataload(
userChallenge
)
const userConsumption: number = getRoundFloat(
const dataloads = await this.getUserChallengeDataload(userChallenge)
const userConsumption = getRoundFloat(
consumptionService.calculatePerformanceIndicatorValue(dataloads)
)
const _userChallenge: UserChallenge = {
......@@ -531,11 +529,10 @@ export default class ChallengeService {
userConsumption: userConsumption,
},
}
const updatedUserChallenge: UserChallenge =
await this.updateUserChallenge(
_userChallenge,
UserChallengeUpdateFlag.DUEL_CONSUMPTION
)
const updatedUserChallenge = await this.updateUserChallenge(
_userChallenge,
UserChallengeUpdateFlag.DUEL_CONSUMPTION
)
return { updatedUserChallenge, dataloads }
} catch (error) {
const errorMessage = `Challenge service error on initChallengeDuelProgress: ${JSON.stringify(
......
......@@ -2,6 +2,7 @@ import { DataloadState, FluidType, TimeStep } from 'enums'
import { DateTime } from 'luxon'
import { Dataload, FluidStatus, TimePeriod } from 'models'
import { fluidStatusConnectedData } from 'tests/__mocks__/fluidStatusData.mock'
import { getError } from 'tests/__mocks__/testUtils'
import ConsumptionFormatterService from './consumptionFormatter.service'
const localSpy = jest.spyOn(DateTime, 'local')
......@@ -249,8 +250,8 @@ describe('ConsumptionFormatter service', () => {
)
expect(result).toEqual(mockResult)
})
it('should return an error because of unknown TimeStep', () => {
try {
it('should return an error because of unknown TimeStep', async () => {
const error = await getError(async () =>
consumptionFormatterService.formatGraphData(
mockDataLoad,
mockTimePeriod,
......@@ -258,9 +259,8 @@ describe('ConsumptionFormatter service', () => {
FluidType.ELECTRICITY,
fluidStatus[FluidType.ELECTRICITY]
)
} catch (error) {
expect(error).toEqual(new Error('TimeStep unknown'))
}
)
expect(error).toEqual(new Error('TimeStep unknown'))
})
})
......
......@@ -11,15 +11,15 @@ const mockTimePeriodComparison: TimePeriod = {
startDate: DateTime.fromISO('2020-09-01T00:00:00.000Z', { zone: 'utc' }),
endDate: DateTime.fromISO('2020-09-03T23:59:59.999Z', { zone: 'utc' }),
}
let fluidTypes: FluidType[] = [0, 1, 2]
let allFluids: FluidType[] = [0, 1, 2]
describe('ConsumptionFormatter service', () => {
const consumptionValidatorService = new ConsumptionValidatorService()
describe('formatGraphData method', () => {
describe('ValidateGetGraphData method', () => {
it('should return true for DAY', () => {
const result = consumptionValidatorService.ValidateGetGraphData(
mockTimePeriod,
TimeStep.DAY,
fluidTypes
allFluids
)
expect(result).toBeTruthy()
})
......@@ -27,7 +27,7 @@ describe('ConsumptionFormatter service', () => {
const result = consumptionValidatorService.ValidateGetGraphData(
mockTimePeriod,
TimeStep.DAY,
fluidTypes,
allFluids,
mockTimePeriodComparison
)
expect(result).toBeTruthy()
......@@ -42,12 +42,12 @@ describe('ConsumptionFormatter service', () => {
const result = consumptionValidatorService.ValidateGetGraphData(
mockTimePeriod,
TimeStep.DAY,
fluidTypes,
allFluids,
wrongTimePeriodComparison
)
expect(result).toBeFalsy()
})
it('should return false with comparison Date', () => {
it('should return false with comparison Date for elec', () => {
const wrongTimePeriodComparison: TimePeriod = {
startDate: DateTime.fromISO('2020-09-05T00:00:00.000Z', {
zone: 'utc',
......@@ -81,7 +81,7 @@ describe('ConsumptionFormatter service', () => {
const result = consumptionValidatorService.ValidateGetGraphData(
wrongTimePeriod,
TimeStep.DAY,
fluidTypes
allFluids
)
expect(result).toBeFalsy()
})
......@@ -89,12 +89,12 @@ describe('ConsumptionFormatter service', () => {
const result = consumptionValidatorService.ValidateGetGraphData(
mockTimePeriod,
TimeStep.HALF_AN_HOUR,
fluidTypes
allFluids
)
expect(result).toBeFalsy()
})
it('should return false because of HALF_AN_HOUR and ValidateTimePeriodLength', () => {
fluidTypes = [0] // Only fluid without TimeStep incompatibilty
allFluids = [0] // Only fluid without TimeStep incompatibilty
const mockTimePeriodTooLong: TimePeriod = {
startDate: DateTime.fromISO('2020-10-01T00:00:00.000Z', {
zone: 'utc',
......@@ -104,7 +104,7 @@ describe('ConsumptionFormatter service', () => {
const result = consumptionValidatorService.ValidateGetGraphData(
mockTimePeriodTooLong,
TimeStep.HALF_AN_HOUR,
fluidTypes
allFluids
)
expect(result).toBeFalsy()
})
......@@ -118,7 +118,7 @@ describe('ConsumptionFormatter service', () => {
const result = consumptionValidatorService.ValidateGetGraphData(
mockTimePeriodTooLong,
TimeStep.WEEK,
fluidTypes
allFluids
)
expect(result).toBeFalsy()
})
......@@ -132,7 +132,7 @@ describe('ConsumptionFormatter service', () => {
const result = consumptionValidatorService.ValidateGetGraphData(
mockTimePeriodTooLong,
TimeStep.DAY,
fluidTypes
allFluids
)
expect(result).toBeFalsy()
})
......@@ -146,7 +146,7 @@ describe('ConsumptionFormatter service', () => {
const result = consumptionValidatorService.ValidateGetGraphData(
mockTimePeriodTooLong,
TimeStep.MONTH,
fluidTypes
allFluids
)
expect(result).toBeFalsy()
})
......@@ -160,7 +160,7 @@ describe('ConsumptionFormatter service', () => {
const result = consumptionValidatorService.ValidateGetGraphData(
mockTimePeriodTooLong,
TimeStep.YEAR,
fluidTypes
allFluids
)
expect(result).toBeFalsy()
})
......
......@@ -24,7 +24,8 @@ describe('PartnersInfo service', () => {
res = await customPopupService.getCustomPopup()
expect(true).toBe(false)
} catch (error) {
expect(res).toBe(undefined)
//
}
expect(res).toBe(undefined)
})
})
......@@ -20,7 +20,7 @@ export default class CustomPopupService {
/**
* Get information from backoffice about the status of custom popup
* On success, respond the customPopup
* Else, throw an error
* Else, return undefined
*/
public async getCustomPopup(): Promise<CustomPopup | undefined> {
const env = new EnvironmentService()
......
import { TimeStep } from 'enums'
import { DateTime } from 'luxon'
import { TimePeriod } from 'models'
import { getError } from 'tests/__mocks__/testUtils'
import DateChartService from './dateChart.service'
const localSpy = jest.spyOn(DateTime, 'local')
......@@ -294,12 +295,11 @@ describe('dateChart service', () => {
expect(result).toEqual(expectedTimePeriod)
})
it('should throw error for unknown TimeStep', () => {
try {
it('should throw error for unknown TimeStep', async () => {
const error = await getError(async () =>
dateChartService.defineTimePeriod(refDate, unknownTimeStep, -1)
} catch (error) {
expect(error).toEqual(new Error('TimeStep unknown'))
}
)
expect(error).toEqual(new Error('TimeStep unknown'))
})
})
......@@ -686,18 +686,17 @@ describe('dateChart service', () => {
expect(result).toBe(false)
})
it('should throw error for unknown TimeStep', () => {
it('should throw error for unknown TimeStep', async () => {
const firstDate = DateTime.fromISO('2020-10-31T00:00:00.000Z', {
zone: 'utc',
})
const secondDate = DateTime.fromISO('2020-10-31T00:30:00.000Z', {
zone: 'utc',
})
try {
const error = await getError(async () =>
dateChartService.compareStepDate(unknownTimeStep, firstDate, secondDate)
} catch (error) {
expect(error).toEqual(new Error('TimeStep unknown'))
}
)
expect(error).toEqual(new Error('TimeStep unknown'))
})
})
......
......@@ -14,6 +14,7 @@ import {
fluidStatusConnectedData,
fluidStatusData,
} from 'tests/__mocks__/fluidStatusData.mock'
import { getError } from 'tests/__mocks__/testUtils'
const mockGetPerformanceIndicators = jest.fn()
const mockGetGraphData = jest.fn()
......@@ -87,11 +88,10 @@ describe('Duel service', () => {
}
mockClient.query.mockResolvedValueOnce(mockQueryResult)
mockClient.destroy.mockRejectedValue(new Error())
try {
await duelService.deleteAllDuelEntities()
} catch (error) {
expect(error).toEqual(new Error())
}
const error = await getError(async () =>
duelService.deleteAllDuelEntities()
)
expect(error).toEqual(new Error())
})
})
......
......@@ -12,6 +12,7 @@ import {
mockedEcogesturesData,
} from 'tests/__mocks__/ecogesturesData.mock'
import { mockProfileEcogesture } from 'tests/__mocks__/profileEcogesture.mock'
import { getError } from 'tests/__mocks__/testUtils'
import { hashFile } from 'utils/hash'
import EcogestureService from './ecogesture.service'
......@@ -58,7 +59,7 @@ describe('Ecogesture service', () => {
it('should return true when 3 ecogestures stored', async () => {
mockClient.query.mockResolvedValueOnce(mockQueryResultMockedEcogestures)
const result = await ecogestureService.deleteAllEcogestures()
expect(mockClient.destroy).toBeCalledTimes(3)
expect(mockClient.destroy).toHaveBeenCalledTimes(3)
expect(result).toBe(true)
})
it('should return true when no ecogestures stored', async () => {
......@@ -78,7 +79,7 @@ describe('Ecogesture service', () => {
it('should return true when 3 ecogestures stored', async () => {
mockClient.query.mockResolvedValueOnce(mockQueryResultMockedEcogestures)
const result = await ecogestureService.reinitAllEcogestures()
expect(mockClient.save).toBeCalledTimes(3)
expect(mockClient.save).toHaveBeenCalledTimes(3)
expect(result).toBe(true)
})
it('should return true when no ecogestures stored', async () => {
......@@ -303,7 +304,10 @@ describe('Ecogesture service', () => {
.spyOn(ecogestureService, 'deleteAllEcogestures')
.mockResolvedValue(true)
mockClient.create.mockRejectedValueOnce(new Error())
expect(ecogestureService.initEcogesture('')).rejects.toThrow(new Error())
const error = await getError(async () =>
ecogestureService.initEcogesture('')
)
expect(error).toEqual(new Error())
})
})
})