Skip to content
This repository has been archived by the owner on Oct 29, 2019. It is now read-only.

Commit

Permalink
Merge f96a1e1 into 29f3851
Browse files Browse the repository at this point in the history
  • Loading branch information
js0n committed Oct 23, 2017
2 parents 29f3851 + f96a1e1 commit 42a32ec
Show file tree
Hide file tree
Showing 23 changed files with 5,259 additions and 3,323 deletions.
2 changes: 1 addition & 1 deletion __tests__/collapse.virtual-dom.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/* eslint import/no-extraneous-dependencies: ["error", {"devDependencies": true}] */

import React from 'react';
import TestUtils from 'react-addons-test-utils';
import TestUtils from 'react-dom/test-utils';
import Menu from '../src';
import content from './CONTENT.json';

Expand Down
75 changes: 75 additions & 0 deletions __tests__/item-action-dispatch.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* item-action-dispatch.jsx
* Author: Jason Wong <jwong84@gmail.com>
* Date: 23.10.2017
*/

/* eslint-env jest */
/* eslint import/no-extraneous-dependencies: ["error", {"devDependencies": true}] */

import React from 'react';
import TestUtils from 'react-dom/test-utils';
import { mapDispatchToProps } from '../src/containers/Item';

describe('Menu with recursive content', () => {
const fakeEvent = {
preventDefault() {},
isDefaultPrevented() { return false; }
};

const fakePreventedEvent = {
preventDefault() {},
isDefaultPrevented() { return true; }
}

it('dispatches changeSubMenuVisibility action when hasSubMenu upon toggleSubMenu', () => {
const mockDispatch = jest.fn();
const actions = mapDispatchToProps(mockDispatch, { hasSubMenu: true });

actions.toggleSubMenu(fakeEvent);

expect(mockDispatch.mock.calls.length).toBe(1);
expect(mockDispatch.mock.calls[0][0].type).toBe('CHANGE_SUBMENU_VISIBILITY');
});

it('does not dispatch changeSubMenuVisibility action when !hasSubMenu upon toggleSubMenu', () => {
const mockDispatch = jest.fn();
const actions = mapDispatchToProps(mockDispatch, { hasSubMenu: false });

actions.toggleSubMenu(fakeEvent);

expect(mockDispatch.mock.calls.length).toBe(0);
});

it('dispatches emitSelected and changeActiveLinkId actions upon activateMe', () => {
const mockDispatch = jest.fn();
const actions = mapDispatchToProps(mockDispatch, {});

actions.activateMe(fakeEvent);

expect(mockDispatch.mock.calls.length).toBe(2);
expect(mockDispatch.mock.calls[0][0].type).toBe('EMIT_SELECTED');
expect(mockDispatch.mock.calls[1][0].type).toBe('CHANGE_ACTIVE_LINK');
});

it('does not dispatch changeActiveLinkId action upon activateMe when e.isDefaultPrevented', () => {
const mockDispatch = jest.fn();
const actions = mapDispatchToProps(mockDispatch, {});

actions.activateMe(fakeEvent);

expect(mockDispatch.mock.calls.length).toBe(2);
expect(mockDispatch.mock.calls[0][0].type).toBe('EMIT_SELECTED');
expect(mockDispatch.mock.calls[1][0].type).toBe('CHANGE_ACTIVE_LINK');
});

it('does not dispatch changeActiveLinkId action upon activateMe when e.isDefaultPrevented', () => {
const mockDispatch = jest.fn();
const actions = mapDispatchToProps(mockDispatch, {});

actions.activateMe(fakePreventedEvent);

expect(mockDispatch.mock.calls.length).toBe(1);
expect(mockDispatch.mock.calls[0][0].type).toBe('EMIT_SELECTED');
});
});
2 changes: 1 addition & 1 deletion dist/react-metismenu-standart.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 42a32ec

Please sign in to comment.