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