-
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 other parts of BreakTimeNotificationOverview parts
- Loading branch information
1 parent
f51183f
commit 13d0bd3
Showing
3 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
...eralComponents/BreakTimeNotificationOverview/BreakTimeNotificationOverviewBuilder.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/lib/Mock"; | ||
import CoreDIContainer from "../../../../../Core/DependencyInjection/CoreDIContainer"; | ||
import PRESENTATION_TYPES from "../../../../../Core/DependencyInjection/Presentation/PRESENTATION_TYPES"; | ||
import IBreakTimeNotificationOverviewPresenter from "../../../../../Core/Presentation/React/GeneralComponents/BreakTimeNotificationOverview/IBreakTimeNotificationOverviewPresenter"; | ||
import BreakTimeNotificationOverviewBuilder from "../../../../../Core/Presentation/React/GeneralComponents/BreakTimeNotificationOverview/BreakTimeNotificationOverviewBuilder"; | ||
|
||
describe("BreakTimeNotificationOverviewBuilder", () => { | ||
let systemUnderTest: BreakTimeNotificationOverviewBuilder; | ||
|
||
beforeEach(() => { | ||
systemUnderTest = new BreakTimeNotificationOverviewBuilder(); | ||
}); | ||
|
||
test("buildPresenter registers presenter with the CoreDIContainer", () => { | ||
systemUnderTest.buildViewModel(); | ||
systemUnderTest.buildPresenter(); | ||
|
||
expect( | ||
CoreDIContainer.isBound( | ||
PRESENTATION_TYPES.IBreakTimeNotificationOverviewPresenter, | ||
), | ||
).toBe(true); | ||
expect( | ||
CoreDIContainer.get( | ||
PRESENTATION_TYPES.IBreakTimeNotificationOverviewPresenter, | ||
), | ||
).toBe(systemUnderTest.getPresenter()!); | ||
}); | ||
|
||
test("buildPresenter unbinds the presenter if it is already bound", () => { | ||
CoreDIContainer.bind( | ||
PRESENTATION_TYPES.IBreakTimeNotificationOverviewPresenter, | ||
).toConstantValue(mock<IBreakTimeNotificationOverviewPresenter>); | ||
|
||
const unbindSpy = jest.spyOn(CoreDIContainer, "unbind"); | ||
|
||
systemUnderTest.buildViewModel(); | ||
systemUnderTest.buildPresenter(); | ||
|
||
expect(unbindSpy).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
41 changes: 41 additions & 0 deletions
41
...lComponents/BreakTimeNotificationOverview/BreakTimeNotificationOverviewController.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,41 @@ | ||
import mock from "jest-mock-extended/lib/Mock"; | ||
import BreakTimeNotificationOverviewController from "../../../../../Core/Presentation/React/GeneralComponents/BreakTimeNotificationOverview/BreakTimeNotificationOverviewController"; | ||
import BreakTimeNotificationOverviewViewModel from "../../../../../Core/Presentation/React/GeneralComponents/BreakTimeNotificationOverview/BreakTimeNotificationOverviewViewModel"; | ||
import IBreakTimeNotification from "../../../../../Core/Domain/BreakTimeNotifications/IBreakTimeNotification"; | ||
|
||
describe("BreakTimeNotificationOverviewController", () => { | ||
let systemUnderTest: BreakTimeNotificationOverviewController; | ||
|
||
test("selectNotification sets selected notification in view model", () => { | ||
const viewModel = new BreakTimeNotificationOverviewViewModel(); | ||
systemUnderTest = new BreakTimeNotificationOverviewController(viewModel); | ||
|
||
const notification = mock<IBreakTimeNotification>(); | ||
|
||
systemUnderTest.selectNotification(notification); | ||
|
||
expect(viewModel.selectedNotification.Value).toBe(notification); | ||
}); | ||
|
||
test("returnToOverview sets selected notification to null in view model", () => { | ||
const viewModel = new BreakTimeNotificationOverviewViewModel(); | ||
viewModel.selectedNotification.Value = mock<IBreakTimeNotification>(); | ||
systemUnderTest = new BreakTimeNotificationOverviewController(viewModel); | ||
|
||
systemUnderTest.returnToOverview(); | ||
|
||
expect(viewModel.selectedNotification.Value).toBeNull(); | ||
}); | ||
|
||
test("closeModal sets show modal to false and selected notification to null in view model", () => { | ||
const viewModel = new BreakTimeNotificationOverviewViewModel(); | ||
viewModel.showModal.Value = true; | ||
viewModel.selectedNotification.Value = mock<IBreakTimeNotification>(); | ||
systemUnderTest = new BreakTimeNotificationOverviewController(viewModel); | ||
|
||
systemUnderTest.closeModal(); | ||
|
||
expect(viewModel.showModal.Value).toBe(false); | ||
expect(viewModel.selectedNotification.Value).toBeNull(); | ||
}); | ||
}); |
15 changes: 15 additions & 0 deletions
15
...alComponents/BreakTimeNotificationOverview/BreakTimeNotificationOverviewPresenter.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,15 @@ | ||
import BreakTimeNotificationOverviewViewModel from "../../../../../Core/Presentation/React/GeneralComponents/BreakTimeNotificationOverview/BreakTimeNotificationOverviewViewModel"; | ||
import BreakTimeNotificationOverviewPresenter from "../../../../../Core/Presentation/React/GeneralComponents/BreakTimeNotificationOverview/BreakTimeNotificationOverviewPresenter"; | ||
|
||
describe("BreakTimeNotificationOverviewPresenter", () => { | ||
test("openModal sets show modal to true in view model", () => { | ||
const viewModel = new BreakTimeNotificationOverviewViewModel(); | ||
const systemUnderTest = new BreakTimeNotificationOverviewPresenter( | ||
viewModel, | ||
); | ||
|
||
systemUnderTest.openModal(); | ||
|
||
expect(viewModel.showModal.Value).toBe(true); | ||
}); | ||
}); |