Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request #192 from storybooks/test/treeNode
Browse files Browse the repository at this point in the history
Test/tree node
  • Loading branch information
maximilianoforlenza authored Apr 28, 2019
2 parents 1b8d50f + 121b6da commit 2180e0a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 14 additions & 3 deletions __tests__/TreeNode.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,28 @@ describe('<TreeNode/>', () => {
simulateClickOnButton(wrapper);
expect(clickFn()).toEqual(data);
});
test('should return toggled boolean on false', () => {
test('should return toggled boolean in false', () => {
const wrapper = shallow(renderComponent({onToggle: clickFn}));
clickFn.mockImplementation((node, toggled) => toggled);
simulateClickOnButton(wrapper);
expect(clickFn.mock.calls[0][1]).toBe(false);
});
});
describe('Drawer when toggled is false', () => {
test('should be children size equal to zero', () => {
describe('Drawer', () => {
test('should children size to be equal to zero when toggled is false', () => {
const wrapper = shallow(renderComponent({node: {...data, toggled: false}}));
expect(wrapper.find('Drawer').children().length).toBe(0);
});
test('should return Loading component when node has property loading in true', () => {
const wrapper = shallow(renderComponent({node: {id: 1, name: 'test', toggled: true, loading: true}}));
const drawer = wrapper.find('Drawer');
expect(drawer.find('Loading').exists()).toBe(true)
});
test('should return seven TreeNode children', () => {
const wrapper = shallow(renderComponent());
const drawer = wrapper.find('Drawer');
const ul = drawer.children();
expect(ul.children()).toHaveLength(7);
})
});
describe('animations method', () => {
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"lib": "npm run babel",
"babel": "rimraf dist && babel src/ -d dist/",
"test": "jest --config=jest.config.js",
"test:watch": "jest --config=jest.config.js --watch",
"test:coverage": "jest --config=jest.config.js --coverage",
"lint": "eslint src/",
"example": "webpack-dev-server --content-base ./example/ --config ./example/webpack.config.js"
},
Expand Down

0 comments on commit 2180e0a

Please sign in to comment.