我有一个文件 run.js
有:
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');
}
}
});
}
]);
这会在应用加载时运行。这通常是很好的行为。但是当我对 Controller 进行单元测试时,一切都变得一团糟。我不知道如何spy
或mock
以使其为假。有什么想法吗?
谢谢!
最佳答案
关于javascript - 如何在 Angular/Karma 单元测试中忽略 run.js?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30404266/