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