本文整理汇总了TypeScript中@angular/testing.beforeEach函数的典型用法代码示例。如果您正苦于以下问题:TypeScript beforeEach函数的具体用法?TypeScript beforeEach怎么用?TypeScript beforeEach使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了beforeEach函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe('SumPipe', () => {
let pipe: SumPipe;
beforeEach(() => {
pipe = new SumPipe();
});
it('Should return 10', () => {
expect(pipe.transform([1,2,3,4])).toEqual(10);
});
it('Should return 1', () => {
expect(pipe.transform([1])).toEqual(1);
});
it('Should return 2', () => {
expect(pipe.transform([1,1])).toEqual(2);
});
it('Should return 15', () => {
expect(pipe.transform(15)).toEqual(15);
});
});
开发者ID:josx,项目名称:angular-pipes,代码行数:29,代码来源:sum.pipe.spec.ts
示例2: describe
describe('RepeatPipe', () => {
let pipe: RepeatPipe;
beforeEach(() => {
pipe = new RepeatPipe();
});
it('Should do nothing', () => {
expect(pipe.transform('a', 1, '')).toEqual('a');
});
it('Should repeat two times', () => {
expect(pipe.transform('a', 2, '')).toEqual('aa');
});
it('Should repeat two times with space', () => {
expect(pipe.transform('a', 2, ' ')).toEqual('a a');
});
it('Should return the value unchanged', () => {
expect(pipe.transform(1, null)).toEqual(1);
});
});
开发者ID:josx,项目名称:angular-pipes,代码行数:30,代码来源:repeat.pipe.spec.ts
示例3: describe
describe('CountPipe', () => {
let pipe: CountPipe;
beforeEach(() => {
pipe = new CountPipe();
});
it('Should return the length of the collection', () => {
expect(pipe.transform([1,2])).toEqual(2);
});
it('Should return the length of the object (keys)', () => {
expect(pipe.transform({ a: 1, b: 2, c: 3})).toEqual(3);
});
it('Should return the value unchanged', () => {
expect(pipe.transform('a')).toEqual('a');
});
});
开发者ID:josx,项目名称:angular-pipes,代码行数:26,代码来源:count.pipe.spec.ts
示例4: describe
describe('CeilPipe', () => {
let pipe: CeilPipe;
beforeEach(() => {
pipe = new CeilPipe();
});
it('Should return 4', () => {
expect(pipe.transform(3.4, 0)).toEqual(4);
});
it('Should return 1', () => {
expect(pipe.transform(1, 0)).toEqual(1);
});
it('Should return 1', () => {
expect(pipe.transform(0.65, 0)).toEqual(1);
});
it('Should return 1.5', () => {
expect(pipe.transform(1.5, 1)).toEqual(1.5);
});
it('Should return 1.55', () => {
expect(pipe.transform(1.5444, 2)).toEqual(1.55);
});
});
开发者ID:josx,项目名称:angular-pipes,代码行数:34,代码来源:ceil.pipe.spec.ts
示例5: describe
describe('Login Component', () => {
setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
let tcb: TestComponentBuilder;
beforeEachProviders(() => [
TestComponentBuilder,
provide(DirectiveResolver, {useClass: MockDirectiveResolver}),
provide(ViewResolver, {useClass: MockViewResolver}),
LoginComponent,
]);
beforeEach(inject([TestComponentBuilder], (tcb_) => {
tcb = tcb_;
}));
it('should render form', (done) => {
tcb.createAsync(LoginComponent)
.then((fixture) => {
let element = fixture.nativeElement;
fixture.detectChanges();
let form = element.querySelector('form');
expect(form).toBeTruthy();
expect(form.querySelector('input[name="username"]')).toBeTruthy();
expect(form.querySelector('input[name="password"]')).toBeTruthy();
done();
});
});
});
开发者ID:mahpah,项目名称:ng2-pack,代码行数:28,代码来源:login.component.spec.ts
示例6: describe
describe('TakePipe', () => {
let pipe: TakePipe;
beforeEach(() => {
pipe = new TakePipe();
});
it('Should return []', () => {
expect(pipe.transform([])).toEqual([]);
});
it('Should return [1]', () => {
const value = [1, 2, 3, 4];
expect(pipe.transform(value)).toEqual([1]);
expect(value).toEqual([1, 2, 3, 4]); // Check integrity
});
it ('Should return [1, 2]', () => {
expect(pipe.transform([1, 2, 3, 4], 2)).toEqual([1, 2]);
});
it('Should return the value unchanged', () => {
expect(pipe.transform('a')).toEqual('a');
});
})
开发者ID:josx,项目名称:angular-pipes,代码行数:32,代码来源:take.pipe.spec.ts
示例7: describe
describe('ToArrayPipe', () => {
let pipe: ToArrayPipe;
beforeEach(() => {
pipe = new ToArrayPipe();
});
const value = {
a: 1,
b: 2,
c: 3
};
it ('should transform the object to an array', () => {
expect(pipe.transform(value)).toEqual([1, 2, 3]);
});
it ('should return the input unchanged', () => {
expect(pipe.transform('a')).toEqual('a');
});
});
开发者ID:josx,项目名称:angular-pipes,代码行数:25,代码来源:to-array.pipe.spec.ts
示例8: describe
describe('TemplatePipe', () => {
let pipe: TemplatePipe;
beforeEach(() => {
pipe = new TemplatePipe();
});
it ('Should replace the parameters', () => {
expect(pipe.transform('Hello $1', 'World')).toEqual('Hello World');
});
it ('Should replace the parameters #2', () => {
expect(pipe.transform('Hello $1, how is it $2', 'World', 'going?')).toEqual('Hello World, how is it going?');
});
it('Should return the value unchanged', () => {
expect(pipe.transform(1, [null])).toEqual(1);
});
});
开发者ID:josx,项目名称:angular-pipes,代码行数:26,代码来源:template.pipe.spec.ts
示例9: describe
describe('MapPipe', () => {
let pipe: MapPipe;
beforeEach(() => {
pipe = new MapPipe();
});
it('Should return the modified array', () => {
const array = [0, 1, 2, 3];
const fn = function (item) {
return ++item;
};
expect(pipe.transform(array, fn)).toEqual([1, 2, 3, 4]);
expect(array).toEqual([0, 1, 2, 3]); // Check integrity
});
it('Should return the original array', () => {
// undefined to avoid typescript error
expect(pipe.transform([1,2], undefined)).toEqual([1, 2]);
});
it('Should return the value unchanged', () => {
expect(pipe.transform('a', null)).toEqual('a');
});
})
开发者ID:josx,项目名称:angular-pipes,代码行数:31,代码来源:map.pipe.spec.ts
示例10: describe
describe('Dashboard Component', () => {
setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
let tcb: TestComponentBuilder;
beforeEachProviders(() => [
TestComponentBuilder,
HTTP_PROVIDERS,
ROUTER_FAKE_PROVIDERS,
provide(Location, {useClass: SpyLocation}),
provide(DirectiveResolver, {useClass: MockDirectiveResolver}),
provide(ViewResolver, {useClass: MockViewResolver}),
HeroService,
AppComponent,
]);
beforeEach(inject([TestComponentBuilder], (tcb_) => {
tcb = tcb_;
}));
it('should render the title', (done) => {
return tcb.createAsync(DashboardComponent)
.then(fixture => {
let component = fixture.componentInstance;
component.title = 'Top_heroes';
fixture.detectChanges();
let element = fixture.nativeElement;
expect(element.querySelector('h3').innerText).toContain('Top_heroes');
done();
});
});
});
开发者ID:mahpah,项目名称:ng2-pack,代码行数:31,代码来源:dashboard.component.spec.ts
注:本文中的@angular/testing.beforeEach函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论