本文整理汇总了TypeScript中@jupyterlab/testutils.sleep函数的典型用法代码示例。如果您正苦于以下问题:TypeScript sleep函数的具体用法?TypeScript sleep怎么用?TypeScript sleep使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sleep函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should paste when clicked', async () => {
const button = ToolbarItems.createPasteButton(panel);
const count = panel.content.widgets.length;
Widget.attach(button, document.body);
await framePromise();
NotebookActions.copy(panel.content);
(button.node.firstChild as HTMLElement).click();
await sleep();
expect(panel.content.widgets.length).to.equal(count + 1);
button.dispose();
});
示例2: it
it('should emit a tick identical to the poll state', async () => {
poll = new Poll<void, void>({
factory: () => Promise.resolve(),
frequency: { interval: 100, backoff: false },
name: '@jupyterlab/test-coreutils:Poll#ticked-3'
});
poll.ticked.connect((_, tick) => {
expect(tick).to.equal(poll.state);
});
await sleep(250);
});
示例3: it
it('should resolve after the reveal and context ready promises', async () => {
const x = Object.create(null);
const reveal = sleep(300, x);
const contextReady = Promise.all([context.ready, x]);
const widget = new DocumentWidget({ context, content, reveal });
expect(widget.isRevealed).to.equal(false);
// Our promise should resolve before the widget reveal promise.
expect(await Promise.race([widget.revealed, reveal])).to.equal(x);
// The context ready promise should also resolve first.
context.initialize(true);
expect(
await Promise.race([widget.revealed, contextReady])
).to.deep.equal([undefined, x]);
// The widget.revealed promise should finally resolve.
expect(await widget.revealed).to.be.undefined;
});