title: Can/Should custom $resource action methods be tested?
body: <p>In a angular service I have $resource action methods such as :</p>
  
  <pre><code>class FooService {
    /*@ngInject*/
    constructor($resource) {
      this.Foo = $resource('/foo/:fooId/',
                            {fooId: '@fooId'},
                            {
                               bar: {
                                  method: 'GET',
                                  url: '/foo/:fooId/bar/',
                                  isArray: true
                            }
                  );
    }
    getAllFoo() {
      return this.Foo.query();
    }
  }
  </code></pre>
  
  <p>is bar testable ? </p>
  
  <p>I already have tests for methods such as getAllFoo(), but I am not so sure about $resource action methods. </p>
  
  <p>Is it ok to use them directly in controller, as in<br>
  <code>this.FooService.Foo.bar(params).$promise.then</code> ?</p>
  
  <p>Should they be tested ?
  And if so, how ?</p>
  
  <p>EDIT:
  I know how to test getAllFoo() :</p>
  
  <pre><code>describe('FooService', () =&gt; {
      let $rootScope, $resource, $httpBackend, $log, $interval;
      let makeFooService, translateMock;
      let mockAllFoo = [
          {"id": 123,"stuff": "asdf asdf"},
          {"id": 124,"stuff": "hjghjg"}
      ];
  
      beforeEach(window.module(FooModule.name));
  
      beforeEach(inject((_$rootScope_, $q, _$resource_, _$httpBackend_, _$log_) =&gt; {   
          $rootScope = _$rootScope_;
          queryDeferred = $q.defer();
          $resource = _$resource_;
          $httpBackend = _$httpBackend_;
          $log = _$log_;   
          translateMock = { use: () =&gt; ({}) };  
          makeFooService = () =&gt;  new FooService(_$resource_);
      }));
  
      afterEach(function() {
          $httpBackend.verifyNoOutstandingExpectation();
          $httpBackend.verifyNoOutstandingRequest();
      });
      describe('Service', () =&gt; {
      it('has a resource-property [Foo]', () =&gt; {
          let service = makeFooService();
          expect(service.Foo).not.toBeNull();
      });
  
      it('should load all foos when getAllFoo() is called', () =&gt; {
          $httpBackend.expect('GET', /(.+)\/foo/).respond( () =&gt; [200, mockAllFoo, 'success'] );
          let service = makeFooService();
          let allFoo = service.getAllFoo();
          $httpBackend.flush();
          expect(allFoo.length).toBe(2);
      });
  </code></pre>
  
  <p>So I know how to test getAllFoo() but not how to test bar();
  If bar is testable and usable in a controller directly, then I dont see the point of doing methods such as getAllFoo() that are simply wrapper around $resource action methods. I need clarifications on the best practices here.</p>