test: add a case when regions only contain invalid region Ids

This commit is contained in:
Riqwan Thamir
2022-12-06 22:14:12 +01:00
committed by Adrien de Peretti
parent bcc1edbf2b
commit 66bec2f54d

View File

@@ -1292,6 +1292,31 @@ describe("/admin/discounts", () => {
)
})
it("fails to create a discount if the regions contains only invalid regionIds ", async () => {
expect.assertions(2)
const api = useApi()
const err = await api.post(
"/admin/discounts",
{
code: "HELLOWORLD",
rule: {
description: "test",
type: "percentage",
value: 10,
allocation: "total",
},
regions: [invalidRegionId],
},
adminReqConfig
).catch(e => e)
expect(err.response.status).toEqual(404)
expect(err.response.data.message).toEqual(
`Region with not-a-valid-region was not found`
)
})
it("fails to create a discount if regions are not present ", async () => {
expect.assertions(2)
const api = useApi()