fix: include discount rule in swap retrieval (#682)

This commit is contained in:
Sebastian Rindom
2021-11-03 14:11:27 +01:00
committed by GitHub
parent 49e1dbbd48
commit a5fe1c2e28
4 changed files with 138 additions and 69 deletions

View File

@@ -72,6 +72,36 @@ describe("/admin/swaps", () => {
expect(response.data.swap.cart).toHaveProperty("discount_total")
expect(response.data.swap.cart).toHaveProperty("gift_card_total")
})
it("gets a swap with a discount", async () => {
const api = useApi()
const response = await api
.get("/admin/swaps/disc-swap", {
headers: {
Authorization: "Bearer test_token",
},
})
.catch((err) => {
console.log(err)
})
expect(response.status).toEqual(200)
expect(response.data.swap).toEqual(
expect.objectContaining({
id: "disc-swap",
})
)
expect(response.data.swap.cart).toEqual(
expect.objectContaining({
id: "disc-swap-cart",
discount_total: -800,
shipping_total: 1000,
subtotal: -8000,
total: -6200,
})
)
})
})
describe("GET /admin/swaps/", () => {