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


TypeScript instanceType.service.InstanceTypeService類代碼示例

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


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

示例1: describe

describe('Service: instanceTypeService', function () {

  let instanceTypeService: InstanceTypeService,
      $q: ng.IQService,
      $scope: ng.IScope;

  const m3Category: IInstanceTypeCategory = {
    type: 'general',
    families: [{
      type: 'm3',
      instanceTypes: [
        {name: 'm3.medium'},
        {name: 'm3.large'},
        {name: 'm3.xlarge'},
        {name: 'm3.2xlarge'}
      ]
    }]
  };

  const r3Category: IInstanceTypeCategory = {
    type: 'memory',
    families: [{
      type: 'r3',
      instanceTypes: [
        {name: 'r3.large'},
        {name: 'r3.xlarge'},
        {name: 'r3.2xlarge'},
        {name: 'r3.4xlarge'},
      ]
    }]
  };

  const t2Category: IInstanceTypeCategory = {
    type: 'micro',
    families: [{
      type: 't2',
      instanceTypes: [
        {name: 't2.small'},
        {name: 't2.medium'},
      ]
    }]
  };

  const gceCustomInstanceCategory: IInstanceTypeCategory = {
    type: 'buildCustom',
    families: [{
      type: 'buildCustom',
      instanceTypes: [{name: 'buildCustom', nameRegex: /custom-\d{1,2}-\d{4,6}/}]
    }]
  };

  const categories: IInstanceTypeCategory[] = [m3Category, r3Category, t2Category, gceCustomInstanceCategory];

  beforeEach(
    mock.module(INSTANCE_TYPE_SERVICE)
  );

  beforeEach(
    mock.inject(function (_instanceTypeService_: InstanceTypeService, _$q_: ng.IQService, $rootScope: ng.IRootScopeService, serviceDelegate: any) {
      instanceTypeService = _instanceTypeService_;
      $q = _$q_;
      $scope = $rootScope.$new();

      spyOn(serviceDelegate, 'getDelegate').and.returnValue({
        getCategories: () => { return $q.when(categories); }
      });
    })
  );

  describe('find profile name for instance type', function () {

    beforeEach(function() {
      spyOn(instanceTypeService, 'getCategories').and.returnValue($q.when(categories));
    });

    m3Category.families[0].instanceTypes.forEach( function(instanceType) {
      it('should return "general" if the ' + instanceType.name + ' is in the "general" category', function () {
        let result: string = null;
        instanceTypeService.getCategoryForInstanceType('aws', instanceType.name).then(function(category) {
          result = category;
        });
        $scope.$digest();
        expect(result).toBe('general');
      });
    });

    r3Category.families[0].instanceTypes.forEach(function (instanceType) {
      it('should return "memory" if the ' + instanceType.name + ' is in the "memory" category', function () {
        let result: string = null;
        instanceTypeService.getCategoryForInstanceType('aws', instanceType.name).then(function(category) {
          result = category;
        });
        $scope.$digest();
        expect(result).toBe('memory');
      });
    });

    t2Category.families[0].instanceTypes.forEach(function (instanceType) {
      it('should return "micro" if the ' + instanceType.name + ' is in the "micro" category', function () {
        let result: string = null;
//.........這裏部分代碼省略.........
開發者ID:brujoand,項目名稱:deck,代碼行數:101,代碼來源:instanceTypeService.spec.ts

示例2: it

 it('should return "memory" if the ' + instanceType.name + ' is in the "memory" category', function () {
   let result: string = null;
   instanceTypeService.getCategoryForInstanceType('aws', instanceType.name).then(function(category) {
     result = category;
   });
   $scope.$digest();
   expect(result).toBe('memory');
 });
開發者ID:brujoand,項目名稱:deck,代碼行數:8,代碼來源:instanceTypeService.spec.ts


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