我用的是卡玛测试跑步者和茉莉花。在这种情况下,我知道如何在scope.But上测试函数,我该怎么做呢?
listing_app.controller('my_listing_products_list', ['$scope', '$modal',
function ($scope, $modal) {
this.someFn = function(a,b){
//How do i test this function ?
}
}]);如何通过Jasmine获取这个对象和控制器上下文?
发布于 2014-01-03 19:04:33
尝试以下几点:
describe('my_listing_products_list controller', function(){
beforeEach(inject(function($controller, $rootScope){
scope = $rootScope.$new();
ctrl = $controller("my_listing_products_list", {$scope: scope});
}));
it('should exist', function($controller){
expect(ctrl.someFn()).toBe('whatever the function returns')
});
})https://stackoverflow.com/questions/20910445
复制相似问题