This commit is contained in:
parent
bc98d6ba75
commit
a521ea193a
2 changed files with 0 additions and 50 deletions
|
@ -16,69 +16,22 @@ let interaction: ButtonInteractionType;
|
|||
beforeEach(() => {
|
||||
jest.resetAllMocks();
|
||||
|
||||
jest.spyOn(Buy as any, "Confirm")
|
||||
.mockRestore();
|
||||
jest.spyOn(Buy as any, "Cancel")
|
||||
.mockRestore();
|
||||
|
||||
interaction = GenerateButtonInteractionMock();
|
||||
interaction.customId = "effects buy";
|
||||
|
||||
});
|
||||
|
||||
describe("Execute", () => {
|
||||
test("GIVEN subaction is confirm, EXPECT confirm function executed", async () => {
|
||||
// Arrange
|
||||
interaction.customId += " confirm";
|
||||
|
||||
const confirmSpy = jest.spyOn(Buy as any, "Confirm")
|
||||
.mockImplementation();
|
||||
|
||||
// Act
|
||||
await Buy.Execute(interaction as unknown as ButtonInteraction);
|
||||
|
||||
// Assert
|
||||
expect(confirmSpy).toHaveBeenCalledTimes(1);
|
||||
expect(confirmSpy).toHaveBeenCalledWith(interaction);
|
||||
|
||||
expect(AppLogger.LogError).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test("GIVEN subaction is cancel, EXPECT cancel function executed", async () => {
|
||||
// Arrange
|
||||
interaction.customId += " cancel";
|
||||
|
||||
const cancelSpy = jest.spyOn(Buy as any, "Cancel")
|
||||
.mockImplementation();
|
||||
|
||||
// Act
|
||||
await Buy.Execute(interaction as unknown as ButtonInteraction);
|
||||
|
||||
// Assert
|
||||
expect(cancelSpy).toHaveBeenCalledTimes(1)
|
||||
expect(cancelSpy).toHaveBeenCalledWith(interaction);
|
||||
|
||||
expect(AppLogger.LogError).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test("GIVEN subaction is invalid, EXPECT error logged", async () => {
|
||||
// Arrange
|
||||
interaction.customId += " invalid";
|
||||
|
||||
const confirmSpy = jest.spyOn(Buy as any, "Confirm")
|
||||
.mockImplementation();
|
||||
const cancelSpy = jest.spyOn(Buy as any, "Cancel")
|
||||
.mockImplementation();
|
||||
|
||||
// Act
|
||||
await Buy.Execute(interaction as unknown as ButtonInteraction);
|
||||
|
||||
// Assert
|
||||
expect(AppLogger.LogError).toHaveBeenCalledTimes(1);
|
||||
expect(AppLogger.LogError).toHaveBeenCalledWith("Buy", "Unknown subaction, effects invalid");
|
||||
|
||||
expect(confirmSpy).not.toHaveBeenCalled();
|
||||
expect(cancelSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
import Buy from "../../../src/commands/effects/Buy";
|
||||
import EffectHelper from "../../../src/helpers/EffectHelper";
|
||||
|
||||
jest.mock("../../../src/helpers/EffectHelper");
|
||||
|
||||
describe("Buy", () => {
|
||||
|
|
Loading…
Reference in a new issue