本文整理汇总了TypeScript中@angular/core/testing.it函数的典型用法代码示例。如果您正苦于以下问题:TypeScript it函数的具体用法?TypeScript it怎么用?TypeScript it使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了it函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe('should emit Highcharts series event', () => {
it('"afterAnimate"', (done) => {
create(`
<chart [options]="options">
<series (afterAnimate)="onEvent()"></series>
</chart>
`).then(fixture => {
fixture.componentInstance.onEvent = () => done();
fixture.componentInstance.options = ['options'];
fixture.detectChanges();
ChartEventEmitter.emitSeriesEvent('afterAnimate');
});
});
it('"checkboxClick"', (done) => {
create(`
<chart [options]="options">
<series (checkboxClick)="onEvent()"></series>
</chart>
`).then(fixture => {
fixture.componentInstance.onEvent = () => done();
fixture.componentInstance.options = ['options'];
fixture.detectChanges();
ChartEventEmitter.emitSeriesEvent('checkboxClick');
});
});
it('"click"', (done) => {
create(`
<chart [options]="options">
<series (click)="onEvent()"></series>
</chart>
`).then(fixture => {
fixture.componentInstance.onEvent = () => done();
fixture.componentInstance.options = ['options'];
fixture.detectChanges();
ChartEventEmitter.emitSeriesEvent('click');
});
});
it('"hide"', (done) => {
create(`
<chart [options]="options">
<series (hide)="onEvent()"></series>
</chart>
`).then(fixture => {
fixture.componentInstance.onEvent = () => done();
fixture.componentInstance.options = ['options'];
fixture.detectChanges();
ChartEventEmitter.emitSeriesEvent('hide');
});
});
it('"legendItemClick"', (done) => {
create(`
<chart [options]="options">
<series (legendItemClick)="onEvent()"></series>
</chart>
`).then(fixture => {
fixture.componentInstance.onEvent = () => done();
fixture.componentInstance.options = ['options'];
fixture.detectChanges();
ChartEventEmitter.emitSeriesEvent('legendItemClick');
});
});
it('"mouseOut"', (done) => {
create(`
<chart [options]="options">
<series (mouseOut)="onEvent()"></series>
</chart>
`).then(fixture => {
fixture.componentInstance.onEvent = () => done();
fixture.componentInstance.options = ['options'];
fixture.detectChanges();
ChartEventEmitter.emitSeriesEvent('mouseOut');
});
});
it('"mouseOver"', (done) => {
create(`
<chart [options]="options">
<series (mouseOver)="onEvent()"></series>
</chart>
`).then(fixture => {
fixture.componentInstance.onEvent = () => done();
fixture.componentInstance.options = ['options'];
fixture.detectChanges();
ChartEventEmitter.emitSeriesEvent('mouseOver');
});
});
it('"show"', (done) => {
create(`
<chart [options]="options">
<series (show)="onEvent()"></series>
</chart>
`).then(fixture => {
fixture.componentInstance.onEvent = () => done();
fixture.componentInstance.options = ['options'];
//.........这里部分代码省略.........
示例2: describe
describe('Service: TestService', () => {
let mockbackend, service;
/*beforeEachProviders(() => [
Busses,
MockBackend,
BaseRequestOptions,
provide(Http, {
useFactory: (backend, options) => new Http(backend, options),
deps: [MockBackend, BaseRequestOptions]})
]);
beforeEachProviders(() => {
return [
HTTP_PROVIDERS,
provide(XHRBackend, {useClass: MockBackend}),
Busses
];
});
*/
let response = {busses: [
{
id: 1,
numberPlate: "KL-AB345",
color: "green",
picture: "http://www.tm4.com/wp-content/uploads/2014/08/Foton-bus-12-m-e1407525133477.png"
},
{
id: 2,
numberPlate: "KL-CD678",
color: "red",
picture: "http://littlebabybum.com/wp-content/uploads/2015/01/wheels-on-the-bus-red.png"
}]};
beforeEachProviders(() => [
Busses,
BaseRequestOptions,
MockBackend,
provide(Http, {
useFactory: (backend: MockBackend, defaultOptions: BaseRequestOptions) => {
return new Http(backend, defaultOptions);
},
deps: [MockBackend, BaseRequestOptions]
})
]);
/*beforeEach(inject([XHRBackend, Busses], (_mockbackend, _service) => {
mockbackend = _mockbackend;
service = _service;
}))*/
console.log("create connection...");
beforeEach(inject([MockBackend], (backend: MockBackend) => {
const baseResponse = new Response(new ResponseOptions({ body: response }));
backend.connections.subscribe((c: MockConnection) => c.mockRespond(baseResponse));
}));
//specs
it('should request busses from server', inject([Busses], (service: Busses) => {
/*mockbackend.connections.subscribe(connection => {
connection.mockRespond(new Response(new ResponseOptions({body:response})));
});*/
console.log("start request...");
service.requestBusses("");
console.log("finished test spec request");
console.log(service.getBusses());
expect(service.getBusses()).not.toEqual([]);
}));
});
示例3: describe
describe('Component: ChessBoard', () => {
it('should create an instance', () => {
let component = new ChessBoardComponent();
expect(component).toBeTruthy();
});
});
示例4: describe
describe('App: Pcards', () => {
it('should create the app',
inject([AppComponent], (app: AppComponent) => {
expect(app).toBeTruthy();
}));
});
示例5: describe
describe('Smoke test', () => {
it('should run a passing test', () => {
expect(true).toEqual(true, 'should pass');
});
});
示例6: describe
describe('Component: Logout', () => {
it('should create an instance', () => {
//let component = new LogoutComponent();
//expect(component).toBeTruthy();
});
});
示例7: describe
describe('Component: Article', () => {
it('should create an instance', () => {
let component = new ArticleComponent();
expect(component).toBeTruthy();
});
});
示例8: describe
describe('List Group:', () => {
var listGroup: ListGroup<TestOption> = null;
beforeEach(() => {
listGroup = new ListGroup<TestOption>();
listGroup.getLabel = option => option.name;
});
it('by default, uses JSON.stringify', () => {
let option = new TestOption('id', 'value');
expect(listGroup.getId(option)).toEqual(JSON.stringify(option));
});
describe('selection:', () => {
beforeEach(() => {
listGroup.getId = option => option.id;
});
it('selects an option', (done) => {
let option = new TestOption('id', 'value');
listGroup.select(option)
listGroup.selection.subscribe(selection => {
expect(selection['id']).toEqual(option);
done();
});
});
it('selects multiple options', (done) => {
let options = [
new TestOption('id', 'value'),
new TestOption('id2', 'value')
];
options.forEach(option => listGroup.select(option));
listGroup.selection.subscribe(selection => {
options.forEach(option => expect(selection[option.id]).toEqual(option));
done();
});
});
it('deselects double selected options in multi-select', (done) => {
let options = [
new TestOption('id', 'value'),
new TestOption('id2', 'value'),
new TestOption('id2', 'value')
];
options.forEach(option => listGroup.select(option));
listGroup.selection.subscribe(selection => {
expect(selection['id']).toEqual(options[0]);
expect(selection['id2']).toBeUndefined();
done();
});
});
it('deselects double selected options in multi-select', (done) => {
let options = [
new TestOption('id', 'value'),
new TestOption('id2', 'value'),
new TestOption('id2', 'value')
];
options.forEach(option => listGroup.select(option));
listGroup.selection.subscribe(selection => {
expect(selection['id']).toEqual(options[0]);
expect(selection['id2']).toBeUndefined();
done();
});
});
it('selects single option', (done) => {
listGroup.isMultiple = false;
let options = [
new TestOption('id', 'value'),
new TestOption('id2', 'value')
];
options.forEach(option => listGroup.select(option));
listGroup.selection.subscribe(selection => {
expect(selection['id']).toBeUndefined();
expect(selection['id2']).toEqual(options[1]);
done();
});
});
it('deselects single option', (done) => {
listGroup.isMultiple = false;
let options = [
new TestOption('id', 'value'),
new TestOption('id', 'value')
//.........这里部分代码省略.........