-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(order): add service to get order by line-item for customer
feat(order): add service to list orders for customer on specific year/month chore(order.schema.ts): reformat code for better readability feat(order.schema.ts): add types for OrderFulfillment, OrderRefundLineItem, and OrderRefund
- Loading branch information
1 parent
e548a12
commit d1fb32f
Showing
6 changed files
with
451 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { OrderModel } from "~/functions/order/order.models"; | ||
import { Order } from "~/functions/order/order.types"; | ||
import { orderWithfulfillmentAndRefunds } from "~/functions/webhook/data-ordre-with-fullfilment-and-refunds"; | ||
import { CustomerOrderServiceGet } from "./get"; | ||
require("~/library/jest/mongoose/mongodb.jest"); | ||
|
||
describe("CustomerOrderServiceGet", () => { | ||
it("should return order by line-item for customer", async () => { | ||
const dumbData = Order.parse(orderWithfulfillmentAndRefunds); | ||
const response = await OrderModel.create(dumbData); | ||
|
||
const lineItemId = response.line_items[0].id; | ||
|
||
const customerId = response.line_items[0].properties?.find( | ||
(p) => p.name === "_customerId" | ||
)?.value as number | undefined; | ||
|
||
const order = await CustomerOrderServiceGet({ | ||
customerId: customerId || 0, | ||
lineItemId, | ||
}); | ||
|
||
expect(order.line_items.id).toEqual(lineItemId); | ||
expect(order.fulfillments.length).toBe(1); | ||
expect(order.refunds.length).toBe(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.