2024-06-27 16:06:39 +02:00
|
|
|
import { length } from "enheter";
|
2024-06-27 23:31:59 +02:00
|
|
|
import { Product } from "../product";
|
2024-06-27 16:06:39 +02:00
|
|
|
|
|
|
|
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));
|
2024-06-27 16:06:39 +02:00
|
|
|
const comparison = standard.priceFor(length("foot", 2));
|
2024-06-27 23:31:59 +02:00
|
|
|
expect(comparison).toEqual(10);
|
2024-06-27 16:06:39 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
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));
|
2024-06-27 16:06:39 +02:00
|
|
|
const comparison = standard.priceFor(length("foot", 8));
|
2024-06-27 23:31:59 +02:00
|
|
|
expect(comparison).toEqual(40);
|
2024-06-27 16:06:39 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
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));
|
2024-06-27 16:06:39 +02:00
|
|
|
const comparison = standard.priceFor(length("inch", 24));
|
2024-06-27 23:31:59 +02:00
|
|
|
expect(comparison).toEqual(20);
|
2024-06-27 16:06:39 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|