Updates method to reflect correct payment provider API
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
import { IdMap } from "medusa-test-utils"
|
||||
|
||||
export const TotalsServiceMock = {
|
||||
getTotal: jest.fn().mockImplementation(cart => {
|
||||
if (cart.total) {
|
||||
return cart.total
|
||||
}
|
||||
return 0
|
||||
}),
|
||||
getSubtotal: jest.fn().mockImplementation(cart => {
|
||||
if (cart.subtotal) {
|
||||
return cart.subtotal
|
||||
|
||||
@@ -23,4 +23,60 @@ describe("ProductService", () => {
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe("createSession", () => {
|
||||
const createSession = jest.fn().mockReturnValue(Promise.resolve())
|
||||
const container = {
|
||||
totalsService: TotalsService,
|
||||
pp_default_provider: {
|
||||
createSession
|
||||
}
|
||||
}
|
||||
|
||||
const providerService = new PaymentProviderService(container)
|
||||
|
||||
it("successfully creates session", () => {
|
||||
await providerService.createSession("default_provider", {
|
||||
total: 100
|
||||
})
|
||||
|
||||
expect(createSession).toBeCalledTimes(1)
|
||||
expect(createSession).toBeCalledWith({
|
||||
total: 100
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("updateSession", () => {
|
||||
const createSession = jest.fn().mockReturnValue(Promise.resolve())
|
||||
const updateSession = jest.fn().mockReturnValue(Promise.resolve())
|
||||
|
||||
const container = {
|
||||
totalsService: TotalsService,
|
||||
pp_default_provider: {
|
||||
createSession,
|
||||
updateSession
|
||||
}
|
||||
}
|
||||
|
||||
const providerService = new PaymentProviderService(container)
|
||||
|
||||
it("successfully creates session", () => {
|
||||
await providerService.createSession({
|
||||
provider_id: "default_provider",
|
||||
data: {
|
||||
id: "1234"
|
||||
}
|
||||
}, {
|
||||
total: 100
|
||||
})
|
||||
|
||||
expect(TotalsService.getTotal).toBeCalledTimes(1)
|
||||
expect(TotalsService.getTotal).toBeCalledWith({
|
||||
total: 100
|
||||
})
|
||||
|
||||
expect
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user