本文整理汇总了TypeScript中@jupyterlab/testutils.signalToPromise函数的典型用法代码示例。如果您正苦于以下问题:TypeScript signalToPromise函数的具体用法?TypeScript signalToPromise怎么用?TypeScript signalToPromise使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了signalToPromise函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should add a new code cell when cells are cleared', async () => {
const model = new NotebookModel();
let promise = signalToPromise(model.cells.changed);
model.cells.clear();
await promise;
expect(model.cells.length).to.equal(0);
await signalToPromise(model.cells.changed);
expect(model.cells.length).to.equal(1);
expect(model.cells.get(0)).to.be.an.instanceof(CodeCellModel);
});
示例2: it
it('should stop routing if returned by a routed command', async () => {
const wanted = ['a', 'b'];
const recorded: string[] = [];
commands.addCommand('a', {
execute: () => {
recorded.push('a');
}
});
commands.addCommand('b', {
execute: () => {
recorded.push('b');
}
});
commands.addCommand('c', { execute: () => router.stop });
commands.addCommand('d', {
execute: () => {
recorded.push('d');
}
});
router.register({ command: 'a', pattern: /.*/, rank: 10 });
router.register({ command: 'b', pattern: /.*/, rank: 20 });
router.register({ command: 'c', pattern: /.*/, rank: 30 });
router.register({ command: 'd', pattern: /.*/, rank: 40 });
let promise = signalToPromise(router.routed);
await router.route();
await promise;
expect(recorded).to.deep.equal(wanted);
});
示例3: it
it('should trigger a save', () => {
let promise = signalToPromise(context.fileChanged);
context.model.fromString('bar');
expect(handler.isActive).to.equal(false);
handler.saveInterval = 1;
handler.start();
return promise;
});
示例4: it
it('should save when clicked', async () => {
const button = ToolbarItems.createSaveButton(panel);
Widget.attach(button, document.body);
let promise = signalToPromise(context.fileChanged);
await framePromise();
(button.node.firstChild as HTMLElement).click();
await promise;
button.dispose();
});