Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add blend pricing tests #12

Merged
merged 14 commits into from
Sep 25, 2024
26 changes: 26 additions & 0 deletions projects/planner/src/app/shared/blend-pricing.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { TestBed } from '@angular/core/testing';
import { BlendPricingService } from './blend-pricing.service';
import { GasBlenderService } from './gas-blender.service';
import { UnitConversion } from './UnitConversion';

describe('BlendPricingService', () => {
let sut: BlendPricingService;

beforeEach(() => {
jirkapok marked this conversation as resolved.
Show resolved Hide resolved
TestBed.configureTestingModule({
providers: [BlendPricingService, GasBlenderService, UnitConversion]
});

sut = TestBed.inject(BlendPricingService);
});

it('should calculate prices based on unit price and amount of gases', () => {

sut.calculate();

expect(sut.o2Price).toBe(0);
jirkapok marked this conversation as resolved.
Show resolved Hide resolved
expect(sut.hePrice).toBe(0);
expect(sut.topMixPrice).toBe(0);
expect(sut.totalPrice).toBe(0);
});
});
4 changes: 1 addition & 3 deletions projects/planner/src/app/shared/blend-pricing.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Injectable } from '@angular/core';
import {
BlendPricing
} from 'scuba-physics';
import {BlendPricing} from 'scuba-physics';
jirkapok marked this conversation as resolved.
Show resolved Hide resolved
import { GasBlenderService } from './gas-blender.service';

@Injectable()
Expand Down
27 changes: 27 additions & 0 deletions projects/scuba-physics/src/lib/blendPricing.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { BlendPricing, BlendCosts, BlendPrice } from './blendPricing';

describe('BlendPricing', () => {
/** we will not test negative numbers */
josefbogar marked this conversation as resolved.
Show resolved Hide resolved
it('should calculate prices according declared amount and price of gas', () => {

const costs: BlendCosts = {
addO2: 2,
o2UnitPrice: 5,
addHe: 3,
heUnitPrice: 8,
addTop: 4,
topMixUnitPrice: 10
};

const expected: BlendPrice = {
o2Price: 10,
hePrice: 24,
topMixPrice: 40,
totalPrice: 74
};

const result = BlendPricing.price(costs);

expect(result).toEqual(expected);
});
});