Create effects concept #402

Merged
Vylpes merged 9 commits from feature/378-effects-concept into develop 2024-11-09 21:31:11 +00:00
Showing only changes of commit 60bb39253f - Show all commits

View file

@ -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", () => {