當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript IHttpBackendService.whenGET方法代碼示例

本文整理匯總了TypeScript中angular.IHttpBackendService.whenGET方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript IHttpBackendService.whenGET方法的具體用法?TypeScript IHttpBackendService.whenGET怎麽用?TypeScript IHttpBackendService.whenGET使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在angular.IHttpBackendService的用法示例。


在下文中一共展示了IHttpBackendService.whenGET方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

  it('adds label to subnet, including (deprecated) if deprecated field is true', function() {
    $http
      .whenGET(API.baseUrl + '/subnets')
      .respond(200, [
        { purpose: 'internal', deprecated: true },
        { purpose: 'external', deprecated: false },
        { purpose: 'internal' },
      ]);

    let result: ISubnet[] = null;

    SubnetReader.listSubnets().then((subnets: ISubnet[]) => {
      result = subnets;
    });

    $http.flush();
    $scope.$digest();

    expect(result[0].label).toBe('internal (deprecated)');
    expect(result[0].deprecated).toBe(true);
    expect(result[1].label).toBe('external');
    expect(result[1].deprecated).toBe(false);
    expect(result[2].label).toBe('internal');
    expect(result[2].deprecated).toBe(false);
  });
開發者ID:emjburns,項目名稱:deck,代碼行數:25,代碼來源:subnet.read.service.spec.ts

示例2: it

  it('should return a non-empty array when configured to do so and invoked', () => {
    const services: IPagerDutyService[] = [
      {
        name: 'one',
        integration_key: 'one_key',
        id: '1',
        policy: 'ABCDEF',
        lastIncidentTimestamp: '1970',
        status: 'active',
      },
      {
        name: '2',
        integration_key: 'two_key',
        id: '2',
        policy: 'ABCDEG',
        lastIncidentTimestamp: '1970',
        status: 'active',
      },
    ];
    $http.whenGET(`${API.baseUrl}/pagerDuty/services`).respond(200, services);

    let executed = false;
    PagerDutyReader.listServices().subscribe((pagerDutyServices: IPagerDutyService[]) => {
      expect(pagerDutyServices).toBeDefined();
      expect(pagerDutyServices.length).toBe(2);
      executed = true; // can't use done() function b/c $digest is already in progress
    });

    $http.flush();
    expect(executed).toBeTruthy();
  });
開發者ID:emjburns,項目名稱:deck,代碼行數:31,代碼來源:pagerDuty.read.service.spec.ts

示例3: beforeEach

    beforeEach(angular.mock.inject($injector => {
        service = $injector.get("DataService");
        $httpBackend = $injector.get("$httpBackend");
        caLondonAppConfig = $injector.get("caLondonAppConfig");

        caLondonAppConfig.API_URL = "https://myurl.com/";

        $httpBackend.whenGET(caLondonAppConfig.API_URL + "api/pages/home").respond([{pageData: "bogus"}]);
    }));
開發者ID:disco-funk,項目名稱:ca-london-angular,代碼行數:9,代碼來源:data.service.spec.ts

示例4: it

 it('returns an empty list instead of failing if tags cannot be loaded', () => {
   $http.whenGET(`${SETTINGS.gateUrl}/tags?entityId=a,b&entityType=servergroups&maxResults=2`).respond(400, 'bad request');
   let result: any = null;
   service.getAllEntityTags('serverGroups', ['a', 'b']).then(r => result = r);
   $http.flush();
   $timeout.flush();
   $http.flush();
   expect(result).toEqual([]);
 });
開發者ID:jcwest,項目名稱:deck,代碼行數:9,代碼來源:entityTags.read.service.spec.ts

示例5: it

    it("should not intercept for a 200 response", () => {
        $location.path("/page/somepage");

        $httpBackend.whenGET("some/url")
            .respond([{some: "data"}]);

        $http.get("some/url")
            .then(() => {
                    expect($cookies.remove).not.toHaveBeenCalled();
                    expect($location.path()).toEqual("/page/somepage");
                });
        $httpBackend.flush();
    });
開發者ID:disco-funk,項目名稱:ca-london-angular,代碼行數:13,代碼來源:http-401-interceptor.service.spec.ts

示例6: beforeEach

    beforeEach(angular.mock.inject($injector => {
        $rootScope = $injector.get("$rootScope");
        $httpBackend = $injector.get("$httpBackend");

        $httpBackend.whenGET("https://myurl.com/api/pages?contentType").respond(testPageData);

        service = $injector.get("PageRouterService");

        service.pageTitles = [];

        service.pageTitles.push({PageTitle: "Some Title", PageName: "somename"});
        service.pageTitles.push({PageTitle: "Some Title 2", PageName: "somename2"});
        service.pageTitles.push({PageTitle: "Some Title 3", PageName: "somename3"});
    }));
開發者ID:disco-funk,項目名稱:ca-london-angular,代碼行數:14,代碼來源:page-router.service.spec.ts

示例7: beforeEach

    beforeEach(angular.mock.inject($injector => {
        $controller = $injector.get("$controller");
        $rootScope = $injector.get("$rootScope");
        $window = $injector.get("$window");
        $q = $injector.get("$q");
        $routeParams = $injector.get("$routeParams");
        $templateCache = $injector.get("$templateCache");
        $timeout = $injector.get("$timeout");
        $httpBackend = $injector.get("$httpBackend");
        $scope = $rootScope.$new(true);

        caLondonAppConfig = $injector.get("caLondonAppConfig");
        pageRouterService = $injector.get("PageRouterService");

        caLondonAppConfig.API_URL = "https://myurl.com/";

        $routeParams.pageName = "testpage";

        $httpBackend.whenGET("https://myurl.com/api/pages?contentType")
            .respond([]);
    }));
開發者ID:disco-funk,項目名稱:ca-london-angular,代碼行數:21,代碼來源:page-router.controller.spec.ts

示例8: beforeEach

 beforeEach(() => {
   $http.whenGET(`${SETTINGS.gateUrl}/reports/reservation/v2`).respond(200, []);
 });
開發者ID:brujoand,項目名稱:deck,代碼行數:3,代碼來源:reservationReport.read.service.spec.ts


注:本文中的angular.IHttpBackendService.whenGET方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。