This commit is contained in:
parent
e449e1a2b2
commit
60bb39253f
1 changed files with 27 additions and 2 deletions
|
@ -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", () => {
|
||||
|
|
Loading…
Reference in a new issue