|
@@ -7,6 +7,10 @@ import {
|
|
|
CommandRegistry
|
|
|
} from 'phosphor/lib/ui/commandregistry';
|
|
|
|
|
|
+import {
|
|
|
+ h, IElementAttrs, VNode, realize
|
|
|
+} from 'phosphor/lib/ui/vdom';
|
|
|
+
|
|
|
import {
|
|
|
simulate
|
|
|
} from 'simulate-event';
|
|
@@ -114,6 +118,35 @@ describe('commandlinker/commandlinker', () => {
|
|
|
|
|
|
});
|
|
|
|
|
|
+ describe('#populateVNodeAttributes()', () => {
|
|
|
+
|
|
|
+ it('should connect a node to a command', () => {
|
|
|
+ let called = false;
|
|
|
+ let command = 'commandlinker:connect-node';
|
|
|
+ let commands =new CommandRegistry();
|
|
|
+ let linker = new CommandLinker({ commands });
|
|
|
+ let node: HTMLElement;
|
|
|
+ let vnode: VNode;
|
|
|
+ let disposable = commands.addCommand(command, {
|
|
|
+ execute: () => { called = true; }
|
|
|
+ });
|
|
|
+ let attrs: IElementAttrs = {};
|
|
|
+
|
|
|
+ vnode = h.div(linker.populateVNodeAttrs(attrs, command, null));
|
|
|
+ node = realize(vnode);
|
|
|
+ document.body.appendChild(node);
|
|
|
+
|
|
|
+ expect(called).to.be(false);
|
|
|
+ simulate(node, 'click');
|
|
|
+ expect(called).to.be(true);
|
|
|
+
|
|
|
+ document.body.removeChild(node);
|
|
|
+ linker.dispose();
|
|
|
+ disposable.dispose();
|
|
|
+ });
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|
|
|
});
|