-
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.
- Loading branch information
1 parent
c843c21
commit 671fe96
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
...omponents/CoreTest/Presentation/React/LearningSpaceDisplay/SideBar/SideBarBuilder.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 |
---|---|---|
@@ -1,13 +1,50 @@ | ||
import mock from "jest-mock-extended/lib/Mock"; | ||
import CoreDIContainer from "../../../../../Core/DependencyInjection/CoreDIContainer"; | ||
import PRESENTATION_TYPES from "../../../../../Core/DependencyInjection/Presentation/PRESENTATION_TYPES"; | ||
import SideBarBuilder from "../../../../../Core/Presentation/React/LearningSpaceDisplay/SideBar/SideBarBuilder"; | ||
import ILearningWorldPort from "../../../../../Core/Application/Ports/Interfaces/ILearningWorldPort"; | ||
import PORT_TYPES from "../../../../../Core/DependencyInjection/Ports/PORT_TYPES"; | ||
import { | ||
HistoryWrapper, | ||
LocationScope, | ||
} from "../../../../../Core/Presentation/React/ReactRelated/ReactEntryPoint/HistoryWrapper"; | ||
|
||
const worldPortMock = mock<ILearningWorldPort>(); | ||
|
||
describe("SideBarBuilder", () => { | ||
let systemUnderTest: SideBarBuilder; | ||
beforeAll(() => { | ||
CoreDIContainer.snapshot(); | ||
CoreDIContainer.rebind<ILearningWorldPort>( | ||
PORT_TYPES.ILearningWorldPort, | ||
).toConstantValue(worldPortMock); | ||
}); | ||
|
||
beforeEach(() => { | ||
systemUnderTest = new SideBarBuilder(); | ||
jest | ||
.spyOn(HistoryWrapper, "currentLocationScope") | ||
.mockReturnValue(LocationScope.spaceDisplay); | ||
}); | ||
|
||
afterAll(() => { | ||
CoreDIContainer.restore(); | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
test("constructor didn't throw error", () => { | ||
expect(systemUnderTest).toBeDefined(); | ||
}); | ||
test("buildPresenter builds the presenter and registers it with the WorldPort", () => { | ||
systemUnderTest.buildViewModel(); | ||
systemUnderTest.buildController(); | ||
systemUnderTest.buildPresenter(); | ||
|
||
expect(systemUnderTest["presenter"]).toBeDefined(); | ||
expect(worldPortMock.registerAdapter).toHaveBeenCalledTimes(1); | ||
expect(worldPortMock.registerAdapter).toHaveBeenCalledWith( | ||
systemUnderTest["presenter"], | ||
LocationScope.spaceDisplay, | ||
); | ||
}); | ||
}); |