Feat(order): return reason and transaction methods (#7303)
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
import { Modules } from "@medusajs/modules-sdk"
|
||||
import { IOrderModuleService } from "@medusajs/types"
|
||||
import { SuiteOptions, moduleIntegrationTestRunner } from "medusa-test-utils"
|
||||
|
||||
jest.setTimeout(100000)
|
||||
|
||||
moduleIntegrationTestRunner({
|
||||
moduleName: Modules.ORDER,
|
||||
testSuite: ({ service }: SuiteOptions<IOrderModuleService>) => {
|
||||
describe("Order Module Service - Returns", () => {
|
||||
it("should create return reasons", async function () {
|
||||
const reason = await service.createReturnReasons({
|
||||
value: "test",
|
||||
label: "label test",
|
||||
description: "description test",
|
||||
})
|
||||
|
||||
expect(reason).toEqual({
|
||||
id: expect.any(String),
|
||||
value: "test",
|
||||
label: "label test",
|
||||
description: "description test",
|
||||
return_reason_children: [],
|
||||
metadata: null,
|
||||
deleted_at: null,
|
||||
})
|
||||
})
|
||||
|
||||
it("should create return reasons with parent", async function () {
|
||||
const reason = await service.createReturnReasons({
|
||||
value: "test",
|
||||
label: "label test",
|
||||
description: "description test",
|
||||
})
|
||||
|
||||
const reason2 = await service.createReturnReasons({
|
||||
value: "test 2.0",
|
||||
label: "child",
|
||||
parent_return_reason_id: reason.id,
|
||||
})
|
||||
const reason3 = await service.createReturnReasons({
|
||||
value: "test 3.0",
|
||||
label: "child 3",
|
||||
parent_return_reason_id: reason.id,
|
||||
})
|
||||
|
||||
const getChild = await service.retrieveReturnReason(reason2.id, {
|
||||
relations: ["parent_return_reason"],
|
||||
})
|
||||
expect(getChild).toEqual(
|
||||
expect.objectContaining({
|
||||
id: reason2.id,
|
||||
value: "test 2.0",
|
||||
label: "child",
|
||||
parent_return_reason_id: reason.id,
|
||||
parent_return_reason: expect.objectContaining({
|
||||
id: reason.id,
|
||||
value: "test",
|
||||
label: "label test",
|
||||
description: "description test",
|
||||
parent_return_reason_id: null,
|
||||
}),
|
||||
})
|
||||
)
|
||||
|
||||
const getParent = await service.retrieveReturnReason(reason.id, {
|
||||
relations: ["return_reason_children"],
|
||||
})
|
||||
expect(getParent).toEqual(
|
||||
expect.objectContaining({
|
||||
id: reason.id,
|
||||
value: "test",
|
||||
label: "label test",
|
||||
description: "description test",
|
||||
return_reason_children: [
|
||||
expect.objectContaining({
|
||||
id: reason2.id,
|
||||
value: "test 2.0",
|
||||
label: "child",
|
||||
parent_return_reason_id: reason.id,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: reason3.id,
|
||||
value: "test 3.0",
|
||||
label: "child 3",
|
||||
parent_return_reason_id: reason.id,
|
||||
}),
|
||||
],
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user