本文整理汇总了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);
}));
})
示例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!');
}));
});
示例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();
}));
});
示例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!');
}));
});
示例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!');
}));
});
示例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!');
}));
});
示例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!');
// }));
});
示例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!');
}));
});
示例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"}');
//.........这里部分代码省略.........