start to refactor components.

This commit is contained in:
Jordan
2024-06-30 19:49:41 -07:00
parent 408a996fe7
commit fb68beb1b3
12 changed files with 421 additions and 300 deletions

View File

@ -20,4 +20,11 @@ describe("Product tests", () => {
const comparison = standard.priceFor({l : 24, u: "inch"});
expect(comparison).toBeCloseTo(20, 4);
});
it("Can convert to/from object", () => {
const standard = new Product(10, {l: 1, u : "feet"});
const obj = standard.asObject;
const back = Product.fromObject(obj);
expect(back).toEqual(standard);
})
});

View File

@ -117,7 +117,7 @@ export class Product {
return {
id: this.id,
pricePerUnit: this.pricePerUnit,
dimensions: this.dimensions,
dimensions: JSON.parse(JSON.stringify(this.dimensions)),
attributes: this.attributes,
}
}