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


TypeScript angular.IQService類代碼示例

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


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

示例1: describe

describe('Service: SkinService', () => {
  let appBuilder: ApplicationModelBuilder, scope: IScope, $q: IQService;

  beforeEach(mock.module(APPLICATION_MODEL_BUILDER));

  beforeEach(
    mock.inject(($rootScope: IRootScopeService, _$q_: IQService, applicationModelBuilder: ApplicationModelBuilder) => {
      appBuilder = applicationModelBuilder;
      scope = $rootScope.$new();
      $q = _$q_;
    }),
  );

  describe('instance skin disambiguation', () => {
    beforeEach(() => {
      spyOn(SkinService, 'getAccounts').and.returnValue(
        $q.resolve([
          { name: 'v1-k8s-account', cloudProvider: 'kubernetes', skin: 'v1' },
          { name: 'v2-k8s-account', cloudProvider: 'kubernetes', skin: 'v2' },
          { name: 'appengine-account', cloudProvider: 'appengine', skin: 'v1' },
          { name: 'gce-account', cloudProvider: 'gce' },
        ]),
      );
    });

    it('uses available accounts to determine skin if possible', () => {
      const app = appBuilder.createStandaloneApplication('myApp');

      SkinService.getInstanceSkin('appengine', 'my-instance-id', app).then(skin => {
        expect(skin).toEqual('v1');
      });
      SkinService.getInstanceSkin('gce', 'my-instance-id', app).then(skin => {
        expect(skin).toEqual(null);
      });

      scope.$digest();
    });

    it('scrapes application server groups to determine skin if possible', () => {
      const app = appBuilder.createApplication('myApp', [
        {
          key: 'serverGroups',
          data: [
            {
              name: 'myServerGroup',
              account: 'v2-k8s-account',
              cloudProvider: 'kubernetes',
              instances: [{ id: 'my-instance-id' }],
              serverGroups: [],
            },
          ],
        },
        {
          key: 'loadBalancers',
          data: [],
        },
      ]);

      SkinService.getInstanceSkin('kubernetes', 'my-instance-id', app).then(skin => {
        expect(skin).toEqual('v2');
      });

      scope.$digest();
    });

    it('scrapes application load balancers to determine skin if possible', () => {
      const app = appBuilder.createApplication('myApp', [
        {
          key: 'loadBalancers',
          data: [
            {
              name: 'myLoadBalancer',
              account: 'v2-k8s-account',
              cloudProvider: 'kubernetes',
              instances: [{ id: 'my-instance-id' }],
            },
          ],
        },
        {
          key: 'serverGroups',
          data: [],
        },
      ]);

      SkinService.getInstanceSkin('kubernetes', 'my-instance-id', app).then(skin => {
        expect(skin).toEqual('v2');
      });

      scope.$digest();
    });

    it("scrapes application load balancers' server groups to determine skin if possible", () => {
      const app = appBuilder.createApplication('myApp', [
        {
          key: 'loadBalancers',
          data: [
            {
              name: 'myLoadBalancer',
              account: 'v2-k8s-account',
              cloudProvider: 'kubernetes',
//.........這裏部分代碼省略.........
開發者ID:mizzy,項目名稱:deck,代碼行數:101,代碼來源:skin.service.spec.ts

示例2: describe

describe('Travis Stage Controller', () => {
  let $scope: IScope, $q: IQService, $ctrl: IControllerService;

  beforeEach(mock.module(TRAVIS_STAGE, require('angular-ui-bootstrap')));

  beforeEach(
    mock.inject(($controller: IControllerService, $rootScope: IRootScopeService, _$q_: IQService) => {
      $ctrl = $controller;
      $scope = $rootScope.$new();
      $q = _$q_;
    }),
  );

  const initialize = (stage: any): TravisStage => {
    return $ctrl(TravisStage, {
      stage,
      $scope,
    });
  };

  describe('updateJobsList', () => {
    beforeEach(() => {
      spyOn(IgorService, 'listMasters').and.returnValue($q.when([]));
    });

    it('does nothing if master is parameterized', () => {
      spyOn(IgorService, 'listJobsForMaster');
      const stage = {
        master: '${parameter.master}',
      };
      const controller = initialize(stage);
      $scope.$digest();
      expect(controller.jobs).toBeUndefined();
      expect(controller.viewState.jobsLoaded).toBe(true);
      expect((IgorService.listJobsForMaster as Spy).calls.count()).toBe(0);
    });

    it('does nothing if job is parameterized', () => {
      spyOn(IgorService, 'listJobsForMaster');
      const stage = {
        master: 'not-parameterized',
        job: '${parameter.job}',
      };
      const controller = initialize(stage);
      $scope.$digest();
      expect(controller.jobs).toBeUndefined();
      expect(controller.viewState.jobsLoaded).toBe(true);
      expect((IgorService.listJobsForMaster as Spy).calls.count()).toBe(0);
    });

    it('gets jobs from igor and adds them to scope', () => {
      spyOn(IgorService, 'listJobsForMaster').and.returnValue($q.when(['a', 'b']));
      const stage = {
        master: 'not-parameterized',
      };
      const controller = initialize(stage);
      $scope.$digest();
      expect(controller.jobs).toEqual(['a', 'b']);
      expect(controller.viewState.jobsLoaded).toBe(true);
    });

    it('clears job if no longer present when retrieving from igor', () => {
      spyOn(IgorService, 'listJobsForMaster').and.returnValue($q.when(['a', 'b']));
      spyOn(IgorService, 'getJobConfig').and.returnValue($q.when(null));
      const stage = {
        master: 'not-parameterized',
        job: 'c',
      };
      const controller = initialize(stage);
      $scope.$digest();
      expect(controller.jobs).toEqual(['a', 'b']);
      expect(controller.viewState.jobsLoaded).toBe(true);
      expect(stage.job).toBe('');
    });
  });

  describe('updateJobConfig', () => {
    beforeEach(() => {
      spyOn(IgorService, 'listMasters').and.returnValue($q.when([]));
    });

    it('does nothing if master is parameterized', () => {
      spyOn(IgorService, 'listJobsForMaster');
      spyOn(IgorService, 'getJobConfig');
      const stage = {
        master: '${parameter.master}',
      };
      const controller = initialize(stage);
      $scope.$digest();
      expect(controller.jobs).toBeUndefined();
      expect(controller.viewState.jobsLoaded).toBe(true);
      expect((IgorService.listJobsForMaster as Spy).calls.count()).toBe(0);
      expect((IgorService.getJobConfig as Spy).calls.count()).toBe(0);
    });

    it('does nothing if job is parameterized', () => {
      spyOn(IgorService, 'listJobsForMaster');
      spyOn(IgorService, 'getJobConfig');
      const stage = {
        master: 'not-parameterized',
//.........這裏部分代碼省略.........
開發者ID:emjburns,項目名稱:deck,代碼行數:101,代碼來源:travisStage.controller.spec.ts

示例3: describe

describe("CaStructuredDataCtrl", () => {
    let ctrl: CaStructuredDataCtrl, session: SessionService, alertModalService: AlertModalService,
        caPageHeaderInfoService: CaStructuredDataService, dataService: DataService;
    let $controller: IControllerService, $rootScope: IRootScopeService, $q: IQService,
        $sce: ISCEService, $filter: IFilterService;

    const fakeLdJson: Array<IStructuredData> = [{
        "@context": "http://schema.org",
        "@type": "Event",
        "name": "Bogus structured data",
        "location" : {
            "@type" : "Place",
            "name" : "Studio 54"
        }
    }];

    beforeEach(() => angular.mock.module(CORE_MODULE));

    beforeEach(angular.mock.inject($injector => {
        $controller = $injector.get("$controller");
        $rootScope = $injector.get("$rootScope");
        $sce = $injector.get("$sce");
        $q = $injector.get("$q");
        $filter = $injector.get("$filter");

        dataService = $injector.get("DataService");

        spyOn(dataService, "getData").and.callFake(() => {
            const deferred: IDeferred<Array<IStructuredData>> = $q.defer();
            deferred.resolve(fakeLdJson);
            return deferred.promise;
        });

        session = $injector.get("SessionService");
        alertModalService = $injector.get("AlertModalService");
        caPageHeaderInfoService = $injector.get("CaStructuredDataService");

        $sce.trustAsHtml = data => `trusted ${data}`;

        ctrl = $controller("CaStructuredDataCtrl", {});
    }));

    it("should instantiate and load data when data ready event is emitted", () => {
        caPageHeaderInfoService.structuredData = [];

        expect(ctrl).toBeDefined();
        expect(ctrl.structuredData).toEqual([]);

        $rootScope.$digest();

        expect(ctrl.structuredData).toEqual(fakeLdJson);
    });

    describe("#getLdJson", () => {
        it("should return trusted version of structured ld+json data", () => {
            ctrl.structuredData = [{something: "some data"}];

            const actual: Array<IStructuredData> = ctrl.getLdJson();

            expect(actual).toEqual("trusted [\n  {\n    \"something\": \"some data\"\n  }\n]");
        });
    });
});
開發者ID:disco-funk,項目名稱:ca-london-angular,代碼行數:63,代碼來源:ca-structured-data.controller.spec.ts

示例4: normalizeServerGroup

 public normalizeServerGroup(serverGroup: any): IPromise<any> {
   return this.$q.when(serverGroup);
 }
開發者ID:robfletcher,項目名稱:deck,代碼行數:3,代碼來源:serverGroupTransformer.service.ts

示例5:

 const application: Application = { name: 'deck', executions: { refresh: () => $q.when(null) } } as any;
開發者ID:spinnaker,項目名稱:deck,代碼行數:1,代碼來源:execution.service.spec.ts

示例6: spyOn

 spyOn(ctrl, "getForgottenDialogResult").and.callFake(() => {
     const deferred: IDeferred<any> = $q.defer();
     deferred.resolve("bogus@user.name");
     return deferred.promise;
 });
開發者ID:disco-funk,項目名稱:ca-london-angular,代碼行數:5,代碼來源:login.controller.spec.ts

示例7: beforeEach

 beforeEach(() => {
   spyOn(IgorService, 'listMasters').and.returnValue($q.when([]));
 });
開發者ID:emjburns,項目名稱:deck,代碼行數:3,代碼來源:travisStage.controller.spec.ts


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