Within my configuration object, I have set up two boolean variables that are passed to a constant within my Angular application.
When the page loads, these booleans are checked. If both are true, the user remains on the page. However, if one or the other is true, the user is redirected to a specific page.
Take a look at the code snippet below:
angular
.module('ecardGeneratorPrototype')
.constant('config',
{
"enable-file-upload": true,
"enable-webcam": true
In a resolve function, I validate these variables as follows:
.when('/home', {
templateUrl: 'app/home/home.html',
controller: 'HomeController',
controllerAs: 'home',
resolve : {
choice: ['$route', '$window', 'config', function ($route, $window, config) {
if (config["enable-file-upload"] && config["enable-webcam"]) {
//return
return;
}
else {
if (config["enable-file-upload"]) {
//$log( "display the file upload page" );
$window.location.href = '#/file-upload';
} else if (config["enable-webcam"]) {
//$log( "display the webcam page" );
$window.location.href = '#/webcam';
}
}
return;
}]
}
})
I am wondering if it's possible to override these constants in order to properly test the redirection of pages using Protractor.