本文整理匯總了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;
});