本文整理汇总了TypeScript中simulate-event.simulate函数的典型用法代码示例。如果您正苦于以下问题:TypeScript simulate函数的具体用法?TypeScript simulate怎么用?TypeScript simulate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了simulate函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should disconnect a node from a command', () => {
let called = false;
let command = 'commandlinker:disconnect-node';
let commands =new CommandRegistry();
let linker = new CommandLinker({ commands });
let node = document.createElement('div');
let disposable = commands.addCommand(command, {
execute: () => { called = true; }
});
document.body.appendChild(node);
linker.connectNode(node, command, null);
// Make sure connection is working.
expect(called).to.be(false);
simulate(node, 'click');
expect(called).to.be(true);
// Reset flag.
called = false;
// Make sure disconnection is working.
linker.disconnectNode(node);
expect(called).to.be(false);
simulate(node, 'click');
expect(called).to.be(false);
document.body.removeChild(node);
linker.dispose();
disposable.dispose();
});
开发者ID:rlugojr,项目名称:jupyterlab,代码行数:31,代码来源:commandlinker.spec.ts
示例2: it
it('should set the focus number of the widget', () => {
let tracker = new FocusTracker();
let widget0 = createWidget();
let widget1 = createWidget();
widget0.node.focus();
tracker.add(widget0);
tracker.add(widget1);
simulate(widget1.node, 'focus');
expect(tracker.focusNumber(widget0)).to.be(0);
simulate(widget0.node, 'focus');
expect(tracker.focusNumber(widget0)).to.be(2);
});
开发者ID:rlugojr,项目名称:phosphor,代码行数:12,代码来源:focustracker.spec.ts
示例3: it
it('should create a new folder', (done) => {
Widget.attach(buttons, document.body);
let node = buttons.createNode;
simulate(node, 'mousedown');
let menu = document.getElementsByClassName('p-Menu')[0];
simulate(menu, 'keydown', { keyCode: 40 });
simulate(menu, 'keydown', { keyCode: 13 });
model.fileChanged.connect((sender, args) => {
expect(args.newValue.type).to.be('directory');
done();
});
});
开发者ID:rlugojr,项目名称:jupyterlab,代码行数:12,代码来源:buttons.spec.ts
示例4: it
it('should wrap the select node', () => {
let select = document.createElement('select');
let wrapper = Styling.wrapSelect(select);
expect(wrapper.className).to.equal('jp-select-wrapper');
expect(select.parentElement).to.equal(wrapper);
expect(select.className).to.equal('jp-mod-styled');
document.body.appendChild(wrapper);
select.focus();
simulate(select, 'focus');
expect(wrapper.className).to.contain('jp-mod-focused');
select.blur();
simulate(select, 'blur');
expect(wrapper.className).to.not.contain('jp-mod-focused');
document.body.removeChild(wrapper);
});
开发者ID:afshin,项目名称:jupyterlab,代码行数:15,代码来源:styling.spec.ts
示例5: it
it('should connect a node to a command', () => {
let called = false;
const command = 'commandlinker:connect-node';
const commands = new CommandRegistry();
const linker = new CommandLinker({ commands });
let node: HTMLElement;
let vnode: VirtualNode;
const disposable = commands.addCommand(command, {
execute: () => {
called = true;
}
});
vnode = h.div({ dataset: linker.populateVNodeDataset(command, null) });
node = VirtualDOM.realize(vnode);
document.body.appendChild(node);
expect(called).to.equal(false);
simulate(node, 'click');
expect(called).to.equal(true);
document.body.removeChild(node);
linker.dispose();
disposable.dispose();
});
开发者ID:AlbertHilb,项目名称:jupyterlab,代码行数:25,代码来源:commandlinker.spec.ts
示例6: it
it('should run and advance when clicked', async () => {
const button = ToolbarItems.createRunButton(panel);
const widget = panel.content;
// Clear and select the first two cells.
const codeCell = widget.widgets[0] as CodeCell;
codeCell.model.outputs.clear();
widget.select(codeCell);
const mdCell = widget.widgets[1] as MarkdownCell;
mdCell.rendered = false;
widget.select(mdCell);
Widget.attach(button, document.body);
await context.ready;
await context.session.ready;
await context.session.kernel.ready;
const p = new PromiseDelegate();
context.session.statusChanged.connect((sender, status) => {
// Find the right status idle message
if (status === 'idle' && codeCell.model.outputs.length > 0) {
expect(mdCell.rendered).to.equal(true);
expect(widget.activeCellIndex).to.equal(2);
button.dispose();
p.resolve(0);
}
});
await framePromise();
simulate(button.node.firstChild as HTMLElement, 'mousedown');
await p.promise;
}).timeout(30000); // Allow for slower CI
开发者ID:AlbertHilb,项目名称:jupyterlab,代码行数:30,代码来源:default-toolbar.spec.ts
示例7: focusWidget
function focusWidget(widget: Widget): void {
widget.node.focus();
if (Platform.IS_IE) {
// Ensure we get a synchronous event on IE for testing.
simulate(widget.node, 'focus');
}
}
开发者ID:afshin,项目名称:phosphor,代码行数:7,代码来源:focustracker.spec.ts
示例8: blurWidget
function blurWidget(widget: Widget): void {
widget.node.blur();
if (Platform.IS_IE) {
// Ensure we get a synchronous event on IE for testing.
simulate(widget.node, 'blur');
}
}
开发者ID:afshin,项目名称:phosphor,代码行数:7,代码来源:focustracker.spec.ts
注:本文中的simulate-event.simulate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论