本文整理汇总了TypeScript中angular2/testing.flushMicrotasks函数的典型用法代码示例。如果您正苦于以下问题:TypeScript flushMicrotasks函数的具体用法?TypeScript flushMicrotasks怎么用?TypeScript flushMicrotasks使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了flushMicrotasks函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should open multiple overlays', fakeAsyncTest(() => {
let pizzaOverlayRef: OverlayRef;
let cakeOverlayRef: OverlayRef;
overlay.create().then(ref => {
pizzaOverlayRef = ref;
pizzaOverlayRef.attach(componentPortal);
});
flushMicrotasks();
overlay.create().then(ref => {
cakeOverlayRef = ref;
cakeOverlayRef.attach(templatePortal);
});
flushMicrotasks();
expect(overlayContainerElement.childNodes.length).toBe(2);
expect(overlayContainerElement.textContent).toContain('Pizza');
expect(overlayContainerElement.textContent).toContain('Cake');
pizzaOverlayRef.dispose();
expect(overlayContainerElement.childNodes.length).toBe(1);
expect(overlayContainerElement.textContent).toContain('Cake');
cakeOverlayRef.dispose();
expect(overlayContainerElement.childNodes.length).toBe(0);
expect(overlayContainerElement.textContent).toBe('');
}));
示例2: it
it('should default the element to position: absolute', fakeAsyncTest(() => {
strategy.apply(element);
flushMicrotasks();
expect(element.style.position).toBe('absolute');
}));
示例3: beforeEach
beforeEach(inject(deps, fakeAsync((tcb: TestComponentBuilder, o: Overlay) => {
builder = tcb;
overlay = o;
builder.createAsync(TestComponentWithTemplatePortals).then(fixture => {
fixture.detectChanges();
templatePortal = fixture.componentInstance.templatePortal;
componentPortal = new ComponentPortal(PizzaMsg, fixture.componentInstance.elementRef);
});
flushMicrotasks();
})));
示例4: it
it('should apply the aria-live value polite by default', fakeAsyncTest(() => {
let appFixture: ComponentFixture = null;
builder.createAsync(TestApp).then(fixture => {
appFixture = fixture;
});
flushMicrotasks();
live.announce('Hey Google');
// This flushes our 100ms timeout for the screenreaders.
tick(100);
expect(liveEl.textContent).toBe('Hey Google');
expect(liveEl.getAttribute('aria-live')).toBe('polite');
}));