Quellcode durchsuchen

Add VNode test.

Afshin Darian vor 8 Jahren
Ursprung
Commit
5df74e2dd6
1 geänderte Dateien mit 33 neuen und 0 gelöschten Zeilen
  1. 33 0
      test/src/commandlinker/commandlinker.spec.ts

+ 33 - 0
test/src/commandlinker/commandlinker.spec.ts

@@ -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();
+      });
+
+    });
+
   });
 
 });