javascript - Testing Angular Controller As with Jasmine -


I'm new to Jasmine / angular testing and I'm trying to test a controller. The control code is given below

  (function () {'strict use'; angular.module ('app'). Controller ('action events'), action events CTRL. $ Injection = ['$ log', 'action events']; function action events citation ($ log, action events) {/ * jshint is valid: true * / var vm = this; // getActionEvents (); vm.ActionEvents = [{"Details" : "Second", "Type": 4, "Detroit": "2014-10-17T00: 00: 00", "Hanotified": True, "Status": 0, "User": zero, "id" : 6}, {"Details": "Third notification", "Type": 2, "Date Ridge": "2014-10-18T 00: 00: 00", "Hanotified": True, "Status": 1 , "User": blank, "id": 7}]; vm.init = getActionEvents (); function getActionEvents () {var userId = 1; ActionEvents.get (userId). Then (work on success (feedback) {vm .ActionEvents = response.data;}, fail on function (response) {$ log.error ("Action Loading ActionEvents failed with response:", response);}); <}  

}) ();

I wrote a test below

  Description ("app", function () {"action events controller", function () {// basic fake search service which is empty array Var MockActionEventSivet = {Receive: Function (User ID) {Return [{"Details": "Second Notification", "Type": 4, "Date" ":" 2014-10-17T00: 00: 00 ", "," "True", "status": 0, "user": zero, "id": 6}, {"description": "third notification", "type": 2, "datrised": "2014- 10-18T00: 00: 00 "," Hanotified ": S "Status": 1, "user": zero, "id": 7}];},}; var scope; var log; var controller; first each (module ('tracer app')) first (injected Function ($ Rootscope, $ controller) {scope = $ rootScope. $ New (); log = null; controller = $ controller ('ActionEventsCtrl as actionEventVM', {$ log: log, actionEvents: mockActionEventsService});}) ); It should be ('data', function () {hope (scope.actionEventVM.ActionEvents) .toJson ();});});  

});

But I am getting an error

  typeError: there is no undefined function TypeError: is not undefined on ObjectEstantiate (action events.controller.js: Line 20:19) A function on getActionEvents (actionevents.controller.js: line 24:38) at D on D (Konular Min. JS: Line 35:36). Angular.min.js: Line 35: 165) at angular.min.js: Line 67: Null at line 41 9. & Lt; Anonymous & gt; (Actionevents.controller.test.js: Line 34:26) on ObjectD [as an ion] (angular.min.js: Line 35:36) at workFn (angular-mocks.js: line 2161: 20) on jasmine .blok.exicute (jasmine.js: line 1064: 17) in jasmine. Quay.NX_ (Jasmin. JS: Line 2096: 31) Error: window.inject.angular.mock.inject (angular-mocks.js: line 2146: 25) at the declaration location at zero. & Lt; Anonymous & gt; (Actionevents.controller.test.js: Line 31:20) on jasmine.Env.describe (jasmine.js: line 819: 21) on description (jasmine.js: Line 603: 27) at zero. & Lt; Anonymous & gt; (Actionevents.controller.test.js: Line 12: 5) at jasmine.Env.describe (jasmine.js: line 819: 21) on description (jasmine.js: line 603: 27) at actionevents.controller.test.js : Type Line 10: 1 Line: Undefined type type property 'action events' can not be read: The undefined property on the tap can not read 'action events'. & Lt; Anonymous & gt; (Actionevents.controller.test.js: Line 39:39) on jasmine. Block Exquit (Jasmin. JS: Line 1064: 17) in Chameli. Quyu Nx_ (Jasmine. JS: Line 20 9 6: 31) Jasmine in Chameli. JS: Line 2086: 18  

I was getting the error because my injection The log object did not have the error function. Due to being a dummy method in the log it takes a parameter.


Comments

Popular posts from this blog

c# - SignalR: "Protocol error: Unknown transport." when navigating to hub -

class - Kivy: how to instantiate a dynamic classes in python -

python - mayavi mapping a discrete colorbar on a surface -