In my application, the CanDeactiveGuard
is functioning properly. During unit testing, I encountered an issue with one test where I intended to use callThrough
to invoke the openConfirmDialog()
method within the Guard. This method triggers the Modal Dialog component that prompts the user to save changes. Although the method resides in the Guard, it actually calls a service to open the modal. My question is whether it is appropriate to execute the code in the ModalDialogService
from a Guard method, or if I should test the service independently.
The Guard class and the ModalDialogService
are the two key components involved in this scenario. Should the code within the ModalDialogService
be executed from the Guard, or should it be tested separately?
Here's a snippet from the guard spec file:
(...mockGuardComponent and service tests...)
During the second test, I'm attempting to trigger the openConfirmDialog() method to launch the modal.
Below is an excerpt from the ModalDialogService class:
(...ModalDialogService class code...)
Given that the openConfirmDialog()
method does not execute the code in the ModalDialogService
, it seems necessary to test that functionality separately. Does this mean that I have to mock objects such as OverlayRef
, ModalDialogConfig
, and ModalDialogRef
to create a dialog?