removed unused imports
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { IdMap } from "medusa-test-utils"
|
||||
import { request } from "../../../../../helpers/test-request"
|
||||
import { OrderServiceMock } from "../../../../../services/__mocks__/order"
|
||||
import { EventBusServiceMock } from "../../../../../services/__mocks__/event-bus"
|
||||
|
||||
describe("POST /admin/orders/:id/fulfillment", () => {
|
||||
describe("successfully fulfills an order", () => {
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { IdMap } from "medusa-test-utils"
|
||||
import { request } from "../../../../../helpers/test-request"
|
||||
import { orders } from "../../../../../services/__mocks__/order"
|
||||
import { ReturnService } from "../../../../../services/__mocks__/return"
|
||||
import { EventBusServiceMock } from "../../../../../services/__mocks__/event-bus"
|
||||
import { OrderServiceMock } from "../../../../../services/__mocks__/order"
|
||||
|
||||
describe("POST /admin/orders/:id/return", () => {
|
||||
describe("successfully returns full order", () => {
|
||||
@@ -244,11 +242,14 @@ describe("POST /admin/orders/:id/return", () => {
|
||||
},
|
||||
}
|
||||
)
|
||||
expect(EventBusServiceMock.emit).toHaveBeenCalledWith(expect.any(String),{
|
||||
id: expect.any(String),
|
||||
no_notification: false,
|
||||
return_id: expect.any(String)
|
||||
})
|
||||
expect(EventBusServiceMock.emit).toHaveBeenCalledWith(
|
||||
expect.any(String),
|
||||
{
|
||||
id: expect.any(String),
|
||||
no_notification: false,
|
||||
return_id: expect.any(String),
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -280,11 +281,14 @@ describe("POST /admin/orders/:id/return", () => {
|
||||
}
|
||||
)
|
||||
|
||||
expect(EventBusServiceMock.emit).toHaveBeenCalledWith(expect.any(String),{
|
||||
id: expect.any(String),
|
||||
no_notification: true,
|
||||
return_id: expect.any(String)
|
||||
})
|
||||
expect(EventBusServiceMock.emit).toHaveBeenCalledWith(
|
||||
expect.any(String),
|
||||
{
|
||||
id: expect.any(String),
|
||||
no_notification: true,
|
||||
return_id: expect.any(String),
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import _ from "lodash"
|
||||
import { IdMap, MockRepository, MockManager } from "medusa-test-utils"
|
||||
import { MockRepository, MockManager } from "medusa-test-utils"
|
||||
import { EventBusServiceMock } from "../__mocks__/event-bus"
|
||||
import DraftOrderService from "../draft-order"
|
||||
|
||||
|
||||
const eventBusService = {
|
||||
emit: jest.fn(),
|
||||
withTransaction: function() {
|
||||
@@ -209,7 +208,6 @@ describe("DraftOrderService", () => {
|
||||
})
|
||||
|
||||
describe("update", () => {
|
||||
|
||||
const testOrder = {
|
||||
region_id: "test-region",
|
||||
shipping_address_id: "test-shipping",
|
||||
@@ -226,7 +224,7 @@ describe("DraftOrderService", () => {
|
||||
|
||||
const completedOrder = {
|
||||
status: "completed",
|
||||
...testOrder
|
||||
...testOrder,
|
||||
}
|
||||
|
||||
const draftOrderRepository = MockRepository({
|
||||
@@ -237,17 +235,16 @@ describe("DraftOrderService", () => {
|
||||
id: "test-draft-order",
|
||||
...d,
|
||||
}),
|
||||
findOne: (q) => {
|
||||
findOne: q => {
|
||||
switch (q.where.id) {
|
||||
case "completed":
|
||||
return Promise.resolve(completedOrder)
|
||||
default:
|
||||
return Promise.resolve(testOrder)
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
const draftOrderService = new DraftOrderService({
|
||||
manager: MockManager,
|
||||
regionService: undefined,
|
||||
@@ -263,7 +260,7 @@ describe("DraftOrderService", () => {
|
||||
beforeEach(async () => {
|
||||
jest.clearAllMocks()
|
||||
})
|
||||
|
||||
|
||||
it("calls draftOrder model functions", async () => {
|
||||
await draftOrderService.update("test-draft-order", {
|
||||
no_notification_order: true,
|
||||
@@ -274,26 +271,28 @@ describe("DraftOrderService", () => {
|
||||
no_notification_order: true,
|
||||
billing_address_id: "test-billing",
|
||||
customer_id: "test-customer",
|
||||
items: [ {
|
||||
metadata: {},
|
||||
quantity: 2,
|
||||
variant_id: "test-variant"
|
||||
}],
|
||||
items: [
|
||||
{
|
||||
metadata: {},
|
||||
quantity: 2,
|
||||
variant_id: "test-variant",
|
||||
},
|
||||
],
|
||||
region_id: "test-region",
|
||||
shipping_address_id: "test-shipping",
|
||||
shipping_methods: [{
|
||||
data: {},
|
||||
option_id: "test-option"
|
||||
}]
|
||||
shipping_methods: [
|
||||
{
|
||||
data: {},
|
||||
option_id: "test-option",
|
||||
},
|
||||
],
|
||||
})
|
||||
})
|
||||
|
||||
it("fails to update draftOrder when already complete", async () => {
|
||||
await expect(
|
||||
draftOrderService.update("completed", {})
|
||||
).rejects.toThrow("Can't update a draft order which is complete")
|
||||
|
||||
await expect(draftOrderService.update("completed", {})).rejects.toThrow(
|
||||
"Can't update a draft order which is complete"
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { IdMap, MockManager, MockRepository } from "medusa-test-utils"
|
||||
import OrderService from "../order"
|
||||
import { EventBusServiceMock } from "../__mocks__/event-bus"
|
||||
|
||||
describe("OrderService", () => {
|
||||
const totalsService = {
|
||||
|
||||
Reference in New Issue
Block a user