本文整理汇总了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();
});
示例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);
});
示例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();
});
});
示例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);
});
示例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();
});
示例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
示例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');
}
}
示例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');
}
}