javascript - how to resolve my unit test issue -
i trying build unit test case
i have in controller like
$scope.getdetail = function(name) { //other codes //using testfactory details testfactory.getdetail(name).then(function(detail){ console.log(detail) }) //other codes }
factory file
var factory = {}; factory.getdetail = function(name) { //calculate…etc return details; } return factory;
unit test file
describe('controller', function () { var testctrl, scope, testfactory; beforeeach(module('testapp')); beforeeach(inject(function (_$controller_, _$rootscope_, _testfactory_) { scope = _$rootscope_.$new(); testfactory = _testfactory_; testctrl = _$controller_('testctrl', { $scope: scope }); }; var name = 'test'; spyon(testfactory, 'getdetail').and.callfake(function(name) { return 'success'; }); it('should details', function() { var result = testfactory.getdetail(name); expect(result).tobetruthy(); }) }));
i getting
undefined' not function (evaluating 'testfactory.getdetail(name)' error.
can me solve this? not sure went wrong. lot!
Comments
Post a Comment