Skip to content

Commit

Permalink
Added tests for LearningWorldCompletionModalBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
Lizardguard committed Feb 11, 2025
1 parent 81e7dc8 commit 7dc4853
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { mock } from "jest-mock-extended";
import CoreDIContainer from "../../../../../Core/DependencyInjection/CoreDIContainer";
import PRESENTATION_TYPES from "../../../../../Core/DependencyInjection/Presentation/PRESENTATION_TYPES";
import ILearningWorldCompletionModalPresenter from "../../../../../Core/Presentation/React/LearningSpaceMenu/LearningWorldCompletionModal/ILearningWorldCompletionModalPresenter";
import LearningWorldCompletionModalBuilder from "../../../../../Core/Presentation/React/LearningSpaceMenu/LearningWorldCompletionModal/LearningWorldCompletionModalBuilder";

describe("LearningWorldCompletionModalBuilder", () => {
let systemUnderTest: LearningWorldCompletionModalBuilder;

beforeEach(() => {
systemUnderTest = new LearningWorldCompletionModalBuilder();
});

test("buildPresenter registers presenter with the CoreDIContainer", () => {
systemUnderTest.buildViewModel();
systemUnderTest.buildPresenter();

expect(
CoreDIContainer.isBound(
PRESENTATION_TYPES.ILearningWorldCompletionModalPresenter,
),
).toBe(true);
expect(
CoreDIContainer.get(
PRESENTATION_TYPES.ILearningWorldCompletionModalPresenter,
),
).toBe(systemUnderTest.getPresenter()!);
});

test("buildPresenter unbinds the presenter if it is already bound", () => {
CoreDIContainer.bind(
PRESENTATION_TYPES.ILearningWorldCompletionModalPresenter,
).toConstantValue(mock<ILearningWorldCompletionModalPresenter>);

const unbindSpy = jest.spyOn(CoreDIContainer, "unbind");

systemUnderTest.buildViewModel();
systemUnderTest.buildPresenter();

expect(unbindSpy).toHaveBeenCalledTimes(1);
});
});

0 comments on commit 7dc4853

Please sign in to comment.