PliWould/lib/__tests__/product-test.ts

24 lines
808 B
TypeScript
Raw Normal View History

import { length } from "enheter";
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`, () => {
2024-06-27 23:31:59 +02:00
const standard = new Product(20, length("foot", 4));
const comparison = standard.priceFor(length("foot", 2));
2024-06-27 23:31:59 +02:00
expect(comparison).toEqual(10);
});
it(`Length product gives correct price for a longer length`, () => {
2024-06-27 23:31:59 +02:00
const standard = new Product(20, length("foot", 4));
const comparison = standard.priceFor(length("foot", 8));
2024-06-27 23:31:59 +02:00
expect(comparison).toEqual(40);
});
it(`Length product gives correct price if different units`, () => {
2024-06-27 23:31:59 +02:00
const standard = new Product(10, length("foot", 1));
const comparison = standard.priceFor(length("inch", 24));
2024-06-27 23:31:59 +02:00
expect(comparison).toEqual(20);
});
});