Skip to content

Commit

Permalink
Added tests for LearningWorldCompletionModalPresenter
Browse files Browse the repository at this point in the history
  • Loading branch information
Lizardguard committed Feb 11, 2025
1 parent 7dc4853 commit c843c21
Showing 1 changed file with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe("LearningWorldCompletionModalPresenter", () => {
beforeAll(() => {
CoreDIContainer.snapshot();
CoreDIContainer.rebind(
USECASE_TYPES.ISetWorldCompletionModalToShownUseCase
USECASE_TYPES.ISetWorldCompletionModalToShownUseCase,
).toConstantValue(setWorldCompletionModalToShownMock);
});
beforeEach(() => {
Expand Down Expand Up @@ -96,4 +96,46 @@ describe("LearningWorldCompletionModalPresenter", () => {

expect(vm.showModal.Value).toEqual(false);
});

test("onLearningWorldScored should set canShowModal true, if currentScore is equal/greater to requiredScore", () => {
const worldScoreTO = {
worldID: 1,
currentScore: 1,
requiredScore: 1,
};

systemUnderTest.onLearningWorldScored(worldScoreTO);

expect(vm.canShowModal).toEqual(true);
});

test("onLearningWorldScored should not set canShowModal true, if currentScore is less than requiredScore", () => {
const worldScoreTO = {
worldID: 1,
currentScore: 1,
requiredScore: 2,
};

systemUnderTest.onLearningWorldScored(worldScoreTO);

expect(vm.canShowModal).toEqual(false);
});

test("openModal should set showModal true, if canShowModal is true", () => {
vm.canShowModal = true;
vm.showModal.Value = false;

systemUnderTest.openModal();

expect(vm.showModal.Value).toEqual(true);
});

test("openModal should not set showModal true, if canShowModal is false", () => {
vm.canShowModal = false;
vm.showModal.Value = false;

systemUnderTest.openModal();

expect(vm.showModal.Value).toEqual(false);
});
});

0 comments on commit c843c21

Please sign in to comment.