import { Id, Product, productPriceFor } from "../product"; import uuid from "react-native-uuid" describe("Product tests", () => { it(`Length product gives correct price for a shorter length`, () => { const standard : Product = { id: uuid.v4().valueOf() as Id, dimensions: { l: 5, u: "ft", }, type: "lumber", pricePerUnit: 10, }; const comparison = productPriceFor(standard, { l: 2, u: "feet" }); expect(comparison).toEqual(4); }); it(`Length product gives correct price for a longer length`, () => { const standard : Product = { id: uuid.v4().valueOf() as Id, dimensions: { l: 5, u: "ft", }, type: "lumber", pricePerUnit: 10, }; const comparison = productPriceFor(standard, { l: 10, u: "feet" }); expect(comparison).toEqual(20); }); it(`Length product gives correct price if different units`, () => { const standard : Product = { id: uuid.v4().valueOf() as Id, dimensions: { l: 12, u: "in", }, type: "lumber", pricePerUnit: 1, }; const comparison = productPriceFor(standard, { l: 2, u: "feet" }); expect(comparison).toBeCloseTo(2, 1); }); });