不满意的 GET 请求 Jasmine angularJS 用于异步服务调用

Unsatisifed GET request Jasmine with angularJS for asynch service calls

当我 运行 我的 jasmine 测试 case.I 试图测试我的服务时,我收到不满意的 GET 请求错误消息。 结构是:

describe('should test Static Quotes List functionality', function () {

            it('should check list of static quotes is not null', function () {

                //ARRANGE 

                var url = CONFIG.autoApiBaseUrl + 'api/quotesconfig';

                httpBackend.expect('GET', url).respond(staticQuotesData);

                //ACT
                retrievequoteService.getStaticQuotes().then(function (data) {
                    //ASSERT
                    expect(data).not.toBeNull();
                    expect(data.length).toEqual(1);
                });

                setTimeout(function () {
                    httpBackend.flush();
                }, 100);

            });
        });

我的服务文件是:

  function getStaticQuotes() {
        var deferred = $q.defer();
        retrievequoteResource.getStaticQuotes().$promise.then(function (result) {
            deferred.resolve(result);
        });
        return deferred.promise;
    } 

你能帮我解决这个问题吗?

谢谢。 萨杰什

我改成了

spyOn(retrievequoteResource, "getStaticQuotes").and.returnValue({ $promise: q.when(staticQuotesData) });

                //ACT

                var result;

                var promise = retrievequoteService.getStaticQuotes();
                promise.then(function (result) {
                    expect(result).not.toBeNull();
                    expect(result.length).toEqual(1);
                });

                $rootScope.$digest();