vendredi 22 mai 2015

How to ignore a run.js in Angular / Karma unit testing?

I have a file run.js that has:

window.map.run([
    '$rootScope', '$location', 'cache', 'userCache',
    function($rootScope, $location, cache, userCache) {
        userCache.checkSession().then(function(result) {
            if(result.userId) {
                cache.set('login', 'successfulLogin', true);
                if($location.path() !== '/patients') {
                    $location.path('/patients');
                }
            }
        });
    }
]);

This runs when the app loads. This is normally great behavior. But when I'm unit testing controllers, all hell breaks loose. I can't figure out how to spy or mock this so that it's false. Any ideas?

Thanks!

Aucun commentaire:

Enregistrer un commentaire