本文整理汇总了TypeScript中angular2/testing.tick函数的典型用法代码示例。如果您正苦于以下问题:TypeScript tick函数的具体用法?TypeScript tick怎么用?TypeScript tick使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tick函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should login', inject([TestComponentBuilder], fakeAsync((tcb:TestComponentBuilder) => {
let fixture;
tcb
// https://github.com/angular/angular/issues/2835
.overrideTemplate(TaLogin, `
<form>
<input type="text" #username>
<button (click)="loginSubmit(username)">Find user</button>
</form>
`)
.createAsync(TaLogin).then((rootFixture) => {
fixture = rootFixture;
});
tick();
let componentInstance = fixture.componentInstance;
let element = fixture.nativeElement;
let username;
componentInstance.login.subscribe((value) => {
username = value;
});
element.querySelector('input').value = 'cironunes';
element.querySelector('button').click();
tick();
expect(username).toBe('cironunes');
})));
示例2: dispatchEvent
tcb.createAsync(DemoFormWithEvents).then((fixture) => {
let el = fixture.debugElement.nativeElement;
let input = fixture.debugElement.query(By.css("input")).nativeElement;
let form = fixture.debugElement.query(By.css("form")).nativeElement;
fixture.detectChanges();
input.value = '';
dispatchEvent(input, 'input');
fixture.detectChanges();
tick();
// no value on sku field, all error messages are displayed
let msgs = el.querySelectorAll('.ui.error.message');
expect(msgs[0]).toHaveText('SKU is invalid');
expect(msgs[1]).toHaveText('SKU is required');
// displays no errors when sku has a value
input.value = 'XYZ';
dispatchEvent(input, 'input');
fixture.detectChanges();
tick()
msgs = el.querySelectorAll('.ui.error.message');
expect(msgs.length).toEqual(0);
fixture.detectChanges();
dispatchEvent(form, 'submit');
tick();
// checks for the form submitted message
expect(fakeConsole._logs).toContain('you submitted value: XYZ');
});
示例3: createComponent
createComponent(tcb).then((fixture) => {
input.value = 'ABC';
dispatchEvent(input, 'input');
tick();
fixture.detectChanges();
dispatchEvent(form, 'submit');
tick();
expect(fakeConsole._logs).toContain('you submitted value: ABC');
});
示例4: tick
.then((controlsInstance: PaginationControlsCmp) => {
testCmpInstance.config.currentPage = 1;
fixture.detectChanges();
tick();
expect(controlsInstance.api.isLastPage()).toBe(false);
testCmpInstance.config.currentPage = 10;
fixture.detectChanges();
tick();
expect(controlsInstance.api.isLastPage()).toBe(true);
});
示例5: it
it('should accept pin (with fakeAsync)', inject([TestComponentBuilder], fakeAsync((tcb) => {
var fixture;
tcb.createAsync(GreetingComponent).then((rootFixture) => {
fixture = rootFixture });
tick();
var compiled = fixture.debugElement.nativeElement;
compiled.querySelector('button').click();
tick();
fixture.detectChanges();
expect(compiled.querySelector('h3')).toHaveText('Status: Welcome!');
})));
示例6: it
it('should load operations and schema', inject([], fakeAsync(() => {
mockBackend.connections.subscribe(c => {
expect(c.request.url).toBe('http://localhost:8000/apidoc');
let response = new ResponseOptions({
body: {
'hydra:title': 'Hydra API Test',
'hydra:supportedClass': [
{'@id': 'http://schema.org/Person'},
{'@id': 'http://schema.org/BlogPosting'},
{'@id': '#Entrypoint'},
{'@id': '#ConstraintViolation'},
{'@id': '#ConstraintViolationList'}
]
}
});
c.mockRespond(new Response(response));
});
spyOn(schemaService, '_loadCollectionOperations');
spyOn(schemaService, '_loadSingleOperations');
spyOn(schemaService, '_loadSchema');
schemaService._loadDocumentation();
tick();
expect(schemaService._loadCollectionOperations).toHaveBeenCalled();
expect(schemaService._loadSingleOperations).toHaveBeenCalled();
expect(schemaService._loadSchema).toHaveBeenCalled();
})));
示例7: it
it('should set the user', inject([Ng2TestsApp], fakeAsync((app: Ng2TestsApp) => {
app.findUser('nonexistent');
tick();
expect(app.user).toBe(null);
expect(app.msg).toBe('User not found');
})));
示例8: fakeAsync
fakeAsync((tasksService, mockBackend) => {
mockBackend.connections.subscribe( conn => {
chai.expect(conn.request.url).to.be.oneOf([
'http://ngcourse.herokuapp.com/api/v1/tasks',
'http://ngcourse.herokuapp.com/api/v1/tasks/1'
]);
chai.expect(conn.request.method).to.be.oneOf([
RequestMethod.Get,
RequestMethod.Post,
RequestMethod.Delete,
RequestMethod.Put
]);
if (conn.request.url ===
'http://ngcourse.herokuapp.com/api/v1/tasks' &&
conn.request.method === RequestMethod.Get) {
let response = new ResponseOptions({body: mockTasksResponse});
conn.mockRespond(new Response(response));
return;
}
let response = new ResponseOptions({body: mockResponseBody});
conn.mockRespond(new Response(response));
});
tasksService.fetch();
tick();
callback(tasksService);
}
示例9: spyOn
.then((controlsInstance: PaginationControlsCmp) => {
spyOn(testCmpInstance, 'pageChanged');
controlsInstance.api.next();
tick();
expect(testCmpInstance.pageChanged).toHaveBeenCalledWith(3);
});