Pass tests

This commit is contained in:
Sebastian Rindom
2020-06-29 17:17:16 +02:00
parent 25776ab940
commit ae372de305
4 changed files with 4 additions and 61 deletions
@@ -1,33 +0,0 @@
import { IdMap } from "medusa-test-utils"
import { request } from "../../../../../helpers/test-request"
import { CartServiceMock } from "../../../../../services/__mocks__/cart"
describe("POST /store/carts/:id/shipping-options", () => {
describe("creates shipping options", () => {
let subject
beforeAll(async () => {
subject = await request(
"POST",
`/store/carts/${IdMap.getId("emptyCart")}/shipping-options`
)
})
afterAll(() => {
jest.clearAllMocks()
})
it("calls Cart service set shipping options", () => {
expect(CartServiceMock.setShippingOptions).toHaveBeenCalledTimes(1)
})
it("returns 200", () => {
expect(subject.status).toEqual(200)
})
it("returns the cart", () => {
expect(subject.body.cart._id).toEqual(IdMap.getId("emptyCart"))
expect(subject.body.cart.decorated).toEqual(true)
})
})
})
@@ -1,17 +0,0 @@
export default async (req, res) => {
const { id } = req.params
try {
const cartService = req.scope.resolve("cartService")
// Ask the cart service to set payment sessions
await cartService.setShippingOptions(id)
// return the updated cart
let cart = await cartService.retrieve(id)
cart = await cartService.decorate(cart)
res.status(200).json({ cart })
} catch (err) {
throw err
}
}