PliWould/lib/__tests__/product-test.ts
2024-06-27 14:31:59 -07:00

24 lines
808 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, length("foot", 4));
const comparison = standard.priceFor(length("foot", 2));
expect(comparison).toEqual(10);
});
it(`Length product gives correct price for a longer length`, () => {
const standard = new Product(20, length("foot", 4));
const comparison = standard.priceFor(length("foot", 8));
expect(comparison).toEqual(40);
});
it(`Length product gives correct price if different units`, () => {
const standard = new Product(10, length("foot", 1));
const comparison = standard.priceFor(length("inch", 24));
expect(comparison).toEqual(20);
});
});