diff --git a/tests/helpers/EffectHelper.test.ts b/tests/helpers/EffectHelper.test.ts index d9520a2..9e3b5b0 100644 --- a/tests/helpers/EffectHelper.test.ts +++ b/tests/helpers/EffectHelper.test.ts @@ -1,8 +1,33 @@ +import UserEffect from "../../src/database/entities/app/UserEffect"; +import EffectHelper from "../../src/helpers/EffectHelper"; + describe("AddEffectToUserInventory", () => { describe("GIVEN effect is in database", () => { - test.todo("EXPECT effect to be updated"); + const effectMock = { + AddUnused: jest.fn(), + Save: jest.fn(), + }; - test.todo("EXPECT effect to be saved"); + beforeAll(async () => { + UserEffect.FetchOneByUserIdAndName = jest.fn().mockResolvedValue(effectMock); + + await EffectHelper.AddEffectToUserInventory("userId", "name", 1); + }); + + test("EXPECT database to be fetched", () => { + expect(UserEffect.FetchOneByUserIdAndName).toHaveBeenCalledTimes(1); + expect(UserEffect.FetchOneByUserIdAndName).toHaveBeenCalledWith("userId", "name"); + }); + + test("EXPECT effect to be updated", () => { + expect(effectMock.AddUnused).toHaveBeenCalledTimes(1); + expect(effectMock.AddUnused).toHaveBeenCalledWith(1); + }); + + test("EXPECT effect to be saved", () => { + expect(effectMock.Save).toHaveBeenCalledTimes(1); + expect(effectMock.Save).toHaveBeenCalledWith(UserEffect, effectMock); + }); }); describe("GIVEN effect is not in database", () => {