fix(medusa): Add usage_count + usage_limit to discount
This commit is contained in:
@@ -106,6 +106,8 @@ describe("/store/carts", () => {
|
||||
|
||||
afterEach(async () => {
|
||||
const manager = dbConnection.manager;
|
||||
await manager.query(`DELETE FROM "discount"`);
|
||||
await manager.query(`DELETE FROM "discount_rule"`);
|
||||
await manager.query(`DELETE FROM "cart"`);
|
||||
await manager.query(`DELETE FROM "customer"`);
|
||||
await manager.query(
|
||||
@@ -114,6 +116,21 @@ describe("/store/carts", () => {
|
||||
await manager.query(`DELETE FROM "region"`);
|
||||
});
|
||||
|
||||
it("fails on apply discount if limit has been reached", async () => {
|
||||
const api = useApi();
|
||||
|
||||
try {
|
||||
await api.post("/store/carts/test-cart", {
|
||||
discounts: [{ code: "CREATED" }],
|
||||
});
|
||||
} catch (error) {
|
||||
expect(error.response.status).toEqual(400);
|
||||
expect(error.response.data.message).toEqual(
|
||||
"Discount has been used maximum allowed times"
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
it("updates cart customer id", async () => {
|
||||
const api = useApi();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user