diff --git a/__tests__/Container.test.js b/__tests__/Container.test.js
index 6cfadb7..0a0231a 100644
--- a/__tests__/Container.test.js
+++ b/__tests__/Container.test.js
@@ -4,8 +4,8 @@ import {shallow} from 'enzyme';
import {decorators} from '../src';
import Container from '../src/components/Decorators/Container';
import animations from '../src/themes/animations';
-import data from '../example/data';
import style from '../src/themes/default';
+import data from './mocks/data';
const onClick = jest.fn();
diff --git a/__tests__/NodeHeader.test.js b/__tests__/NodeHeader.test.js
index a25f133..0043ca4 100644
--- a/__tests__/NodeHeader.test.js
+++ b/__tests__/NodeHeader.test.js
@@ -5,7 +5,7 @@ import NodeHeader from '../src/components/NodeHeader';
import defaultTheme from '../src/themes/default';
import defaultDecorators from '../src/components/Decorators';
import defaultAnimations from '../src/themes/animations';
-import data from '../example/data';
+import data from './mocks/data';
const onClick = jest.fn();
diff --git a/__tests__/TreeNode.test.js b/__tests__/TreeNode.test.js
index d4ea652..d7d5154 100644
--- a/__tests__/TreeNode.test.js
+++ b/__tests__/TreeNode.test.js
@@ -5,7 +5,7 @@ import TreeNode from '../src/components/TreeNode';
import defaultTheme from '../src/themes/default';
import defaultAnimations from '../src/themes/animations';
import defaultDecorators from '../src/components/Decorators';
-import data from '../example/data';
+import data from './mocks/data';
const onToggle = jest.fn();
@@ -29,15 +29,29 @@ const renderComponent = (props = {}) => {
describe('', () => {
describe('when NodeHeader is clicked', () => {
- it('should call onToggle with the selected node and toggled in false', () => {
+ it('should call onToggle', () => {
const wrapper = renderComponent();
wrapper.simulateClickOnHeader();
expect(onToggle).toHaveBeenCalled();
- expect(onToggle).toBeCalledWith(data, false);
+ });
+ describe('and node.toggle is true', () => {
+ it('should return the selected node and toggled in false', () => {
+ const wrapper = renderComponent();
+ wrapper.simulateClickOnHeader();
+ expect(onToggle).toBeCalledWith(data, false);
+ });
+ });
+ describe('and node.toggle is false', () => {
+ it('should return the selected node and toggled in true', () => {
+ const node = {...data, toggled: false};
+ const wrapper = renderComponent({node});
+ wrapper.simulateClickOnHeader();
+ expect(onToggle).toBeCalledWith(node, true);
+ });
});
});
- describe('> ', () => {
+ describe('', () => {
describe('when toggle is false', () => {
it('should have children.size to be 0', () => {
const wrapper = renderComponent({
@@ -100,7 +114,7 @@ describe('', () => {
});
});
- describe('> decorators', () => {
+ describe('decorators', () => {
describe('when node decorators not exists', () => {
describe('and decorators is called', () => {
it('should return defaultDecorators', () => {
diff --git a/__tests__/Treebeard.test.js b/__tests__/Treebeard.test.js
index 0ce74e1..956792e 100644
--- a/__tests__/Treebeard.test.js
+++ b/__tests__/Treebeard.test.js
@@ -3,7 +3,7 @@ import {shallow} from 'enzyme';
import {castArray} from 'lodash';
import Treebeard from '../src/components';
-import data from '../example/data';
+import data from './mocks/data';
const renderComponent = (props = {}) => shallow(
diff --git a/__tests__/mocks/data.js b/__tests__/mocks/data.js
new file mode 100644
index 0000000..cae006f
--- /dev/null
+++ b/__tests__/mocks/data.js
@@ -0,0 +1,45 @@
+export default {
+ name: 'react-treebeard',
+ id: 1,
+ toggled: true,
+ children: [
+ {
+ name: 'example',
+ children: [
+ { name: 'app.js' },
+ { name: 'data.js' },
+ { name: 'index.html' },
+ { name: 'styles.js' },
+ { name: 'webpack.config.js' }
+ ]
+ },
+ {
+ name: 'node_modules',
+ loading: true,
+ children: []
+ },
+ {
+ name: 'src',
+ children: [
+ {
+ name: 'components',
+ children: [
+ { name: 'decorators.js' },
+ { name: 'treebeard.js' }
+ ]
+ },
+ { name: 'index.js' }
+ ]
+ },
+ {
+ name: 'themes',
+ children: [
+ { name: 'animations.js' },
+ { name: 'default.js' }
+ ]
+ },
+ { name: 'gulpfile.js' },
+ { name: 'index.js' },
+ { name: 'package.json' }
+ ]
+};