Skip to content

Commit

Permalink
feat: add expect called once for insertOne and find functions
Browse files Browse the repository at this point in the history
  • Loading branch information
vanpho93 committed Jan 4, 2023
1 parent 2b009df commit 742c2a8
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ test("throws error when coupon code already exists in promotion window", async (
}
});

test("should insert a new coupon and results created results", async () => {
test("should insert a new coupon and return the created results", async () => {
const now = new Date();
const input = { code: "CODE", shopId: "123", promotionId: "123", canUseInStore: true };
const promotion = { _id: "123", endDate: now };
Expand All @@ -76,6 +76,9 @@ test("should insert a new coupon and results created results", async () => {

const result = await createStandardCoupon(mockContext, input);

expect(mockContext.collections.Coupons.insertOne).toHaveBeenCalledTimes(1);
expect(mockContext.collections.Coupons.find).toHaveBeenCalledTimes(1);

expect(result).toEqual({
success: true,
coupon: {
Expand Down

0 comments on commit 742c2a8

Please sign in to comment.