• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript angular.IQService类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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("[email protected]");
     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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript angular.IRootScopeService类代码示例发布时间:2022-05-28
下一篇:
TypeScript angular.IQResolveReject类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap