unit testing - Mocking $resourceProvider in AngularJs & Jasmine -
I am using $ $ resource in my controller: ng.resource.IResourceService help me get data from server ("$ Scope", "$ resource", "$ rootsecope", "$ http", "$ window", "$ location", and < , "Resource service", work ($ area, $ resource: ng resource.rowsssss service, $ rootscope: iRurtscope, $ http, $ window, $ location, resource service: services. IResourceService) {... // implementation} ]);
And here's my attempt to test Jasmine unit. However, I'm getting the error: [$ Injector: unpr] Unknown Provider: $ resource provider & lt; - $ resource
How do you duplicate the $ resource provider?
Description ("Test Controller Test", Function (): Zero {var vm: createDailylog.IViewModel; var $ scope: ng.IScope; var $ rootScope; var $ httpBackend: ng.IHttpBackendService ; // var $ injector = angularindsector (['ng', 'ngrsasource']); var $ resource = $ injector.get ('$ resource'); first of every (function): zero {module ("controller") ;}); First (Injection (function (_ $ controller_: ng.IControllerService, _ $ HttpBackend_, _ $ resource_, _ $ rootScope_: IRootScope, $ Injector) {$ httpBackend = _ $ httpBackend_; // $ resource = _ $ Resource_; $ .httpBackend = $ httpBackend; $ rootScope = _ $ rootScope_. $ New (); $ rootScope.config = {serverUrl: "https://test.do MainName.net/ ", ServerVersion:" test ", title:" test server reference "}; // controller VM = _ $ controller _ ('testController', {$ area: $ area, $ resource: $ injector.jet ( "$ Resource"), $ Rootscope: _ $ rootScope_, $ window: {}, location: {}});}); // every (works () (// $ httpBackend.verifyNoOutstandingExpectation (); // $ httpBackend.verifyNoOutstandingRequest (); //}); Description ('when populate method is called', function () (this is ("make the controller!", Function () {$ httpBackend.flush ()) is expected (true) .tb (true);}) ;}); ); }); });
Why do you need to copy $ resource
? You should only have fun with data, which is coming from $ http
; You are already doing this.
Comments
Post a Comment