23 lines
823 B
TypeScript
23 lines
823 B
TypeScript
import { length } from "enheter";
|
|
import { Product } from "../product";
|
|
|
|
describe("Product tests", () => {
|
|
|
|
it(`Length product gives correct price for a shorter length`, () => {
|
|
const standard = new Product(20, { l: 4, u: "feet" });
|
|
const comparison = standard.priceFor({ l: 2, u: "feet" });
|
|
expect(comparison).toEqual(10);
|
|
});
|
|
|
|
it(`Length product gives correct price for a longer length`, () => {
|
|
const standard = new Product(20, {l: 4, u : "feet"});
|
|
const comparison = standard.priceFor({l : 8, u : "feet"});
|
|
expect(comparison).toEqual(40);
|
|
});
|
|
|
|
it(`Length product gives correct price if different units`, () => {
|
|
const standard = new Product(10, {l: 1, u : "feet"});
|
|
const comparison = standard.priceFor({l : 24, u: "inch"});
|
|
expect(comparison).toBeCloseTo(20, 4);
|
|
});
|
|
}); |