WIP Start creating EffectHelper tests
Some checks failed
Test / build (push) Failing after 12s

This commit is contained in:
Ethan Lane 2024-10-31 17:59:46 +00:00
parent e449e1a2b2
commit 60bb39253f

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