Skip to content

Commit

Permalink
[DOCS-3207] Use consistent Order response schema (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrodewig authored Aug 20, 2024
1 parent 3e8357b commit 4e39ca6
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 263 deletions.
9 changes: 4 additions & 5 deletions __tests__/orders.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ describe("Orders", () => {
"status",
"total",
];
const orderItemFields = ["id", "order", "product", "quantity"];

beforeAll(async () => {
const { products: p, customer: c, orders: o } = await seedTestData();
Expand Down Expand Up @@ -256,18 +255,18 @@ describe("Orders", () => {
.post(`/customers/${customerRes.body.id}/cart/item`)
.send({ productName: product.name, quantity: 1 });
expect(firstResp.status).toEqual(200);
expect(firstResp.body.quantity).toEqual(1);
expect(firstResp.body.items[0].quantity).toEqual(1);
expect(Object.keys(firstResp.body).sort()).toEqual(
orderItemFields.sort()
orderFields.sort()
);
// Update the quantity of the item in the cart.
const secondResp = await req(app)
.post(`/customers/${customerRes.body.id}/cart/item`)
.send({ productName: product.name, quantity: 2 });
expect(secondResp.status).toEqual(200);
expect(secondResp.body.quantity).toEqual(2);
expect(secondResp.body.items[0].quantity).toEqual(2);
expect(Object.keys(secondResp.body).sort()).toEqual(
orderItemFields.sort()
orderFields.sort()
);
});

Expand Down
Loading

0 comments on commit 4e39ca6

Please sign in to comment.