PliWould/lib/__tests__/product-test.ts

22 lines
789 B
TypeScript
Raw Normal View History

2024-06-27 23:31:59 +02:00
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" });
2024-06-27 23:31:59 +02:00
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"});
2024-06-27 23:31:59 +02:00
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);
});
});