Create use effect command (#419)
All checks were successful
Deploy To Stage / build (push) Successful in 48s
Deploy To Stage / deploy (push) Successful in 17s

# Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

#380

## Type of change

Please delete options that are not relevant.

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update

# How Has This Been Tested?

Please describe the tests that you ran to verify the changes. Provide instructions so we can reproduce. Please also list any relevant details to your test configuration.

# Checklist

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that provde my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules

Reviewed-on: #419
Reviewed-by: VylpesTester <tester@vylpes.com>
Co-authored-by: Ethan Lane <ethan@vylpes.com>
Co-committed-by: Ethan Lane <ethan@vylpes.com>
This commit is contained in:
Ethan Lane 2025-01-25 17:29:01 +00:00 committed by Vylpes
parent 3e81f8ce1d
commit a3248e978a
42 changed files with 1241 additions and 1133 deletions

View file

@ -0,0 +1,68 @@
import GetCardsHelper from "../../../src/helpers/DropHelpers/GetCardsHelper";
import EffectHelper from "../../../src/helpers/EffectHelper";
import GetUnclaimedCardsHelper from "../../../src/helpers/DropHelpers/GetUnclaimedCardsHelper";
import CardConstants from "../../../src/constants/CardConstants";
jest.mock("../../../src/helpers/EffectHelper");
jest.mock("../../../src/helpers/DropHelpers/GetUnclaimedCardsHelper");
beforeEach(() => {
jest.resetAllMocks();
});
describe("FetchCard", () => {
test("GIVEN user has the unclaimed effect AND unused chance is within constraint, EXPECT unclaimed card returned", async () => {
// Arrange
(EffectHelper.HasEffect as jest.Mock).mockResolvedValue(true);
GetCardsHelper.GetRandomCard = jest.fn();
Math.random = jest.fn().mockReturnValue(CardConstants.UnusedChanceUpChance - 0.1);
// Act
await GetCardsHelper.FetchCard("userId");
// Assert
expect(EffectHelper.HasEffect).toHaveBeenCalledTimes(1);
expect(EffectHelper.HasEffect).toHaveBeenCalledWith("userId", "unclaimed");
expect(GetUnclaimedCardsHelper.GetRandomCardUnclaimed).toHaveBeenCalledTimes(1);
expect(GetUnclaimedCardsHelper.GetRandomCardUnclaimed).toHaveBeenCalledWith("userId");
expect(GetCardsHelper.GetRandomCard).not.toHaveBeenCalled();
});
test("GIVEN user has unclaimed effect AND unused chance is NOT within constraint, EXPECT random card returned", async () => {
// Arrange
(EffectHelper.HasEffect as jest.Mock).mockResolvedValue(true);
GetCardsHelper.GetRandomCard = jest.fn();
Math.random = jest.fn().mockReturnValue(CardConstants.UnusedChanceUpChance + 0.1);
// Act
await GetCardsHelper.FetchCard("userId");
// Assert
expect(EffectHelper.HasEffect).toHaveBeenCalledTimes(1);
expect(EffectHelper.HasEffect).toHaveBeenCalledWith("userId", "unclaimed");
expect(GetCardsHelper.GetRandomCard).toHaveBeenCalledTimes(1);
expect(GetUnclaimedCardsHelper.GetRandomCardUnclaimed).not.toHaveBeenCalled();
});
test("GIVEN user does NOT have unclaimed effect, EXPECT random card returned", async () => {
// Arrange
(EffectHelper.HasEffect as jest.Mock).mockResolvedValue(false);
GetCardsHelper.GetRandomCard = jest.fn();
Math.random = jest.fn().mockReturnValue(CardConstants.UnusedChanceUpChance + 0.1);
// Act
await GetCardsHelper.FetchCard("userId");
// Assert
expect(EffectHelper.HasEffect).toHaveBeenCalledTimes(1);
expect(EffectHelper.HasEffect).toHaveBeenCalledWith("userId", "unclaimed");
expect(GetCardsHelper.GetRandomCard).toHaveBeenCalledTimes(1);
expect(GetUnclaimedCardsHelper.GetRandomCardUnclaimed).not.toHaveBeenCalled();
});
});

View file

@ -0,0 +1,19 @@
describe("GetRandomCardUnclaimed", () => {
test.todo("GIVEN chance is within bronze chance, EXPECT bronze card returned");
test.todo("GIVEN chance is within silver chance, EXPECT silver card");
test.todo("GIVEN chance is within gold chance, EXPECT gold card returned");
test.todo("GIVEN chance is within manga chance, EXPECT manga card returned");
});
describe("GetRandomCardByRarityUnclaimed", () => {
test.todo("GIVEN user has no claimed cards, EXPECT random card returned");
test.todo("GIVEN no cards are found in memory, EXPECT undefined returned");
test.todo("GIVEN no series metadata is found for random card, EXPECT undefined returned");
test.todo("GIVEN user has claimed cards, EXPECT random card to NOT be this card");
});