unit testing - How to test function in AngularJS service with mock data -


how create jasmine unit test 1 function in angularjs service provider. want create mock data myobject , test function getobjectshape() mock data parameter. how achieve that?

    (function () {     'use strict';     angular.module('objectshapes')             .provider('shapesresolver', shapesresolver);          function shapesresolver() {              this.$get = function () {                 return resolver;             };              function resolver(myobject) {                  var service = {                     getobjectshape: getobjectshape                 };                  function getobjectshape() {                     return myobject.shape;                 }             }         } })(); 

here's skeleton of test service.

describe('shapesresolver service', function() {     var shapesresolver;      beforeeach(module('objectshapes'));     beforeeach(inject(function(_shapesresolver_) {         shapesresolver = _shapesresolver_;     }));      it('should something, what?', function() {         var mockmyobject = {};          shapesresolver(mockmyobject);          // shapesresolver doesn't return anything, , doesn't          // have side effect, there's nothing test.          expect(true).tobetruthy();     });  }); 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -