angularjs - Testing a function in an angular factory with jasmine -
i want test function inside angular factory.
app.factory('customersearchservice', function ($http, $q) { var customersearchbyname = function (searchtokens) { //some stuff }; function createsearchstringfromarray(searcharray) { //do stuff return 'processed string'; } return { customersearchbyname: customersearchbyname }; });
i have tried access inner function, results in undefined message function:
describe("services: customersearchservice", function () { beforeeach(module('addressservice')); var customersearchservice; beforeeach(inject(function($injector) { customersearchservice = $injector.get('customersearchservice'); })); it("createsearchstringfromarray function", function () { expect(customersearchservice.createsearchstringfromarray).tobefunction(); }); });
i add createsearchstringfromarray factory functions, want stay private.
how can access inner function jasmine?
thanks link runtarm (http://philipwalton.com/articles/how-to-unit-test-private-functions-in-javascript/) have created new service method testing, removed grunt deployment.
angular factory:
function createsearchstringfromarray(searchtokensarray) { //do stuff return 'processed string'; } return { customersearchbyname: customersearchbyname, /* test-code */ createsearchstringfromarray: createsearchstringfromarray /* end-test-code */ };
thanks runtarm!
Comments
Post a Comment