当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript angular.IComponentControllerService类代码示例

本文整理汇总了TypeScript中angular.IComponentControllerService的典型用法代码示例。如果您正苦于以下问题:TypeScript IComponentControllerService类的具体用法?TypeScript IComponentControllerService怎么用?TypeScript IComponentControllerService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IComponentControllerService类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: describe

describe('Controller: ChaosMonkeyExceptions', () => {
  let $componentController: IComponentControllerService,
    $ctrl: ChaosMonkeyExceptionsController,
    $scope: IScope,
    $q: IQService;

  const initializeController = (data: any) => {
    $ctrl = $componentController(
      'chaosMonkeyExceptions',
      { $scope: null, $q },
      data,
    ) as ChaosMonkeyExceptionsController;
  };

  beforeEach(mock.module(CHAOS_MONKEY_EXCEPTIONS_COMPONENT));

  beforeEach(
    mock.inject(
      (_$componentController_: IComponentControllerService, _$q_: IQService, $rootScope: IRootScopeService) => {
        $scope = $rootScope.$new();
        $componentController = _$componentController_;
        $q = _$q_;
      },
    ),
  );

  describe('data initialization', () => {
    it('gets all accounts, then adds wildcard and regions per account to vm', () => {
      const accounts: any = [
        { name: 'prod', regions: [{ name: 'us-east-1' }, { name: 'us-west-1' }] },
        { name: 'test', regions: [{ name: 'us-west-2' }, { name: 'eu-west-1' }] },
      ];

      spyOn(AccountService, 'listAllAccounts').and.returnValue($q.when(accounts));

      initializeController(null);
      $ctrl.application = ApplicationModelBuilder.createApplicationForTests('app', {
        key: 'serverGroups',
        loader: () => $q.resolve([]),
        onLoad: (_app, data) => $q.resolve(data),
      });
      $ctrl.application.serverGroups.refresh();
      $scope.$digest();

      $ctrl.config = new ChaosMonkeyConfig($ctrl.application.attributes.chaosMonkey || {});

      $ctrl.$onInit();
      $scope.$digest();

      expect($ctrl.accounts).toEqual([accounts[0], accounts[1]]);
      expect($ctrl.regionsByAccount).toEqual({
        prod: ['*', 'us-east-1', 'us-west-1'],
        test: ['*', 'us-west-2', 'eu-west-1'],
      });
    });
  });
});
开发者ID:emjburns,项目名称:deck,代码行数:57,代码来源:chaosMonkeyExceptions.component.spec.ts

示例2: describe

describe('Controller: deploymentStrategySelector', () => {

  beforeEach(
    mock.module(DEPLOYMENT_STRATEGY_SELECTOR_COMPONENT)
  );

  beforeEach(mock.inject(($componentController: IComponentControllerService) => {
    $componentControllerService = $componentController;
  }));

  let $ctrl: DeploymentStrategySelectorController,
      $componentControllerService: IComponentControllerService,
      deployCommand: IDeploymentCommand;

  const strategies: IDeploymentStrategy[] = [
    {
      key: '',
      label: '',
      description: '',
    },
    {
      key: 'no-extra-fields',
      label: '',
      description: '',
    },
    {
      key: 'extra-fields-1',
      label: '',
      description: '',
      additionalFields: ['fieldA'],
      additionalFieldsTemplateUrl: 'aaa'
    },
    {
      key: 'extra-fields-2',
      label: '',
      description: '',
      additionalFields: ['fieldA'],
      additionalFieldsTemplateUrl: 'bbb'
    },
  ];

  const initializeController = (command: IDeploymentCommand) => {
    deployCommand = command;
    $ctrl = $componentControllerService('deploymentStrategySelector', {}, { command }) as DeploymentStrategySelectorController;
    spyOn(DeploymentStrategyRegistry, 'listStrategies').and.returnValue(strategies);
    spyOn(DeploymentStrategyRegistry, 'getStrategy').and.callFake((key: string) => strategies.find(s => s.key === key));
  };

  describe('changing strategies', () => {

    it('removes previous fields when switching strategies if new strategy does not also have the field', () => {
      const command = { strategy: 'extra-fields-1', fieldA: true };
      initializeController(command);
      $ctrl.$onInit();
      expect(command.fieldA).not.toBeUndefined();

      // change to strategy that also has the field
      command.strategy = 'extra-fields-2';
      $ctrl.selectStrategy();
      expect(command.fieldA).not.toBeUndefined();

      // change to strategy that does not have the field
      command.strategy = 'no-extra-fields';
      $ctrl.selectStrategy();
      expect(command.fieldA).toBeUndefined();
    });

    it('removes template when not present', () => {
      const command = { strategy: '' };
      initializeController(command);
      $ctrl.$onInit();
      expect($ctrl.additionalFieldsTemplateUrl).toBeUndefined();

      // change to strategy that has a template
      command.strategy = 'extra-fields-2';
      $ctrl.selectStrategy();
      expect($ctrl.additionalFieldsTemplateUrl).toBe('bbb');

      // change to strategy that does not have a template
      command.strategy = 'no-extra-fields';
      $ctrl.selectStrategy();
      expect($ctrl.additionalFieldsTemplateUrl).toBeUndefined();
    });
  });
});
开发者ID:jcwest,项目名称:deck,代码行数:85,代码来源:deploymentStrategySelector.component.spec.ts

示例3: describe

describe('Component: deployInitializer', () => {
  let ctrl: DeployInitializerController, $componentController: IComponentControllerService, application: Application;

  const initialize = () => {
    ctrl = $componentController(
      'deployInitializer',
      {},
      { application, command: { viewState: {} }, cloudProvider: 'aws' },
    ) as DeployInitializerController;
    ctrl.$onInit();
  };

  beforeEach(mock.module(DEPLOY_INITIALIZER_COMPONENT));

  beforeEach(
    mock.inject((_$componentController_: IComponentControllerService) => {
      $componentController = _$componentController_;
    }),
  );

  describe('template initialization', () => {
    it('creates separate template options for each account and region of a cluster', () => {
      application = ApplicationModelBuilder.createApplicationForTests('app', { key: 'serverGroups', lazy: true });
      application.getDataSource('serverGroups').data = [
        {
          name: 'sg1',
          cluster: 'cluster1',
          account: 'test',
          region: 'us-east-1',
          cloudProvider: 'aws',
          category: 'serverGroup',
        },
        {
          name: 'sg2',
          cluster: 'cluster1',
          account: 'prod',
          region: 'us-east-1',
          cloudProvider: 'aws',
          category: 'serverGroup',
        },
        {
          name: 'sg2',
          cluster: 'cluster1',
          account: 'prod',
          region: 'us-east-1',
          cloudProvider: 'aws',
          category: 'serverGroup',
        },
      ];

      initialize();
      const templates = ctrl.templates;

      expect(templates.length).toBe(3);

      // first template is always "None"
      expect(templates[0].label).toBe('None');
      expect(templates[1].cluster).toBe('cluster1');
      expect(templates[1].cluster).toBe('cluster1');
      expect(templates[2].cluster).toBe('cluster1');
    });
  });
});
开发者ID:emjburns,项目名称:deck,代码行数:63,代码来源:deployInitializer.component.spec.ts

示例4: describe

describe('PagerDutyTagComponent', () => {
  let $componentController: IComponentControllerService, $ctrl: PagerDutyTagComponentController;

  const services: IPagerDutyService[] = [
    {
      name: 'name1',
      integration_key: 'integrationKey1',
      id: '1',
      policy: 'ABCDEF',
      lastIncidentTimestamp: '1970',
      status: 'active',
    },
    {
      name: 'name2',
      integration_key: 'integrationKey2',
      id: '2',
      policy: 'ABCDEG',
      lastIncidentTimestamp: '1970',
      status: 'active',
    },
    {
      name: 'name3',
      integration_key: 'integrationKey3',
      id: '3',
      policy: 'ABCDEH',
      lastIncidentTimestamp: '1970',
      status: 'active',
    },
  ];

  const initialize = (apiKey: string) => {
    $ctrl = $componentController('pagerDutyTag', { $scope: null }, { apiKey }) as PagerDutyTagComponentController;
    $ctrl.$onInit();
  };

  beforeEach(mock.module(PAGER_DUTY_TAG_COMPONENT));

  beforeEach(
    mock.inject((_$componentController_: IComponentControllerService) => {
      $componentController = _$componentController_;
      spyOn(PagerDutyReader, 'listServices').and.returnValue(Observable.of(services));
    }),
  );

  it('should set notFound flag when service is not found for api key', () => {
    initialize('invalidKey');
    expect($ctrl.servicesLoaded).toBe(true);
    expect($ctrl.currentService).toBe(undefined);
  });

  it('should set the current service', () => {
    initialize('integrationKey2');
    expect($ctrl.currentService).toBe(services[1]);
  });

  it('should update the current service when key changes', () => {
    initialize('integrationKey2');
    expect($ctrl.currentService).toBe(services[1]);
    $ctrl.apiKey = 'integrationKey3';
    $ctrl.$onChanges();
    expect($ctrl.currentService).toBe(services[2]);
  });
});
开发者ID:emjburns,项目名称:deck,代码行数:63,代码来源:pagerDutyTag.component.spec.ts

示例5: describe

describe('Component: metric selector', () => {
  let $ctrl: MetricSelectorController;
  let $componentController: IComponentControllerService;
  let $q: IQService;
  let $scope: IScope;
  const alarmUpdated = new Subject<void>();

  let alarm: IUpsertAlarmDescription;
  let serverGroup: IServerGroup;

  beforeEach(mock.module(METRIC_SELECTOR_COMPONENT));

  beforeEach(
    mock.inject(
      (_$componentController_: IComponentControllerService, _$q_: IQService, $rootScope: IRootScopeService) => {
        $componentController = _$componentController_;
        $q = _$q_;
        $scope = $rootScope.$new();
      },
    ),
  );

  const initialize = () => {
    $ctrl = $componentController(
      'awsMetricSelector',
      { $scope },
      { alarm, serverGroup, alarmUpdated },
    ) as MetricSelectorController;
    $ctrl.$onInit();
  };

  const makeServerGroup = (name: string): IServerGroup => {
    return {
      name,
      account: 'test',
      cloudProvider: 'aws',
      cluster: undefined,
      region: 'us-east-1',
      type: undefined,
      instanceCounts: undefined,
      instances: undefined,
    };
  };

  const makeAlarm = (
    namespace: string,
    metricName: string,
    comparisonOperator: AlarmComparisonOperator,
    dimensions: IMetricAlarmDimension[],
  ): IUpsertAlarmDescription => {
    return {
      asgName: undefined,
      name: undefined,
      region: undefined,
      alarmDescription: undefined,
      evaluationPeriods: undefined,
      period: undefined,
      threshold: undefined,
      statistic: undefined,
      unit: undefined,
      alarmActionArns: undefined,
      insufficientDataActionArns: undefined,
      okActionArns: undefined,
      comparisonOperator,
      dimensions,
      metricName,
      namespace,
    };
  };

  describe('initialization', () => {
    beforeEach(() => {
      alarm = makeAlarm('AWS/EC2', 'CPUUtilization', 'GreaterThanThreshold', [
        {
          name: 'AutoScalingGroupName',
          value: 'asg-v000',
        },
      ]);
    });

    it('sets advanced mode when dimensions are non-standard', () => {
      serverGroup = makeServerGroup('asg-v000');
      initialize();
      expect($ctrl.state.advancedMode).toBe(false);

      serverGroup = makeServerGroup('other-v001');
      initialize();
      $ctrl.$onInit();
      expect($ctrl.state.advancedMode).toBe(true);
    });

    it('updates available metrics on initialization, triggers alarmUpdated once', () => {
      spyOn(CloudMetricsReader, 'listMetrics').and.returnValue(
        $q.when([
          {
            namespace: 'AWS/EC2',
            name: 'CPUUtilization',
            dimensions: [{ name: 'AutoScalingGroupName', value: 'asg-v000' }],
          },
          {
//.........这里部分代码省略.........
开发者ID:mizzy,项目名称:deck,代码行数:101,代码来源:metricSelector.component.spec.ts

示例6:

 const initialize = () => {
   $ctrl = $componentController(
     'awsMetricSelector',
     { $scope },
     { alarm, serverGroup, alarmUpdated },
   ) as MetricSelectorController;
   $ctrl.$onInit();
 };
开发者ID:emjburns,项目名称:deck,代码行数:8,代码来源:metricSelector.component.spec.ts

示例7:

 const initialize = () => {
   ctrl = $componentController(
     'deployInitializer',
     {},
     { application, command: { viewState: {} }, cloudProvider: 'aws' },
   ) as DeployInitializerController;
   ctrl.$onInit();
 };
开发者ID:mizzy,项目名称:deck,代码行数:8,代码来源:deployInitializer.component.spec.ts

示例8: spyOn

 const initializeController = (command: IDeploymentCommand) => {
   $ctrl = $componentControllerService(
     'deploymentStrategySelector',
     {},
     { command },
   ) as DeploymentStrategySelectorController;
   spyOn(DeploymentStrategyRegistry, 'listStrategies').and.returnValue(strategies);
   spyOn(DeploymentStrategyRegistry, 'getStrategy').and.callFake((key: string) => strategies.find(s => s.key === key));
 };
开发者ID:mizzy,项目名称:deck,代码行数:9,代码来源:deploymentStrategySelector.component.spec.ts

示例9: spyOn

 const initialize = (accounts: IAccount[], images: IDockerImage[]) => {
   spyOn(AccountService, 'listAccounts').and.returnValue($q.when(accounts));
   spyOn(DockerImageReader, 'findImages').and.returnValue($q.when(images));
   $ctrl = $componentController(
     'dockerImageAndTagSelector',
     { DockerImageReader },
     { organization, registry, repository, tag, account, showRegistry },
   ) as DockerImageAndTagSelectorController;
   $ctrl.$onInit();
   $scope.$digest();
 };
开发者ID:mizzy,项目名称:deck,代码行数:11,代码来源:dockerImageAndTagSelector.component.spec.ts

示例10:

 const initialize = (apiKey: string) => {
   $ctrl = $componentController('pagerDutyTag', { $scope: null }, { apiKey }) as PagerDutyTagComponentController;
   $ctrl.$onInit();
 };
开发者ID:emjburns,项目名称:deck,代码行数:4,代码来源:pagerDutyTag.component.spec.ts


注:本文中的angular.IComponentControllerService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。