Feat/expand on list discounts (#1304)

This commit is contained in:
Kasper Fabricius Kristensen
2022-04-21 15:22:07 +02:00
committed by GitHub
parent 313cb0658b
commit 7a1e394b9d
5 changed files with 87 additions and 6 deletions

View File

@@ -142,6 +142,58 @@ describe("/admin/discounts", () => {
)
})
it("should retrieve discount and only select the id field and retrieve the relation parent_discount", async () => {
const api = useApi()
const group = await dbConnection.manager.insert(CustomerGroup, {
id: "customer-group-1",
name: "vip-customers",
})
await dbConnection.manager.insert(Customer, {
id: "cus_1234",
email: "oli@email.com",
groups: [group],
})
await simpleDiscountFactory(dbConnection, {
id: "test-discount",
code: "TEST",
rule: {
type: "percentage",
value: "10",
allocation: "total",
conditions: [
{
type: "customer_groups",
operator: "in",
customer_groups: ["customer-group-1"],
},
],
},
})
const response = await api
.get(
"/admin/discounts/test-discount?fields=id&expand=parent_discount",
{
headers: {
Authorization: "Bearer test_token",
},
}
)
.catch((err) => {
console.log(err)
})
const disc = response.data.discount
expect(response.status).toEqual(200)
expect(disc).toEqual({
id: "test-discount",
parent_discount: null,
})
})
it("should retrieve discount with product conditions created with factory", async () => {
const api = useApi()