Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should disconnect a node from a command', () => {
let called = false;
const command = 'commandlinker:disconnect-node';
const commands = new CommandRegistry();
const linker = new CommandLinker({ commands });
const node = document.createElement('div');
const disposable = commands.addCommand(command, {
execute: () => {
called = true;
}
});
document.body.appendChild(node);
linker.connectNode(node, command, undefined);
// Make sure connection is working.
expect(called).to.equal(false);
simulate(node, 'click');
expect(called).to.equal(true);
// Reset flag.
constructor(options: JupyterFrontEnd.IOptions) {
super(options);
// The default restored promise if one does not exist in the options.
const restored = new Promise(resolve => {
requestAnimationFrame(() => {
resolve();
});
});
this.commandLinker =
options.commandLinker || new CommandLinker({ commands: this.commands });
this.docRegistry = options.docRegistry || new DocumentRegistry();
this.restored =
options.restored ||
this.started.then(() => restored).catch(() => restored);
this.serviceManager = options.serviceManager || new ServiceManager();
this.commands.addCommand(Private.CONTEXT_MENU_INFO, {
label: 'Shift+Right Click for Browser Menu',
isEnabled: () => false,
execute: () => void 0
});
this.contextMenu.addItem({
command: Private.CONTEXT_MENU_INFO,
selector: 'body',
rank: Infinity
this._busySignal = new Signal(this);
this._dirtySignal = new Signal(this);
// Construct the default workspace name.
const defaultWorkspace = URLExt.join(
PageConfig.getOption('baseUrl'),
PageConfig.getOption('pageUrl')
);
// Set default workspace in page config.
PageConfig.setOption('defaultWorkspace', defaultWorkspace);
// Instantiate public resources.
this.serviceManager = options.serviceManager || new ServiceManager();
this.commandLinker =
options.commandLinker || new CommandLinker({ commands: this.commands });
this.docRegistry = options.docRegistry || new DocumentRegistry();
// Remove extra resources (non-IInfo) from options object.
delete options.serviceManager;
delete options.commandLinker;
delete options.docRegistry;
// Populate application info.
this._info = {
...JupyterLab.defaultInfo,
...(options as Partial),
...{ defaultWorkspace }
};
if (this._info.devMode) {
this.shell.addClass('jp-mod-devMode');
constructor(options: JupyterFrontEnd.IOptions) {
super(options);
// The default restored promise if one does not exist in the options.
const restored = new Promise(resolve => {
requestAnimationFrame(() => {
resolve();
});
});
this.commandLinker =
options.commandLinker || new CommandLinker({ commands: this.commands });
this.docRegistry = options.docRegistry || new DocumentRegistry();
this.restored =
options.restored ||
this.started.then(() => restored).catch(() => restored);
this.serviceManager = options.serviceManager || new ServiceManager();
this.commands.addCommand(Private.CONTEXT_MENU_INFO, {
label: 'Shift+Right Click for Browser Menu',
isEnabled: () => false,
execute: () => void 0
});
this.contextMenu.addItem({
command: Private.CONTEXT_MENU_INFO,
selector: 'body',
rank: Infinity
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, undefined)
});
node = VirtualDOM.realize(vnode);
document.body.appendChild(node);
expect(called).to.equal(false);
simulate(node, 'click');
it('should test whether a command linker has been disposed', () => {
const linker = new CommandLinker({ commands: new CommandRegistry() });
expect(linker.isDisposed).to.equal(false);
linker.dispose();
expect(linker.isDisposed).to.equal(true);
});
});
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 });
const node = document.createElement('div');
const disposable = commands.addCommand(command, {
execute: () => {
called = true;
}
});
document.body.appendChild(node);
linker.connectNode(node, command, undefined);
expect(called).to.equal(false);
simulate(node, 'click');
expect(called).to.equal(true);
document.body.removeChild(node);
linker.dispose();
it('should test whether a command linker has been disposed', () => {
const linker = new CommandLinker({ commands: new CommandRegistry() });
expect(linker.isDisposed).to.equal(false);
linker.dispose();
expect(linker.isDisposed).to.equal(true);
});
});
it('should create a command linker', () => {
const linker = new CommandLinker({ commands: new CommandRegistry() });
expect(linker).to.be.an.instanceof(CommandLinker);
linker.dispose();
});
});
it('should create a command linker', () => {
const linker = new CommandLinker({ commands: new CommandRegistry() });
expect(linker).to.be.an.instanceof(CommandLinker);
linker.dispose();
});
});