Skip to content

Commit

Permalink
fix startegy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
olivermrbl committed Nov 29, 2023
1 parent 0e33f0a commit cc261a9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion integration-tests/api/__tests__/store/cart/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe("/store/carts", () => {
beforeAll(async () => {
const cwd = path.resolve(path.join(__dirname, "..", "..", ".."))
dbConnection = await initDb({ cwd })
medusaProcess = await setupServer({ cwd, verbose: true })
medusaProcess = await setupServer({ cwd })
})

afterAll(async () => {
Expand Down
8 changes: 4 additions & 4 deletions integration-tests/api/__tests__/store/orders.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,20 +501,20 @@ describe("/store/carts", () => {
})
)

const responseFail = await api
const successRes = await api
.post(`/store/carts/${cartId}/complete`)
.catch((err) => {
return err.response
})

expect(responseFail.status).toEqual(200)
expect(responseFail.data.data).toEqual(
expect(successRes.status).toEqual(200)
expect(successRes.data.data).toEqual(
expect.objectContaining({
cart_id: cartId,
id: expect.any(String),
})
)
expect(responseFail.data.type).toEqual("order")
expect(successRes.data.type).toEqual("order")
})
})

Expand Down
14 changes: 10 additions & 4 deletions packages/medusa/src/strategies/__tests__/cart-completion.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,16 @@ const toTest = [
idempotency_key: "ikey",
recovery_point: "started",
},
validate: function (value) {
validate: function (value, { orderServiceMock }) {
expect(value.response_code).toEqual(200)
expect(value.response_body.data).toEqual(
expect.objectContaining({ id: "test-cart" })
)
expect(
orderServiceMock.retrieveByCartIdWithTotals
).toHaveBeenCalledTimes(1)
expect(
orderServiceMock.retrieveByCartIdWithTotals
).toHaveBeenCalledWith("test-cart", {
relations: ["shipping_address", "items", "payments"],
})
},
},
],
Expand Down Expand Up @@ -202,6 +207,7 @@ describe("CartCompletionStrategy", () => {
createFromCart: jest.fn(() => Promise.resolve(cart)),
retrieve: jest.fn(() => Promise.resolve({})),
retrieveWithTotals: jest.fn(() => Promise.resolve({})),
retrieveByCartIdWithTotals: jest.fn(() => Promise.resolve({})),
newTotalsService: newTotalsServiceMock,
}
const swapServiceMock = {
Expand Down

0 comments on commit cc261a9

Please sign in to comment.