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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

python - Django-cities exits with "killed" -

python - How to get a widget position inside it's layout in Kivy? -