我有角与UI的路由器,所以toResolve
变量将在我的SomeController
测试角度解决方法
.state('some.state', {
url: '/some',
controller: 'SomeController',
templateUrl: '/static/views/some-state.html',
resolve: {
toResolve: function(Resource) {
return Resource.get(function(response) {
return response;
});
},
内解决,但如何测试茉莉这个功能?假设我忘记return
声明,因此我范围内的toResolve
将是undefined。
为什么要测试内部AngularJS功能,可能它的工作原理以完美的方式 –
这不是内部,它是一个简单的测试用例,例如'expect($ scope.toResolve).not.toBeUndefined();'当我可能想要返回例如 –
@KrzysztofSafjanowski:无论如何,一切都必须可测试如果我想我应该能够模拟任何组件并测试任何组合那些无论内在与否 –