I have a controller which has some logic that runs when the controller loads.
This logic checks a value in a service and performs an action depending on the value.
if(FunkyService.foo()) {
doA();
} else {
doB();
}
I want to write a Jasmine test that can test outcomes for each value that the service can have (In this example true or false in function foo() of my service).
My problem is that the controller is loaded in a beforeEach() function which means that it is too late in my tests to switch the service value. If I set the results of my services foo() function in a beforeEach() I can't understand how to test both true and false outcomes.
I have two questions.
How can I get my controller to reload in one of my tests? This would allow me to change the service foo() function return value and then force the controller to re-run the logic when it loads.
Or should I be approaching this in an entirely different way?