-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for LearningWorldCompletionModalBuilder
- Loading branch information
1 parent
81e7dc8
commit 7dc4853
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
...earningSpaceMenu/LearningWorldCompletionModal/LearningWorldCompletionModalBuilder.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |