Example #1
0
 it('should give the appropriate label given arguments', () => {
   let cmd = {
     execute: (args: JSONObject) => { return args; },
     label: (args: JSONObject) => { return JSON.stringify(args); }
   };
   registry.addCommand('test', cmd);
   expect(registry.label('test', {})).to.equal('{}');
 });
Example #2
0
 it('should get the display label for a specific command', () => {
   let cmd = {
     execute: (args: JSONObject) => { return args; },
     label: 'foo'
   };
   registry.addCommand('test', cmd);
   expect(registry.label('test')).to.equal('foo');
 });
Example #3
0
 it('should clone the `cmd` before adding it to the registry', () => {
   let cmd = {
     execute: (args: JSONObject) => { return args; },
     label: 'foo'
   };
   registry.addCommand('test', cmd);
   cmd.label = 'bar';
   expect(registry.label('test')).to.equal('foo');
 });
Example #4
0
  function setNodeContentFromCommand(node: HTMLElement, commands: CommandRegistry, id: string): void {
    const iconClass = commands.iconClass(id);
    const iconLabel = commands.iconLabel(id);
    const label = commands.label(id);

    node.innerHTML = '';
    if (iconClass) {
      node.className += ` ${iconClass}`;
      node.setAttribute('title', iconLabel || label);
    } else {
      node.innerText = label;
    }
  }
Example #5
0
 function setNodeContentFromCommand(node: HTMLElement, commands: CommandRegistry, id: string): void {
   let iconClass = commands.iconClass(id);
   let iconLabel = commands.iconLabel(id);
   node.innerHTML = '';
   if (iconClass || iconLabel) {
     let icon = document.createElement('div');
     icon.innerText = commands.iconLabel(id);
     icon.className += ` ${iconClass}`;
     node.appendChild(icon);
   } else {
     node.innerText = commands.label(id);
   }
 }
Example #6
0
 it('should default to an empty string for a command', () => {
   registry.addCommand('test', NULL_COMMAND);
   expect(registry.label('test')).to.equal('');
 });
Example #7
0
 it('should return an empty string if the command is not registered', () => {
   expect(registry.label('foo')).to.equal('');
 });