88 lines
2.8 KiB
TypeScript
88 lines
2.8 KiB
TypeScript
import UserEffect from "../../src/database/entities/app/UserEffect";
|
|
import EffectHelper from "../../src/helpers/EffectHelper";
|
|
|
|
describe("AddEffectToUserInventory", () => {
|
|
describe("GIVEN effect is in database", () => {
|
|
const effectMock = {
|
|
AddUnused: jest.fn(),
|
|
Save: jest.fn(),
|
|
};
|
|
|
|
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", () => {
|
|
test.todo("EXPECT effect to be created");
|
|
|
|
test.todo("EXPECT effect to be saved");
|
|
});
|
|
});
|
|
|
|
describe("UseEffect", () => {
|
|
describe("GIVEN effect is in database", () => {
|
|
describe("GIVEN effect.WhenExpires is undefined", () => {
|
|
test.todo("EXPECT false returned");
|
|
});
|
|
|
|
describe("GIVEN now is before effect.WhenExpires", () => {
|
|
test.todo("EXPECT false returned");
|
|
});
|
|
|
|
describe("GIVEN currently used effect is inactive", () => {
|
|
test.todo("EXPECT UseEffect to be called");
|
|
|
|
test.todo("EXPECT effect to be saved");
|
|
|
|
test.todo("EXPECT true returned");
|
|
});
|
|
});
|
|
|
|
describe("GIVEN effect is not in database", () => {
|
|
test.todo("EXPECT false returned");
|
|
});
|
|
|
|
describe("GIVEN effect.Unused is 0", () => {
|
|
test.todo("EXPECT false returned");
|
|
});
|
|
});
|
|
|
|
describe("HasEffect", () => {
|
|
describe("GIVEN effect is in database", () => {
|
|
describe("GIVEN effect.WhenExpires is defined", () => {
|
|
describe("GIVEN now is before effect.WhenExpires", () => {
|
|
test.todo("EXPECT true returned");
|
|
});
|
|
|
|
describe("GIVEN now is after effect.WhenExpires", () => {
|
|
test.todo("EXPECT false returned");
|
|
});
|
|
});
|
|
|
|
describe("GIVEN effect.WhenExpires is undefined", () => {
|
|
test.todo("EXPECT false returned");
|
|
});
|
|
});
|
|
|
|
describe("GIVEN effect is not in database", () => {
|
|
test.todo("EXPECT false returned");
|
|
});
|
|
});
|