Skip to content

Commit

Permalink
Simplified blend-pricing service
Browse files Browse the repository at this point in the history
  • Loading branch information
jirkapok committed Sep 25, 2024
1 parent 584dbdc commit 2c03e7b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 34 deletions.
3 changes: 1 addition & 2 deletions doc/missingTests.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
43 changes: 11 additions & 32 deletions projects/planner/src/app/shared/blend-pricing.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
});
});

0 comments on commit 2c03e7b

Please sign in to comment.