Skip to content
Snippets Groups Projects
Commit dd1388e6 authored by Hugo NOUTS's avatar Hugo NOUTS
Browse files

Merge branch 'feat/US556-round-load-converter-to-0.01e' into 'feat/1.4.0'

fix(loadConverter): Loads below 0.01cts now equal 0.01cts

See merge request web-et-numerique/llle_project/ecolyo!427
parents 97ad0549 e106f5bc
No related branches found
No related tags found
3 merge requests!435WIP: 1.4.0,!427fix(loadConverter): Loads below 0.01cts now equal 0.01cts,!421feat(chore): 1.4.0
......@@ -26,5 +26,11 @@ describe('Converter service', () => {
const result = converterService.LoadToEuro(20, FluidType.WATER)
expect(result).toEqual(expectedConversion)
})
it('shoud return 0.01 if the load is below 0.01 euro', () => {
const expectedConversion = 0.01
const result = converterService.LoadToEuro(0.002, FluidType.WATER)
expect(result).toEqual(expectedConversion)
})
})
})
......@@ -10,8 +10,11 @@ export default class ConverterService {
}
public LoadToEuro(load: number, fluidType: FluidType): number {
const convertedLoad: number =
load * this._fluidConfig[fluidType].coefficient
let convertedLoad: number = load * this._fluidConfig[fluidType].coefficient
if (convertedLoad > 0 && convertedLoad < 0.01) {
convertedLoad = 0.01
}
return convertedLoad
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment