¿Cómo burlarse de $ window para probar el servicio AngularJS?

Aquí está mi servicio:

var services = angular.module('amdotcom.services', ['ngResource']);

services.factory('homePageRes', ['$resource', '$window',
    function ($resource, $window) {
       var wdw = angular.element($window);
       return $resource('home/index', {
           height: wdw.height(),
           width: wdw.width()
       });
   }]);

services.factory('homePageLoader', ['homePageRes', '$q',
  function (homePageRes, $q) {
      return function () {
          var delay = $q.defer();
          homePageRes.get(function (homePage) {
              delay.resolve(homePage);
          }, function () {
              delay.reject('Unable to fetch home page');
          });
          return delay.promise;
      };
  }]);

A continuación se muestra mi prueba antes de presentar el servicio $ window. Estas pruebas funcionaron bien entonces, pero una vez que introduje el servicio $ window, no puedo burlarme de él.

describe('Services', function () {

    beforeEach(function () {
        module("amdotcom.services");
    });

    describe('homePageLoader', function () {
        var mockBackend, loader;

        beforeEach(inject(function ($httpBackend, homePageLoader) {
            mockBackend = $httpBackend;
            loader = homePageLoader;
        }));

        it('should return home page information', function () {
            mockBackend.expectGET('home/index?height=400&width=500').respond({ "Albums": [{ "Id": 2, "Name": "best shots" }] });

            var homePageData;

            var promise = loader();
            promise.then(function (homePg) {
                homePageData = homePg;
            });

            expect(homePageData).toBeUndefined();

            mockBackend.flush();

            expect(homePageData.Albums[0].Id).toEqual(2);
            expect(homePageData.Albums[0].Name).toEqual("best shots");
        });

        afterEach(function () {
            mockBackend.verifyNoOutstandingExpectation();
            mockBackend.verifyNoOutstandingRequest();
        });
    });
});

Recibo el error que dice: TypeError: 'undefined' no es una función (evaluando 'wdw.height ()')

Intenté usar el proveedor $ y los métodos spyOn, pero ninguno funciona. Por favor ayuda.

Arun

Respuestas a la pregunta(1)

Su respuesta a la pregunta