Skip to content

Commit

Permalink
feat(order): add support for setPurchaseOrderNumber order update acti…
Browse files Browse the repository at this point in the history
…on (#221)

Add support for `setPurchaseOrderNumber` order update action.
  • Loading branch information
mikedebock authored Oct 2, 2024
1 parent 5e08f8f commit 70fee89
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/green-brooms-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@labdigital/commercetools-mock": minor
---

add support for "setPurchaseOrderNumber" order update action
9 changes: 9 additions & 0 deletions src/repositories/order/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type {
OrderSetDeliveryCustomFieldAction,
OrderSetLocaleAction,
OrderSetOrderNumberAction,
OrderSetPurchaseOrderNumberAction,
OrderSetShippingAddressAction,
OrderSetStoreAction,
OrderTransitionStateAction,
Expand Down Expand Up @@ -227,6 +228,14 @@ export class OrderUpdateHandler
resource.orderNumber = orderNumber;
}

setPurchaseOrderNumber(
context: RepositoryContext,
resource: Writable<Order>,
{ purchaseOrderNumber }: OrderSetPurchaseOrderNumberAction,
) {
resource.purchaseOrderNumber = purchaseOrderNumber;
}

setShippingAddress(
context: RepositoryContext,
resource: Writable<Order>,
Expand Down
16 changes: 16 additions & 0 deletions src/services/order.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,22 @@ describe("Order Update Actions", () => {
expect(response.body.orderNumber).toBe("5000123");
});

test("setPurchaseOrderNumber", async () => {
assert(order, "order not created");

const response = await supertest(ctMock.app)
.post(`/dummy/orders/${order.id}`)
.send({
version: 1,
actions: [
{ action: "setPurchaseOrderNumber", purchaseOrderNumber: "abc123" },
],
});
expect(response.status).toBe(200);
expect(response.body.version).toBe(2);
expect(response.body.purchaseOrderNumber).toBe("abc123");
});

test("changeOrderState", async () => {
assert(order, "order not created");

Expand Down

0 comments on commit 70fee89

Please sign in to comment.