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


TypeScript testing.beforeEachProviders函數代碼示例

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


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

示例1: beforeEachProviders

import {
  beforeEachProviders,
  describe,
  expect,
  it,
  inject
} from '@angular/core/testing';
import { MywebsiteAppComponent } from '../app/mywebsite.component';

beforeEachProviders(() => [MywebsiteAppComponent]);

describe('App: Mywebsite', () => {
  it('should create the app',
      inject([MywebsiteAppComponent], (app: MywebsiteAppComponent) => {
    expect(app).toBeTruthy();
  }));

  it('should have as title \'My Website\'',
      inject([MywebsiteAppComponent], (app: MywebsiteAppComponent) => {
    expect(app.title).toEqual('My Website');
  }));
});

describe('my own test', function(){

  it('number schould be positive',
    inject([MywebsiteAppComponent], (app: MywebsiteAppComponent) => {
      expect(app).toBeGreaterThan(-1);
    }));

})
開發者ID:Saturn91,項目名稱:MyWebsite,代碼行數:31,代碼來源:mywebsite.component.spec.ts

示例2: beforeEachProviders

import {
  beforeEachProviders,
  describe,
  expect,
  it,
  inject
} from '@angular/core/testing';
import { CliProjAppComponent } from '../app/cli-proj.component';

beforeEachProviders(() => [CliProjAppComponent]);

describe('App: CliProj', () => {
  it('should create the app',
      inject([CliProjAppComponent], (app: CliProjAppComponent) => {
    expect(app).toBeTruthy();
  }));

  it('should have as title \'cli-proj works!\'',
      inject([CliProjAppComponent], (app: CliProjAppComponent) => {
    expect(app.title).toEqual('cli-proj works!');
  }));
});
開發者ID:manoj-nama,項目名稱:ng2-playarea,代碼行數:22,代碼來源:cli-proj.component.spec.ts

示例3: beforeEachProviders

import {beforeEachProviders, describe, expect, it, inject} from '@angular/core/testing';
import {PeriscopeAppComponent} from '../app/periscope.component';

beforeEachProviders(() => [PeriscopeAppComponent]);

describe('App: Periscope', () => {
  it('should create the app', inject([PeriscopeAppComponent], (app: PeriscopeAppComponent) => {
       expect(app).toBeTruthy();
     }));
});
開發者ID:TheLarkInn,項目名稱:periscope,代碼行數:10,代碼來源:periscope.component.spec.ts

示例4: beforeEachProviders

import {
  beforeEachProviders,
  describe,
  expect,
  it,
  inject
} from '@angular/core/testing';
import { GithubInfoAppComponent } from '../app/github-info.component';

beforeEachProviders(() => [GithubInfoAppComponent]);

describe('App: GithubInfo', () => {
  it('should create the app',
      inject([GithubInfoAppComponent], (app: GithubInfoAppComponent) => {
    expect(app).toBeTruthy();
  }));

  it('should have as title \'github-info works!\'',
      inject([GithubInfoAppComponent], (app: GithubInfoAppComponent) => {
    expect(app.title).toEqual('github-info works!');
  }));
});
開發者ID:laterbreh,項目名稱:github-info,代碼行數:22,代碼來源:github-info.component.spec.ts

示例5: beforeEachProviders

import {
  beforeEachProviders,
  describe,
  expect,
  it,
  inject
} from '@angular/core/testing';
import { CashFlowAppComponent } from '../app/cash-flow.component';

beforeEachProviders(() => [CashFlowAppComponent]);

describe('App: CashFlow', () => {
  it('should create the app',
      inject([CashFlowAppComponent], (app: CashFlowAppComponent) => {
    expect(app).toBeTruthy();
  }));

  it('should have as title \'cash-flow works!\'',
      inject([CashFlowAppComponent], (app: CashFlowAppComponent) => {
    expect(app.title).toEqual('cash-flow works!');
  }));
});
開發者ID:EscuelaIt,項目名稱:Angular2,代碼行數:22,代碼來源:cash-flow.component.spec.ts

示例6: beforeEachProviders

import {
  beforeEachProviders,
  describe,
  expect,
  it,
  inject
} from '@angular/core/testing';
import { AngularObservableAppComponent } from '../app/angular-observable.component';

beforeEachProviders(() => [AngularObservableAppComponent]);

describe('App: AngularObservable', () => {
  it('should create the app',
      inject([AngularObservableAppComponent], (app: AngularObservableAppComponent) => {
    expect(app).toBeTruthy();
  }));

  it('should have as title \'angular-observable works!\'',
      inject([AngularObservableAppComponent], (app: AngularObservableAppComponent) => {
    expect(app.title).toEqual('angular-observable works!');
  }));
});
開發者ID:MathieuNls,項目名稱:mastering-angular2,代碼行數:22,代碼來源:angular-observable.component.spec.ts

示例7: beforeEachProviders

import {
  beforeEachProviders,
  describe,
  expect,
  it,
  inject
} from '@angular/core/testing';
import { ChangeCalculatorAppComponent } from '../app/change-calculator.component';

beforeEachProviders(() => [ChangeCalculatorAppComponent]);

describe('App: ChangeCalculator', () => {
  it('should create the app',
      inject([ChangeCalculatorAppComponent], (app: ChangeCalculatorAppComponent) => {
    expect(app).toBeTruthy();
  }));

  // it('should have as title \'change-calculator works!\'',
  //     inject([ChangeCalculatorAppComponent], (app: ChangeCalculatorAppComponent) => {
  //   expect(app.title).toEqual('change-calculator works!');
  // }));
});
開發者ID:xap5xap,項目名稱:changeCalculator,代碼行數:22,代碼來源:change-calculator.component.spec.ts

示例8: beforeEachProviders

import {
  beforeEachProviders,
  describe,
  expect,
  it,
  inject
} from '@angular/core/testing';
import { AngularPolymerDotnetAppComponent } from '../app/angular-polymer-dotnet.component';

beforeEachProviders(() => [AngularPolymerDotnetAppComponent]);

describe('App: AngularPolymerDotnet', () => {
  it('should create the app',
      inject([AngularPolymerDotnetAppComponent], (app: AngularPolymerDotnetAppComponent) => {
    expect(app).toBeTruthy();
  }));

  it('should have as title \'angular-polymer-dotnet works!\'',
      inject([AngularPolymerDotnetAppComponent], (app: AngularPolymerDotnetAppComponent) => {
    expect(app.title).toEqual('angular-polymer-dotnet works!');
  }));
});
開發者ID:peterblazejewicz,項目名稱:polymer-angular-dotnet,代碼行數:22,代碼來源:angular-polymer-dotnet.component.spec.ts

示例9: beforeEachProviders

import {
  beforeEachProviders,
  describe,
  expect,
  it,
  inject
} from '@angular/core/testing';
import { Ng2WorkshopAppComponent } from '../app/ng2-workshop.component';

beforeEachProviders(() => [Ng2WorkshopAppComponent]);

describe('App: Ng2Workshop', () => {
  it('should create the app',
      inject([Ng2WorkshopAppComponent], (app: Ng2WorkshopAppComponent) => {
    expect(app).toBeTruthy();
  }));

  it('should have as title \'ng2-workshop works!\'',
      inject([Ng2WorkshopAppComponent], (app: Ng2WorkshopAppComponent) => {
    expect(app.title).toEqual('ng2-workshop works!');
  }));
});
開發者ID:mrrobbins,項目名稱:angular-summit-2016,代碼行數:22,代碼來源:ng2-workshop.component.spec.ts

示例10: describe

describe('Core Definition Service', () => {

  beforeEachProviders(() => {
    return [
      CoreDefinitionService,
      provide(ConfigService, {
        useValue: {
          get: function () { return 'http://localhost:8000'; }
        }
      }),
    ];
  });

  describe('loadDefinitions', () => {

    it('should ask for definitions', inject([CoreDefinitionService], (cds) => {
      spyOn(cds, 'getDefinitions').and.returnValue(Observable.of({}));

      cds.loadDefinitions();

      expect(cds.getDefinitions).toHaveBeenCalled();
    }));

    it('should store definitions to local storage', inject([CoreDefinitionService], (cds) => {
      spyOn(cds, 'getDefinitions').and.returnValue(Observable.of({}));
      spyOn(localStorage, 'setItem');

      cds.loadDefinitions();

      expect(localStorage.setItem).toHaveBeenCalledWith('definitions', '{}');
    }));

    it('should dispatch definitions', inject([CoreDefinitionService], (cds) => {
      spyOn(cds, 'getDefinitions').and.returnValue(Observable.of({
        'required': 'hydra:required'
      }));

      cds.loadDefinitions();

      cds.definitions.subscribe(definitions => {
        expect(definitions.required).toEqual('hydra:required');
      });
    }));

    it('should accept string as definition', inject([CoreDefinitionService], (cds) => {
      spyOn(cds, 'getDefinitions').and.returnValue(Observable.of({
        'required': 'hydra:required'
      }));
      spyOn(cds, 'add');

      cds.loadDefinitions();

      expect(cds.add).toHaveBeenCalledWith('required', 'hydra:required', {});
    }));

    it('should accept object with @id as definition', inject([CoreDefinitionService], (cds) => {
      spyOn(cds, 'getDefinitions').and.returnValue(Observable.of({
        'property': {
          '@id': 'hydra:property'
        }
      }));
      spyOn(cds, 'add');

      cds.loadDefinitions();

      expect(cds.add).toHaveBeenCalledWith('property', 'hydra:property', {});
    }));

    it('should reject object without @id as definition', inject([CoreDefinitionService], (cds) => {
      spyOn(cds, 'getDefinitions').and.returnValue(Observable.of({
        'cc:license': {
          '@type': '@id'
        }
      }));
      spyOn(cds, 'add');

      cds.loadDefinitions();

      expect(cds.add).not.toHaveBeenCalled();
    }));

  });

  describe('getDefinitions', () => {

    beforeEachProviders(() => {
      return [
        MockBackend,
        BaseRequestOptions,
        provide(Http, {
          useFactory: (backend, defaultOptions) => {
            return new Http(backend, defaultOptions);
          }, deps: [MockBackend, BaseRequestOptions]
        })
      ];
    });


    it('should dispatch local storage definitions', inject([CoreDefinitionService], (cds) => {
      spyOn(localStorage, 'getItem').and.returnValue('{"property":"hydra:property"}');
//.........這裏部分代碼省略.........
開發者ID:coopTilleuls,項目名稱:hm-admin,代碼行數:101,代碼來源:CoreDefinition.service.spec.ts


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