本文整理汇总了TypeScript中@angular/testing.describe函数的典型用法代码示例。如果您正苦于以下问题:TypeScript describe函数的具体用法?TypeScript describe怎么用?TypeScript describe使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了describe函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: describe
export let secondSuite = () => {
describe('OrderService', () => {
beforeEachProviders(() => [{ provide: OrderService, useFactory: () => new OrderService(false) },
DateFormatter,
DatePipe
]);
it('should fetch our data', inject([OrderService], (orderService: OrderService) => {
expect(orderService.getData().length).toBe(2);
}));
it('should fetch our data', inject([DateFormatter], (dateFormatService: DateFormatter) => {
expect(dateFormatService.x).toBe(3);
}));
});
};
示例2: describe
import { SqrtPipe } from '../../index';
import {describe, it, beforeEach, expect} from '@angular/testing';
describe('SqrtPipe', () => {
let pipe: SqrtPipe;
beforeEach(() => {
pipe = new SqrtPipe();
});
it('Should return 2', () => {
expect(pipe.transform(4)).toEqual(2);
});
it('Should return 9', () => {
expect(pipe.transform(81)).toEqual(9);
});
});
示例3: describe
describe('RoundPipe', () => {
let pipe: RoundPipe;
beforeEach(() => {
pipe = new RoundPipe();
});
it('Should return 3', () => {
expect(pipe.transform(3.4, 0)).toEqual(3);
});
it('Should return 3', () => {
expect(pipe.transform(3.5, 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.54', () => {
expect(pipe.transform(1.5444, 2)).toEqual(1.54);
});
it('Should return 1.35', () => {
expect(pipe.transform(1.345, 2)).toEqual(1.35);
});
});
示例4: describe
describe('WherePipe', () => {
let pipe: WherePipe;
const array = [
{
a: 2,
b: 3,
d: { e : 4}
},
{
a: 4,
b: 3,
d: { e : 8 }
},
{
a: 3,
b: 1,
d: { e : 4}
},
{
a: 4,
b: 5,
d: { e : 5}
}
]
beforeEach(() => {
pipe = new WherePipe();
});
it ('Should return only the 1 values', () => {
const fn = function (item) {
return item === 1;
}
const value = [1, 2, 3, 1, 1, 4];
expect(pipe.transform(value, fn)).toEqual([1, 1, 1]);
expect(value).toEqual([1, 2, 3, 1, 1, 4]);
});
it('Should return the objects where a is 4', () => {
const fn = function (item) {
return item.a === 4;
};
expect(pipe.transform(array, fn))
.toEqual([{
a: 4,
b: 3,
d: { e : 8 }
},
{
a: 4,
b: 5,
d: { e : 5}
}
]);
});
it('Should return the objects where a is 4', () => {
expect(pipe.transform(array, ['a', 4]))
.toEqual([{
a: 4,
b: 3,
d: { e : 8 }
},
{
a: 4,
b: 5,
d: { e : 5}
}
]);
});
it('Should return the objects where d.e is 4', () => {
expect(pipe.transform(array, ['d.e', 4]))
.toEqual([{
a: 2,
b: 3,
d: { e : 4 }
},
{
a: 3,
b: 1,
d: { e : 4}
}
]);
});
it('Should return the value unchanged', () => {
expect(pipe.transform('a', null)).toEqual('a');
});
//.........这里部分代码省略.........
示例5: describe
import {
describe,
ddescribe,
expect,
iit,
it
} from '@angular/testing';
import {Usuario} from './usuario.model';
describe('Usuario', () => {
it('should create an instance', () => {
expect(new Usuario()).toBeTruthy();
});
});
示例6: describe
describe('RandomPipe', () => {
let pipe: RandomPipe;
beforeEach(() => {
pipe = new RandomPipe();
});
it ('Should return a random value between 5 and 10', () => {
const result = pipe.transform(0, 5, 10);
expect(result).toBeGreaterThan(5);
expect(result).toBeLessThan(10);
});
it ('Should return a random value between 0 and 1', () => {
const result = pipe.transform(0, 0, 1);
expect(result).toBeGreaterThan(0);
expect(result).toBeLessThan(1);
});
it ('Should return a random value between 1298 and 1300', () => {
const result = pipe.transform(0, 1298, 1300);
expect(result).toBeGreaterThan(1298);
expect(result).toBeLessThan(1300);
});
it ('Should return the value unchanged', () => {
expect(pipe.transform(0, 'a', 1)).toEqual(0);
});
});
示例7: describe
import { TemplatePipe } from '../../index';
import {describe, it, beforeEach, expect} from '@angular/testing';
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);
});
});
示例8: describe
describe,
beforeEachProviders,
TestComponentBuilder
} from '@angular/testing';
import {Component, provide} from '@angular/core';
import {BaseRequestOptions, Http} from '@angular/http';
import {MockBackend} from '@angular/http/testing';
// Load the implementations that should be tested
import {XLarge} from './x-large.directive';
describe('x-large directive', () => {
// Create a test component to test directives
@Component({
template: '',
directives: [ XLarge ]
})
class TestComponent {}
it('should sent font-size to x-large', injectAsync([TestComponentBuilder], (tcb) => {
return tcb.overrideTemplate(TestComponent, '<div x-large>Content</div>')
.createAsync(TestComponent).then((fixture: any) => {
fixture.detectChanges();
let compiled = fixture.debugElement.nativeElement.children[0];
expect(compiled.style.fontSize).toBe('x-large');
});
}));
});
示例9: describe
import { EncodeURIPipe } from '../../index';
import {describe, it, beforeEach, expect} from '@angular/testing';
describe('EncodeURIPipe', () => {
let pipe: EncodeURIPipe;
beforeEach(() => {
pipe = new EncodeURIPipe();
});
it('Should return the value unchanged', () => {
expect(pipe.transform(1)).toEqual(1);
});
});
示例10: describe
import {describe, it, beforeEach, expect} from '@angular/testing';
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);
});
});