Improve code coverage in TreeNode 72/78472/1
authorawudzins <adam.wudzinski@nokia.com>
Thu, 14 Feb 2019 11:28:42 +0000 (12:28 +0100)
committerawudzins <adam.wudzinski@nokia.com>
Thu, 14 Feb 2019 11:28:42 +0000 (12:28 +0100)
Improve code coverage in TreeNode

Issue-ID: AAI-1618

Change-Id: Idec9566b108743c7c3a515d3f7fdce6f31b15324
Signed-off-by: adam.wudzinski <adam.wudzinski@nokia.com>
test/generic-components/treeNode/TreeNode.test.js [new file with mode: 0644]

diff --git a/test/generic-components/treeNode/TreeNode.test.js b/test/generic-components/treeNode/TreeNode.test.js
new file mode 100644 (file)
index 0000000..1c669e6
--- /dev/null
@@ -0,0 +1,41 @@
+import TreeNode from 'generic-components/treeNode/TreeNode';
+import React from 'react';
+import { mount } from 'enzyme';
+
+describe('TreeNode', () => {
+  let treeNode;
+
+  beforeEach(() => {
+    treeNode = mount(<TreeNode node={{title: 'AAA'}}/>).instance();
+  });
+
+
+  it('Should be invisible when created', () => {
+    // then
+    expect(treeNode.state['visible']).toEqual(false)
+  });
+
+  it('Should be visible when toggled', () => {
+    // given
+    expect(treeNode.state['visible']).toEqual(false)
+
+    // when
+    treeNode.toggle();
+
+    // then
+    expect(treeNode.state['visible']).toEqual(true)
+  });
+
+  it('Should be invisible when double toggled', () => {
+    // given
+    expect(treeNode.state['visible']).toEqual(false);
+
+    // when
+    treeNode.toggle();
+    treeNode.toggle();
+
+    // then
+    expect(treeNode.state['visible']).toEqual(false);
+  });
+
+});

© 2017 ONAP. Copyright © The Linux Foundation ®. All Rights Reserved.
The Linux Foundation has registered trademarks and uses trademarks.
For a list of trademarks of The Linux Foundation, please see our Trademark Usage page.
Linux is a registered trademark of Linus Torvalds.
Privacy Policy and Terms of Use