diff --git a/doc/missingTests.md b/doc/missingTests.md index 56f86e74..46f1ce32 100644 --- a/doc/missingTests.md +++ b/doc/missingTests.md @@ -1,7 +1,6 @@ # TODO missing test cases - -* BlendPricing, BlendPricingService, GasBlenderComponent +* GasBlenderComponent * Diver.component.ts: Add tests for rmv and stressRmv save and load * AppSettingsComponent: * Density Precision and Step for imperial units diff --git a/projects/planner/src/app/shared/blend-pricing.service.spec.ts b/projects/planner/src/app/shared/blend-pricing.service.spec.ts index 2a582b8e..479dcff1 100644 --- a/projects/planner/src/app/shared/blend-pricing.service.spec.ts +++ b/projects/planner/src/app/shared/blend-pricing.service.spec.ts @@ -3,19 +3,12 @@ import { GasBlenderService } from './gas-blender.service'; import { BlendPricingService } from './blend-pricing.service'; describe('BlendPricingService', () => { - let sut: BlendPricingService; - let gasBlender: GasBlenderService; - - const createGasBlenderService = (imperialUnits: boolean = false): GasBlenderService => { - const units = new UnitConversion(); - units.imperialUnits = imperialUnits; - return new GasBlenderService(units); - }; + const units = new UnitConversion(); + const gasBlender = new GasBlenderService(units); + const sut = new BlendPricingService(gasBlender); beforeEach(() => { - gasBlender = createGasBlenderService(); - sut = new BlendPricingService(gasBlender); - + units.imperialUnits = false; gasBlender.targetTank.o2 = 25; gasBlender.targetTank.he = 25; gasBlender.calculate(); @@ -34,28 +27,14 @@ describe('BlendPricingService', () => { expect(sut.totalPrice).toBeCloseTo(744.1176470576471, 8); }); - describe('Imperial units', () => { - beforeEach(() => { - gasBlender = createGasBlenderService(true); - sut = new BlendPricingService(gasBlender); - - gasBlender.targetTank.o2 = 25; - gasBlender.targetTank.he = 25; - gasBlender.calculate(); - - sut.o2UnitPrice = 2; - sut.heUnitPrice = 3; - sut.topMixUnitPrice = 4; - }); - - it('Calculates gas prices in imperial units', () => { - sut.calculate(); + it('Calculates gas prices in Imperial units', () => { + units.imperialUnits = true; + sut.calculate(); - expect(sut.o2Price).toBeCloseTo(85.31631629483086, 8); - expect(sut.hePrice).toBeCloseTo(2175.5660659533, 8); - expect(sut.topMixPrice).toBeCloseTo(8531.631631189413, 8); - expect(sut.totalPrice).toBeCloseTo(10792.514013437543, 8); - }); + expect(sut.o2Price).toBeCloseTo(85.31631629483086, 8); + expect(sut.hePrice).toBeCloseTo(2175.5660659533, 8); + expect(sut.topMixPrice).toBeCloseTo(8531.631631189413, 8); + expect(sut.totalPrice).toBeCloseTo(10792.514013437543, 8); }); });