本文整理匯總了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"}');
//.........這裏部分代碼省略.........