@dhis2/analytics 25.2.3 → 26.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/__demo__/FileMenu.stories.js +8 -6
- package/build/cjs/__demo__/Toolbar.stories.js +77 -0
- package/build/cjs/components/FileMenu/FileMenu.js +21 -59
- package/build/cjs/components/FileMenu/__tests__/FileMenu.spec.js +318 -194
- package/build/cjs/components/Options/VisualizationOptions.js +3 -1
- package/build/cjs/components/Toolbar/HoverMenuBar/HoverMenuBar.js +107 -0
- package/build/cjs/components/Toolbar/HoverMenuBar/HoverMenuDropdown.js +66 -0
- package/build/cjs/components/Toolbar/HoverMenuBar/HoverMenuList.js +94 -0
- package/build/cjs/components/Toolbar/HoverMenuBar/HoverMenuListItem.js +99 -0
- package/build/cjs/components/Toolbar/HoverMenuBar/HoverMenuListItem.styles.js +13 -0
- package/build/cjs/components/Toolbar/HoverMenuBar/__tests__/HoverMenuBar.spec.js +219 -0
- package/build/cjs/components/Toolbar/HoverMenuBar/__tests__/HoverMenuDropdown.spec.js +23 -0
- package/build/cjs/components/Toolbar/HoverMenuBar/__tests__/HoverMenuList.spec.js +56 -0
- package/build/cjs/components/Toolbar/HoverMenuBar/__tests__/HoverMenuListItem.spec.js +50 -0
- package/build/cjs/components/Toolbar/HoverMenuBar/index.js +37 -0
- package/build/cjs/components/Toolbar/InterpretationsAndDetailsToggler.js +50 -0
- package/build/cjs/components/Toolbar/MenuButton.styles.js +13 -0
- package/build/cjs/components/Toolbar/Toolbar.js +39 -0
- package/build/cjs/components/Toolbar/ToolbarSidebar.js +45 -0
- package/build/cjs/components/Toolbar/UpdateButton.js +57 -0
- package/build/cjs/components/Toolbar/__tests__/InterpretationsAndDetailsToggler.spec.js +50 -0
- package/build/cjs/components/Toolbar/__tests__/Toolbar.spec.js +24 -0
- package/build/cjs/components/Toolbar/__tests__/ToolbarSidebar.spec.js +30 -0
- package/build/cjs/components/Toolbar/__tests__/UpdateButton.spec.js +44 -0
- package/build/cjs/components/Toolbar/index.js +57 -0
- package/build/cjs/index.js +304 -46
- package/build/cjs/locales/en/translations.json +1 -0
- package/build/cjs/locales/es/translations.json +3 -2
- package/build/cjs/locales/zh/translations.json +26 -25
- package/build/es/__demo__/FileMenu.stories.js +7 -6
- package/build/es/__demo__/Toolbar.stories.js +69 -0
- package/build/es/components/FileMenu/FileMenu.js +20 -57
- package/build/es/components/FileMenu/__tests__/FileMenu.spec.js +293 -189
- package/build/es/components/Options/VisualizationOptions.js +3 -1
- package/build/es/components/Toolbar/HoverMenuBar/HoverMenuBar.js +90 -0
- package/build/es/components/Toolbar/HoverMenuBar/HoverMenuDropdown.js +44 -0
- package/build/es/components/Toolbar/HoverMenuBar/HoverMenuList.js +75 -0
- package/build/es/components/Toolbar/HoverMenuBar/HoverMenuListItem.js +78 -0
- package/build/es/components/Toolbar/HoverMenuBar/HoverMenuListItem.styles.js +4 -0
- package/build/es/components/Toolbar/HoverMenuBar/__tests__/HoverMenuBar.spec.js +168 -0
- package/build/es/components/Toolbar/HoverMenuBar/__tests__/HoverMenuDropdown.spec.js +16 -0
- package/build/es/components/Toolbar/HoverMenuBar/__tests__/HoverMenuList.spec.js +49 -0
- package/build/es/components/Toolbar/HoverMenuBar/__tests__/HoverMenuListItem.spec.js +41 -0
- package/build/es/components/Toolbar/HoverMenuBar/index.js +4 -0
- package/build/es/components/Toolbar/InterpretationsAndDetailsToggler.js +33 -0
- package/build/es/components/Toolbar/MenuButton.styles.js +4 -0
- package/build/es/components/Toolbar/Toolbar.js +24 -0
- package/build/es/components/Toolbar/ToolbarSidebar.js +29 -0
- package/build/es/components/Toolbar/UpdateButton.js +38 -0
- package/build/es/components/Toolbar/__tests__/InterpretationsAndDetailsToggler.spec.js +43 -0
- package/build/es/components/Toolbar/__tests__/Toolbar.spec.js +17 -0
- package/build/es/components/Toolbar/__tests__/ToolbarSidebar.spec.js +23 -0
- package/build/es/components/Toolbar/__tests__/UpdateButton.spec.js +37 -0
- package/build/es/components/Toolbar/index.js +5 -0
- package/build/es/index.js +1 -0
- package/build/es/locales/en/translations.json +1 -0
- package/build/es/locales/es/translations.json +3 -2
- package/build/es/locales/zh/translations.json +26 -25
- package/package.json +3 -1
- package/CHANGELOG.md +0 -4072
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
import { colors, elevations, spacers } from '@dhis2/ui-constants';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import React, { createContext, useCallback, useContext, useState } from 'react';
|
|
5
|
+
import { useHoverMenubarContext } from './HoverMenuBar.js';
|
|
6
|
+
|
|
7
|
+
const throwErrorIfNotInitialized = () => {
|
|
8
|
+
throw new Error('`HoverMenuListContext` has not been initialised');
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const HoverMenuListContext = /*#__PURE__*/createContext({
|
|
12
|
+
onSubmenuAnchorMouseEnter: throwErrorIfNotInitialized,
|
|
13
|
+
onMenuItemMouseEnter: throwErrorIfNotInitialized,
|
|
14
|
+
openedSubMenuEl: null,
|
|
15
|
+
dense: false
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const useHoverMenuListContext = () => useContext(HoverMenuListContext);
|
|
19
|
+
|
|
20
|
+
const HoverMenuList = _ref => {
|
|
21
|
+
let {
|
|
22
|
+
children,
|
|
23
|
+
className,
|
|
24
|
+
dataTest,
|
|
25
|
+
dense,
|
|
26
|
+
maxHeight,
|
|
27
|
+
maxWidth
|
|
28
|
+
} = _ref;
|
|
29
|
+
const {
|
|
30
|
+
setLastHoveredSubMenuEl
|
|
31
|
+
} = useHoverMenubarContext();
|
|
32
|
+
const [openedSubMenuEl, setOpenedSubMenuEl] = useState(null);
|
|
33
|
+
const onSubmenuAnchorMouseEnter = useCallback(event => {
|
|
34
|
+
if (openedSubMenuEl !== event.currentTarget) {
|
|
35
|
+
setOpenedSubMenuEl(event.currentTarget);
|
|
36
|
+
setLastHoveredSubMenuEl(event.currentTarget);
|
|
37
|
+
}
|
|
38
|
+
}, [openedSubMenuEl, setLastHoveredSubMenuEl]);
|
|
39
|
+
const onMenuItemMouseEnter = useCallback(() => {
|
|
40
|
+
setOpenedSubMenuEl(null);
|
|
41
|
+
setLastHoveredSubMenuEl(null);
|
|
42
|
+
}, [setLastHoveredSubMenuEl]);
|
|
43
|
+
return /*#__PURE__*/React.createElement(HoverMenuListContext.Provider, {
|
|
44
|
+
value: {
|
|
45
|
+
onSubmenuAnchorMouseEnter,
|
|
46
|
+
onMenuItemMouseEnter,
|
|
47
|
+
openedSubMenuEl,
|
|
48
|
+
dense
|
|
49
|
+
}
|
|
50
|
+
}, /*#__PURE__*/React.createElement("ul", {
|
|
51
|
+
"data-test": dataTest,
|
|
52
|
+
className: _JSXStyle.dynamic([["3026610659", [colors.white, colors.grey200, elevations.e300, dense ? '128' : '180', maxWidth, maxHeight, spacers.dp4]]]) + " " + (className || "")
|
|
53
|
+
}, children, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
54
|
+
id: "3026610659",
|
|
55
|
+
dynamic: [colors.white, colors.grey200, elevations.e300, dense ? '128' : '180', maxWidth, maxHeight, spacers.dp4]
|
|
56
|
+
}, ["ul.__jsx-style-dynamic-selector{position:relative;margin:0;padding:0;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background:".concat(colors.white, ";border:1px solid ").concat(colors.grey200, ";border-radius:3px;box-shadow:").concat(elevations.e300, ";display:inline-block;min-width:").concat(dense ? '128' : '180', "px;max-width:").concat(maxWidth, ";max-height:").concat(maxHeight, ";padding:").concat(spacers.dp4, " 0;overflow:auto;list-style:none;}")])));
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
HoverMenuList.defaultProps = {
|
|
60
|
+
dataTest: 'dhis2-analytics-hovermenulist',
|
|
61
|
+
maxWidth: '380px',
|
|
62
|
+
maxHeight: 'auto'
|
|
63
|
+
};
|
|
64
|
+
HoverMenuList.propTypes = {
|
|
65
|
+
/** Typically `MenuItem`, `MenuDivider`, and `MenuSectionHeader` */
|
|
66
|
+
children: PropTypes.node,
|
|
67
|
+
className: PropTypes.string,
|
|
68
|
+
dataTest: PropTypes.string,
|
|
69
|
+
|
|
70
|
+
/** Gives all HoverMenuListItem children a dense style */
|
|
71
|
+
dense: PropTypes.bool,
|
|
72
|
+
maxHeight: PropTypes.string,
|
|
73
|
+
maxWidth: PropTypes.string
|
|
74
|
+
};
|
|
75
|
+
export { HoverMenuList, useHoverMenuListContext };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
import { Popper } from '@dhis2-ui/popper';
|
|
3
|
+
import { Portal } from '@dhis2-ui/portal';
|
|
4
|
+
import { IconChevronRight24 } from '@dhis2/ui-icons';
|
|
5
|
+
import cx from 'classnames';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import React, { useRef } from 'react';
|
|
8
|
+
import { HoverMenuList, useHoverMenuListContext } from './HoverMenuList.js';
|
|
9
|
+
import styles from './HoverMenuListItem.styles.js';
|
|
10
|
+
|
|
11
|
+
const HoverMenuListItem = _ref => {
|
|
12
|
+
let {
|
|
13
|
+
onClick,
|
|
14
|
+
children,
|
|
15
|
+
icon,
|
|
16
|
+
className,
|
|
17
|
+
destructive,
|
|
18
|
+
disabled,
|
|
19
|
+
dataTest,
|
|
20
|
+
label
|
|
21
|
+
} = _ref;
|
|
22
|
+
const ref = useRef();
|
|
23
|
+
const {
|
|
24
|
+
onSubmenuAnchorMouseEnter,
|
|
25
|
+
onMenuItemMouseEnter,
|
|
26
|
+
openedSubMenuEl,
|
|
27
|
+
dense
|
|
28
|
+
} = useHoverMenuListContext();
|
|
29
|
+
const isSubMenuOpen = openedSubMenuEl === ref.current;
|
|
30
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("li", {
|
|
31
|
+
ref: ref,
|
|
32
|
+
"data-test": dataTest,
|
|
33
|
+
onClick: !disabled && !children && onClick ? onClick : undefined,
|
|
34
|
+
onMouseEnter: disabled ? undefined : children ? onSubmenuAnchorMouseEnter : onMenuItemMouseEnter,
|
|
35
|
+
className: "jsx-".concat(styles.__hash) + " " + (cx(className, {
|
|
36
|
+
destructive,
|
|
37
|
+
disabled,
|
|
38
|
+
dense,
|
|
39
|
+
active: isSubMenuOpen,
|
|
40
|
+
'with-chevron': children
|
|
41
|
+
}) || "")
|
|
42
|
+
}, icon && /*#__PURE__*/React.createElement("span", {
|
|
43
|
+
className: "jsx-".concat(styles.__hash) + " " + "icon"
|
|
44
|
+
}, icon), /*#__PURE__*/React.createElement("span", {
|
|
45
|
+
className: "jsx-".concat(styles.__hash) + " " + "label"
|
|
46
|
+
}, label), !!children && /*#__PURE__*/React.createElement("span", {
|
|
47
|
+
className: "jsx-".concat(styles.__hash) + " " + "chevron"
|
|
48
|
+
}, /*#__PURE__*/React.createElement(IconChevronRight24, null)), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
49
|
+
id: styles.__hash
|
|
50
|
+
}, styles)), children && isSubMenuOpen && /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(Popper, {
|
|
51
|
+
placement: "right-start",
|
|
52
|
+
reference: ref
|
|
53
|
+
}, /*#__PURE__*/React.createElement(HoverMenuList, {
|
|
54
|
+
dense: dense
|
|
55
|
+
}, children))));
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
HoverMenuListItem.defaultProps = {
|
|
59
|
+
dataTest: 'dhis2-uicore-hovermenulistitem'
|
|
60
|
+
};
|
|
61
|
+
HoverMenuListItem.propTypes = {
|
|
62
|
+
// Nested menu items become submenus
|
|
63
|
+
children: PropTypes.node,
|
|
64
|
+
className: PropTypes.string,
|
|
65
|
+
dataTest: PropTypes.string,
|
|
66
|
+
destructive: PropTypes.bool,
|
|
67
|
+
disabled: PropTypes.bool,
|
|
68
|
+
|
|
69
|
+
/** An icon for the left side of the menu item */
|
|
70
|
+
icon: PropTypes.node,
|
|
71
|
+
|
|
72
|
+
/** Text in the menu item */
|
|
73
|
+
label: PropTypes.node,
|
|
74
|
+
|
|
75
|
+
/** Click handler */
|
|
76
|
+
onClick: PropTypes.func
|
|
77
|
+
};
|
|
78
|
+
export { HoverMenuListItem };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { colors, spacers } from '@dhis2/ui-constants';
|
|
2
|
+
const _defaultExport = ["li.jsx-1056713124{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:0px ".concat(spacers.dp24, ";cursor:pointer;list-style:none;background-color:").concat(colors.white, ";color:").concat(colors.grey900, ";fill:").concat(colors.grey900, ";font-size:14px;line-height:16px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}"), "li.jsx-1056713124:hover{background-color:".concat(colors.grey200, ";}"), "li.jsx-1056713124:active,li.active.jsx-1056713124{background-color:".concat(colors.grey300, ";}"), "li.destructive.jsx-1056713124{color:".concat(colors.red700, ";fill:").concat(colors.red600, ";}"), "li.destructive.jsx-1056713124:hover{background-color:".concat(colors.red050, ";}"), "li.destructive.jsx-1056713124:active,li.destructive.active.jsx-1056713124{background-color:".concat(colors.red100, ";}"), "li.disabled.jsx-1056713124{cursor:not-allowed;color:".concat(colors.grey500, ";fill:").concat(colors.grey500, ";}"), "li.disabled.jsx-1056713124:hover{background-color:".concat(colors.white, ";}"), ".label.jsx-1056713124{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;padding:".concat(spacers.dp12, " 0;}"), "li.dense.jsx-1056713124 .label.jsx-1056713124{padding:".concat(spacers.dp8, " 0;}"), ".icon.jsx-1056713124{-webkit-box-flex:0;-webkit-flex-grow:0;-ms-flex-positive:0;flex-grow:0;margin-right:".concat(spacers.dp12, ";width:24px;height:24px;}"), ".chevron.jsx-1056713124{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-flex:0;-webkit-flex-grow:0;-ms-flex-positive:0;flex-grow:0;margin-left:".concat(spacers.dp24, ";}"), "li.dense.jsx-1056713124 .icon.jsx-1056713124{margin-right:".concat(spacers.dp8, ";width:16px;height:16px;}"), "li.jsx-1056713124 .icon.jsx-1056713124>svg{width:24px;height:24px;}", "li.dense.jsx-1056713124 .icon.jsx-1056713124>svg,li.jsx-1056713124 .chevron.jsx-1056713124>svg{width:16px;height:16px;}"];
|
|
3
|
+
_defaultExport.__hash = "1056713124";
|
|
4
|
+
export default _defaultExport;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
2
|
+
import { render, fireEvent, screen } from '@testing-library/react';
|
|
3
|
+
import { shallow } from 'enzyme';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { HoverMenuBar, HoverMenuDropdown, HoverMenuList, HoverMenuListItem } from '../index.js';
|
|
6
|
+
describe('<HoverMenuBar/>', () => {
|
|
7
|
+
it('renders children', () => {
|
|
8
|
+
const childNode = 'text node';
|
|
9
|
+
const wrapper = shallow( /*#__PURE__*/React.createElement(HoverMenuBar, null, childNode));
|
|
10
|
+
expect(wrapper.containsMatchingElement(childNode)).toBe(true);
|
|
11
|
+
});
|
|
12
|
+
it('accepts a `dataTest` prop', () => {
|
|
13
|
+
const dataTest = 'test';
|
|
14
|
+
const wrapper = shallow( /*#__PURE__*/React.createElement(HoverMenuBar, {
|
|
15
|
+
dataTest: dataTest
|
|
16
|
+
}, "children"));
|
|
17
|
+
expect(wrapper.find('div').prop('data-test')).toBe(dataTest);
|
|
18
|
+
});
|
|
19
|
+
describe('mouse interactions', () => {
|
|
20
|
+
it('does not open on hover before a dropdown anchor is clicked', async () => {
|
|
21
|
+
createFullMenuBarWrapper();
|
|
22
|
+
fireEvent.mouseOver(screen.getByText('Menu A'));
|
|
23
|
+
await expectMenuItemsInDocument([['Menu item A.1', false], ['Menu item A.2', false], ['Menu item A.3', false]]);
|
|
24
|
+
});
|
|
25
|
+
it('does not open when a disabled dropdown anchor is clicked', async () => {
|
|
26
|
+
createFullMenuBarWrapper();
|
|
27
|
+
fireEvent.click(screen.getByText('Menu C'));
|
|
28
|
+
await expectMenuItemsInDocument([['Menu item A.1', false], ['Menu item A.2', false], ['Menu item A.3', false]]);
|
|
29
|
+
});
|
|
30
|
+
it('opens menu list when clicked', async () => {
|
|
31
|
+
createFullMenuBarWrapper();
|
|
32
|
+
fireEvent.click(screen.getByText('Menu A'));
|
|
33
|
+
await expectMenuItemsInDocument([['Menu item A.1', true], ['Menu item B.1', false], ['Menu item C.1', false]]);
|
|
34
|
+
});
|
|
35
|
+
it('responds to hover once open', async () => {
|
|
36
|
+
createFullMenuBarWrapper();
|
|
37
|
+
fireEvent.click(screen.getByText('Menu A'));
|
|
38
|
+
fireEvent.mouseOver(screen.getByText('Menu B'));
|
|
39
|
+
await expectMenuItemsInDocument([['Menu item A.1', false], ['Menu item B.1', true], ['Menu item C.1', false]]);
|
|
40
|
+
});
|
|
41
|
+
it('does not open disabled dropdown on hover in hover mode', async () => {
|
|
42
|
+
createFullMenuBarWrapper();
|
|
43
|
+
fireEvent.click(screen.getByText('Menu B'));
|
|
44
|
+
fireEvent.mouseOver(screen.getByText('Menu C'));
|
|
45
|
+
await expectMenuItemsInDocument([['Menu item B.1', true], ['Menu item C.1', false]]);
|
|
46
|
+
});
|
|
47
|
+
it('opens submenus when in hover mode', async () => {
|
|
48
|
+
createFullMenuBarWrapper();
|
|
49
|
+
fireEvent.click(screen.getByText('Menu B'));
|
|
50
|
+
fireEvent.mouseOver(screen.getByText('Menu item B.1'));
|
|
51
|
+
await expectMenuItemsInDocument([['Menu item B.1.1', true], ['Menu item B.1.2', true], ['Menu item B.1.3', true], ['Menu item B.2.1', false], ['Menu item B.2.2', false], ['Menu item B.2.3', false]]);
|
|
52
|
+
fireEvent.mouseOver(screen.getByText('Menu item B.2'));
|
|
53
|
+
await expectMenuItemsInDocument([['Menu item B.1.1', false], ['Menu item B.1.2', false], ['Menu item B.1.3', false], ['Menu item B.2.1', true], ['Menu item B.2.2', true], ['Menu item B.2.3', true]]);
|
|
54
|
+
});
|
|
55
|
+
it('does not open disabled submenus when in hover mode', async () => {
|
|
56
|
+
createFullMenuBarWrapper();
|
|
57
|
+
fireEvent.click(screen.getByText('Menu B'));
|
|
58
|
+
fireEvent.mouseOver(screen.getByText('Menu item B.2'));
|
|
59
|
+
await expectMenuItemsInDocument([['Menu item B.2.1', true], ['Menu item B.2.2', true], ['Menu item B.2.3', true], ['Menu item B.3.1', false], ['Menu item B.3.2', false], ['Menu item B.3.3', false]]);
|
|
60
|
+
fireEvent.mouseOver(screen.getByText('Menu item B.3'));
|
|
61
|
+
await expectMenuItemsInDocument([['Menu item B.2.1', true], ['Menu item B.2.2', true], ['Menu item B.2.3', true], ['Menu item B.3.1', false], ['Menu item B.3.2', false], ['Menu item B.3.3', false]]);
|
|
62
|
+
});
|
|
63
|
+
it('closes when clicking on then document', async () => {
|
|
64
|
+
createFullMenuBarWrapper();
|
|
65
|
+
fireEvent.click(screen.getByText('Menu A'));
|
|
66
|
+
await expectMenuItemsInDocument([['Menu item A.1', true]]);
|
|
67
|
+
fireEvent.click(document);
|
|
68
|
+
await expectMenuItemsInDocument([['Menu item A.1', false]]);
|
|
69
|
+
});
|
|
70
|
+
it('stays open when clicking a open submenu anchor', async () => {
|
|
71
|
+
createFullMenuBarWrapper();
|
|
72
|
+
fireEvent.click(screen.getByText('Menu B'));
|
|
73
|
+
await expectMenuItemsInDocument([['Menu item B.1', true]]);
|
|
74
|
+
fireEvent.mouseOver(screen.getByText('Menu item B.1'));
|
|
75
|
+
await expectMenuItemsInDocument([['Menu item B.1', true], ['Menu item B.1.1', true], ['Menu item B.1.2', true], ['Menu item B.1.3', true]]);
|
|
76
|
+
fireEvent.click(screen.getByText('Menu item B.1'));
|
|
77
|
+
await expectMenuItemsInDocument([['Menu item B.1', true], ['Menu item B.1.1', true], ['Menu item B.1.2', true], ['Menu item B.1.3', true]]);
|
|
78
|
+
});
|
|
79
|
+
it('calls the onClick of the menu item and closes when clicking a menu item', async () => {
|
|
80
|
+
const menuItemOnClickSpy = jest.fn();
|
|
81
|
+
createFullMenuBarWrapper({
|
|
82
|
+
menuItemOnClickSpy
|
|
83
|
+
});
|
|
84
|
+
fireEvent.click(screen.getByText('Menu A'));
|
|
85
|
+
await expectMenuItemsInDocument([['Menu item A.1', true]]);
|
|
86
|
+
fireEvent.click(screen.getByText('Menu item A.1'));
|
|
87
|
+
expect(menuItemOnClickSpy).toHaveBeenCalledTimes(1);
|
|
88
|
+
await expectMenuItemsInDocument([['Menu item A.1', false]]);
|
|
89
|
+
});
|
|
90
|
+
it('calls the onClick of the menu item and closes when clicking a submenu item', async () => {
|
|
91
|
+
const subMenuItemOnClickSpy = jest.fn();
|
|
92
|
+
createFullMenuBarWrapper({
|
|
93
|
+
subMenuItemOnClickSpy
|
|
94
|
+
});
|
|
95
|
+
fireEvent.click(screen.getByText('Menu B'));
|
|
96
|
+
await expectMenuItemsInDocument([['Menu item B.1', true]]);
|
|
97
|
+
fireEvent.mouseOver(screen.getByText('Menu item B.1'));
|
|
98
|
+
await expectMenuItemsInDocument([['Menu item B.1.1', true]]);
|
|
99
|
+
fireEvent.click(screen.getByText('Menu item B.1.1'));
|
|
100
|
+
expect(subMenuItemOnClickSpy).toHaveBeenCalledTimes(1);
|
|
101
|
+
await expectMenuItemsInDocument([['Menu item B.1', false], ['Menu item B.1.1', false], ['Menu item B.1.1', false]]);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
function createFullMenuBarWrapper() {
|
|
107
|
+
let {
|
|
108
|
+
menuItemOnClickSpy,
|
|
109
|
+
subMenuItemOnClickSpy
|
|
110
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
111
|
+
return render( /*#__PURE__*/React.createElement(HoverMenuBar, null, /*#__PURE__*/React.createElement(HoverMenuDropdown, {
|
|
112
|
+
label: "Menu A"
|
|
113
|
+
}, /*#__PURE__*/React.createElement(HoverMenuList, null, /*#__PURE__*/React.createElement(HoverMenuListItem, {
|
|
114
|
+
label: "Menu item A.1",
|
|
115
|
+
onClick: menuItemOnClickSpy
|
|
116
|
+
}), /*#__PURE__*/React.createElement(HoverMenuListItem, {
|
|
117
|
+
label: "Menu item A.2"
|
|
118
|
+
}), /*#__PURE__*/React.createElement(HoverMenuListItem, {
|
|
119
|
+
label: "Menu item A.3"
|
|
120
|
+
}))), /*#__PURE__*/React.createElement(HoverMenuDropdown, {
|
|
121
|
+
label: "Menu B"
|
|
122
|
+
}, /*#__PURE__*/React.createElement(HoverMenuList, null, /*#__PURE__*/React.createElement(HoverMenuListItem, {
|
|
123
|
+
label: "Menu item B.1"
|
|
124
|
+
}, /*#__PURE__*/React.createElement(HoverMenuListItem, {
|
|
125
|
+
label: "Menu item B.1.1",
|
|
126
|
+
onClick: subMenuItemOnClickSpy
|
|
127
|
+
}), /*#__PURE__*/React.createElement(HoverMenuListItem, {
|
|
128
|
+
label: "Menu item B.1.2"
|
|
129
|
+
}), /*#__PURE__*/React.createElement(HoverMenuListItem, {
|
|
130
|
+
label: "Menu item B.1.3"
|
|
131
|
+
})), /*#__PURE__*/React.createElement(HoverMenuListItem, {
|
|
132
|
+
label: "Menu item B.2"
|
|
133
|
+
}, /*#__PURE__*/React.createElement(HoverMenuListItem, {
|
|
134
|
+
label: "Menu item B.2.1"
|
|
135
|
+
}), /*#__PURE__*/React.createElement(HoverMenuListItem, {
|
|
136
|
+
label: "Menu item B.2.2"
|
|
137
|
+
}), /*#__PURE__*/React.createElement(HoverMenuListItem, {
|
|
138
|
+
label: "Menu item B.2.3"
|
|
139
|
+
})), /*#__PURE__*/React.createElement(HoverMenuListItem, {
|
|
140
|
+
label: "Menu item B.3",
|
|
141
|
+
disabled: true
|
|
142
|
+
}, /*#__PURE__*/React.createElement(HoverMenuListItem, {
|
|
143
|
+
label: "Menu item B.3.1"
|
|
144
|
+
}), /*#__PURE__*/React.createElement(HoverMenuListItem, {
|
|
145
|
+
label: "Menu item B.3.2"
|
|
146
|
+
}), /*#__PURE__*/React.createElement(HoverMenuListItem, {
|
|
147
|
+
label: "Menu item B.3.3"
|
|
148
|
+
})))), /*#__PURE__*/React.createElement(HoverMenuDropdown, {
|
|
149
|
+
label: "Menu C",
|
|
150
|
+
disabled: true
|
|
151
|
+
}, /*#__PURE__*/React.createElement(HoverMenuList, null, /*#__PURE__*/React.createElement(HoverMenuListItem, {
|
|
152
|
+
label: "Menu item C.1"
|
|
153
|
+
}), /*#__PURE__*/React.createElement(HoverMenuListItem, {
|
|
154
|
+
label: "Menu item C.2"
|
|
155
|
+
}), /*#__PURE__*/React.createElement(HoverMenuListItem, {
|
|
156
|
+
label: "Menu item C.3"
|
|
157
|
+
})))));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
async function expectMenuItemsInDocument(items) {
|
|
161
|
+
for (const [text, inDocument] of items) {
|
|
162
|
+
if (inDocument) {
|
|
163
|
+
expect(await screen.findByText(text)).toBeInTheDocument();
|
|
164
|
+
} else {
|
|
165
|
+
expect(screen.queryByText(text)).not.toBeInTheDocument();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { shallow } from 'enzyme';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { HoverMenuDropdown } from '../index.js';
|
|
4
|
+
describe('<HoverMenuDropdown/>', () => {
|
|
5
|
+
/* Most of the props for this component are included
|
|
6
|
+
* in the mouse interaction tests for the HoverMenuBar.
|
|
7
|
+
* Only the `dataTest` prop needs to be verified here. */
|
|
8
|
+
it('accepts a `dataTest` prop', () => {
|
|
9
|
+
const dataTest = 'test';
|
|
10
|
+
const wrapper = shallow( /*#__PURE__*/React.createElement(HoverMenuDropdown, {
|
|
11
|
+
label: "test dropdown",
|
|
12
|
+
dataTest: dataTest
|
|
13
|
+
}, "children"));
|
|
14
|
+
expect(wrapper.find('button').prop('data-test')).toBe(dataTest);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { shallow, mount } from 'enzyme';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { HoverMenuList, HoverMenuListItem } from '../index.js';
|
|
4
|
+
describe('<HoverMenuList/>', () => {
|
|
5
|
+
const dataTest = 'test';
|
|
6
|
+
const childNode = 'children';
|
|
7
|
+
it('renders children', () => {
|
|
8
|
+
const wrapper = shallow( /*#__PURE__*/React.createElement(HoverMenuList, null, childNode));
|
|
9
|
+
expect(wrapper.containsMatchingElement(childNode)).toBe(true);
|
|
10
|
+
});
|
|
11
|
+
it('accept a `className` prop', () => {
|
|
12
|
+
const className = 'className';
|
|
13
|
+
const wrapper = shallow( /*#__PURE__*/React.createElement(HoverMenuList, {
|
|
14
|
+
className: className
|
|
15
|
+
}, childNode));
|
|
16
|
+
expect(wrapper.find('ul')).toHaveClassName(className);
|
|
17
|
+
});
|
|
18
|
+
it('accepts a `dataTest` prop', () => {
|
|
19
|
+
const wrapper = shallow( /*#__PURE__*/React.createElement(HoverMenuList, {
|
|
20
|
+
dataTest: dataTest
|
|
21
|
+
}, childNode));
|
|
22
|
+
expect(wrapper.find('ul').prop('data-test')).toBe(dataTest);
|
|
23
|
+
});
|
|
24
|
+
it('accept a `dense` prop', () => {
|
|
25
|
+
const wrapper = mount( /*#__PURE__*/React.createElement(HoverMenuList, {
|
|
26
|
+
dense: true
|
|
27
|
+
}, /*#__PURE__*/React.createElement(HoverMenuListItem, {
|
|
28
|
+
label: "item 1"
|
|
29
|
+
}), /*#__PURE__*/React.createElement(HoverMenuListItem, {
|
|
30
|
+
label: "item 2"
|
|
31
|
+
})));
|
|
32
|
+
expect(wrapper.find('li').first()).toHaveClassName('dense');
|
|
33
|
+
expect(wrapper.find('li').last()).toHaveClassName('dense');
|
|
34
|
+
});
|
|
35
|
+
it('accept a `maxHeight` prop', () => {
|
|
36
|
+
const maxHeight = '100000px';
|
|
37
|
+
const wrapper = shallow( /*#__PURE__*/React.createElement(HoverMenuList, {
|
|
38
|
+
maxHeight: maxHeight
|
|
39
|
+
}, childNode));
|
|
40
|
+
expect(wrapper.find('style').text()).toContain("max-height: ".concat(maxHeight));
|
|
41
|
+
});
|
|
42
|
+
it('accept a `maxWidth` prop', () => {
|
|
43
|
+
const maxWidth = '100000px';
|
|
44
|
+
const wrapper = shallow( /*#__PURE__*/React.createElement(HoverMenuList, {
|
|
45
|
+
maxWidth: maxWidth
|
|
46
|
+
}, childNode));
|
|
47
|
+
expect(wrapper.find('style').text()).toContain("max-width: ".concat(maxWidth));
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { shallow } from 'enzyme';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { HoverMenuListItem } from '../index.js';
|
|
4
|
+
describe('<HoverMenuListItem/>', () => {
|
|
5
|
+
/* Some of the props for this component are included
|
|
6
|
+
* in the mouse interaction tests for the HoverMenuBar.
|
|
7
|
+
* Only the `className`, `dataTest`, `destructive` and
|
|
8
|
+
* `icon` prop need to be verified here. */
|
|
9
|
+
it('accepts a `className` prop', () => {
|
|
10
|
+
const className = 'className';
|
|
11
|
+
const wrapper = shallow( /*#__PURE__*/React.createElement(HoverMenuListItem, {
|
|
12
|
+
className: className
|
|
13
|
+
}));
|
|
14
|
+
expect(wrapper.find('li')).toHaveClassName(className);
|
|
15
|
+
});
|
|
16
|
+
it('accepts a `dataTest` prop', () => {
|
|
17
|
+
const dataTest = 'test';
|
|
18
|
+
const wrapper = shallow( /*#__PURE__*/React.createElement(HoverMenuListItem, {
|
|
19
|
+
dataTest: dataTest
|
|
20
|
+
}));
|
|
21
|
+
expect(wrapper.find('li').prop('data-test')).toBe(dataTest);
|
|
22
|
+
});
|
|
23
|
+
it('accepts a `destructive` prop', () => {
|
|
24
|
+
const wrapper = shallow( /*#__PURE__*/React.createElement(HoverMenuListItem, {
|
|
25
|
+
destructive: true
|
|
26
|
+
}));
|
|
27
|
+
expect(wrapper.find('li')).toHaveClassName('destructive');
|
|
28
|
+
});
|
|
29
|
+
it('accepts an `icon` prop', () => {
|
|
30
|
+
const iconText = 'I am an icon';
|
|
31
|
+
const icon = /*#__PURE__*/React.createElement("span", {
|
|
32
|
+
id: "testicon"
|
|
33
|
+
}, iconText);
|
|
34
|
+
const wrapper = shallow( /*#__PURE__*/React.createElement(HoverMenuListItem, {
|
|
35
|
+
icon: icon
|
|
36
|
+
}));
|
|
37
|
+
expect(wrapper.find('span.icon')).toExist();
|
|
38
|
+
expect(wrapper.find('span#testicon')).toExist();
|
|
39
|
+
expect(wrapper.find('span#testicon').text()).toBe(iconText);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
import i18n from '@dhis2/d2-i18n';
|
|
3
|
+
import { IconChevronRight24, IconChevronLeft24 } from '@dhis2/ui';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import menuButtonStyles from './MenuButton.styles.js';
|
|
7
|
+
export const InterpretationsAndDetailsToggler = _ref => {
|
|
8
|
+
let {
|
|
9
|
+
onClick,
|
|
10
|
+
dataTest,
|
|
11
|
+
disabled,
|
|
12
|
+
isShowing
|
|
13
|
+
} = _ref;
|
|
14
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
15
|
+
onClick: onClick,
|
|
16
|
+
disabled: disabled,
|
|
17
|
+
"data-test": dataTest,
|
|
18
|
+
className: "jsx-1238484262 " + "jsx-".concat(menuButtonStyles.__hash)
|
|
19
|
+
}, isShowing ? /*#__PURE__*/React.createElement(IconChevronRight24, null) : /*#__PURE__*/React.createElement(IconChevronLeft24, null), i18n.t('Interpretations and details'), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
20
|
+
id: menuButtonStyles.__hash
|
|
21
|
+
}, menuButtonStyles), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
22
|
+
id: "1238484262"
|
|
23
|
+
}, ["button.jsx-1238484262{gap:8px;}"]));
|
|
24
|
+
};
|
|
25
|
+
InterpretationsAndDetailsToggler.defaultProps = {
|
|
26
|
+
dataTest: 'dhis2-analytics-interpretationsanddetailstoggler'
|
|
27
|
+
};
|
|
28
|
+
InterpretationsAndDetailsToggler.propTypes = {
|
|
29
|
+
onClick: PropTypes.func.isRequired,
|
|
30
|
+
dataTest: PropTypes.string,
|
|
31
|
+
disabled: PropTypes.bool,
|
|
32
|
+
isShowing: PropTypes.bool
|
|
33
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { colors, spacers, theme } from '@dhis2/ui-constants';
|
|
2
|
+
const _defaultExport = ["button.jsx-4266781296{all:unset;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;font-size:14px;line-height:14px;padding:0 ".concat(spacers.dp12, ";color:").concat(colors.grey900, ";-webkit-transition:background-color 250ms cubic-bezier(0.4,0,0.2,1) 0ms;transition:background-color 250ms cubic-bezier(0.4,0,0.2,1) 0ms;cursor:pointer;}"), "button.jsx-4266781296:hover.jsx-4266781296:enabled,button.jsx-4266781296:active{background-color:".concat(colors.grey200, ";}"), "button.jsx-4266781296:focus{outline:3px solid ".concat(theme.focus, ";outline-offset:-3px;}"), "button.jsx-4266781296:focus.jsx-4266781296:not(:focus-visible){outline:none;}", "button.jsx-4266781296:disabled{color:".concat(colors.grey500, ";cursor:not-allowed;}")];
|
|
3
|
+
_defaultExport.__hash = "4266781296";
|
|
4
|
+
export default _defaultExport;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
import { colors } from '@dhis2/ui-constants';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
export const Toolbar = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
children,
|
|
8
|
+
dataTest
|
|
9
|
+
} = _ref;
|
|
10
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
11
|
+
"data-test": dataTest,
|
|
12
|
+
className: _JSXStyle.dynamic([["2617706539", [colors.grey400, colors.white]]])
|
|
13
|
+
}, children, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
14
|
+
id: "2617706539",
|
|
15
|
+
dynamic: [colors.grey400, colors.white]
|
|
16
|
+
}, ["div.__jsx-style-dynamic-selector{box-sizing:border-box;min-height:32px;max-height:32px;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:stretch;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch;border-bottom:1px solid ".concat(colors.grey400, ";background-color:").concat(colors.white, ";}")]));
|
|
17
|
+
};
|
|
18
|
+
Toolbar.defaultProps = {
|
|
19
|
+
dataTest: 'dhis2-analytics-toolbar'
|
|
20
|
+
};
|
|
21
|
+
Toolbar.propTypes = {
|
|
22
|
+
children: PropTypes.node,
|
|
23
|
+
dataTest: PropTypes.string
|
|
24
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
import { colors } from '@dhis2/ui-constants';
|
|
3
|
+
import cx from 'classnames';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
export const ToolbarSidebar = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
children,
|
|
9
|
+
dataTest,
|
|
10
|
+
isHidden
|
|
11
|
+
} = _ref;
|
|
12
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
13
|
+
"data-test": dataTest,
|
|
14
|
+
className: _JSXStyle.dynamic([["1150014343", [colors.grey400]]]) + " " + (cx('container', {
|
|
15
|
+
isHidden
|
|
16
|
+
}) || "")
|
|
17
|
+
}, children, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
18
|
+
id: "1150014343",
|
|
19
|
+
dynamic: [colors.grey400]
|
|
20
|
+
}, ["div.__jsx-style-dynamic-selector{width:260px;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:stretch;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch;border-right:1px solid ".concat(colors.grey400, ";}"), "div.isHidden.__jsx-style-dynamic-selector{display:none;}"]));
|
|
21
|
+
};
|
|
22
|
+
ToolbarSidebar.defaultProps = {
|
|
23
|
+
dataTest: 'dhis2-analytics-toolbarsidebar'
|
|
24
|
+
};
|
|
25
|
+
ToolbarSidebar.propTypes = {
|
|
26
|
+
children: PropTypes.node,
|
|
27
|
+
dataTest: PropTypes.string,
|
|
28
|
+
isHidden: PropTypes.bool
|
|
29
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
import { CircularLoader } from '@dhis2-ui/loader';
|
|
3
|
+
import i18n from '@dhis2/d2-i18n';
|
|
4
|
+
import { colors } from '@dhis2/ui-constants';
|
|
5
|
+
import { IconSync16 } from '@dhis2/ui-icons';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import menuButtonStyles from './MenuButton.styles.js';
|
|
9
|
+
export const UpdateButton = _ref => {
|
|
10
|
+
let {
|
|
11
|
+
onClick,
|
|
12
|
+
disabled,
|
|
13
|
+
loading,
|
|
14
|
+
dataTest
|
|
15
|
+
} = _ref;
|
|
16
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
17
|
+
onClick: onClick,
|
|
18
|
+
disabled: disabled,
|
|
19
|
+
"data-test": dataTest,
|
|
20
|
+
className: "jsx-".concat(menuButtonStyles.__hash) + " " + _JSXStyle.dynamic([["2364287882", [colors.blue700, colors.blue100, colors.blue200]]])
|
|
21
|
+
}, loading ? /*#__PURE__*/React.createElement(CircularLoader, {
|
|
22
|
+
extrasmall: true
|
|
23
|
+
}) : /*#__PURE__*/React.createElement(IconSync16, null), i18n.t('Update'), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
24
|
+
id: menuButtonStyles.__hash
|
|
25
|
+
}, menuButtonStyles), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
26
|
+
id: "2364287882",
|
|
27
|
+
dynamic: [colors.blue700, colors.blue100, colors.blue200]
|
|
28
|
+
}, ["button.__jsx-style-dynamic-selector{gap:8px;color:".concat(colors.blue700, ";font-weight:500;}"), "button.__jsx-style-dynamic-selector:hover.__jsx-style-dynamic-selector:enabled{background:".concat(colors.blue100, ";}"), "button.__jsx-style-dynamic-selector:active{background:".concat(colors.blue200, ";}")]));
|
|
29
|
+
};
|
|
30
|
+
UpdateButton.defaultProps = {
|
|
31
|
+
dataTest: 'dhis2-analytics-updatebutton'
|
|
32
|
+
};
|
|
33
|
+
UpdateButton.propTypes = {
|
|
34
|
+
onClick: PropTypes.func.isRequired,
|
|
35
|
+
dataTest: PropTypes.string,
|
|
36
|
+
disabled: PropTypes.bool,
|
|
37
|
+
loading: PropTypes.bool
|
|
38
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { shallow } from 'enzyme';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { InterpretationsAndDetailsToggler } from '../index.js';
|
|
4
|
+
describe('<InterpretationsAndDetailsToggler/>', () => {
|
|
5
|
+
const noop = () => {};
|
|
6
|
+
|
|
7
|
+
it('accepts an `onClick` prop', () => {
|
|
8
|
+
const onClick = jest.fn();
|
|
9
|
+
const wrapper = shallow( /*#__PURE__*/React.createElement(InterpretationsAndDetailsToggler, {
|
|
10
|
+
onClick: onClick
|
|
11
|
+
}));
|
|
12
|
+
wrapper.simulate('click');
|
|
13
|
+
expect(onClick).toHaveBeenCalledTimes(1);
|
|
14
|
+
});
|
|
15
|
+
it('accepts a `dataTest` prop', () => {
|
|
16
|
+
const dataTest = 'test';
|
|
17
|
+
const wrapper = shallow( /*#__PURE__*/React.createElement(InterpretationsAndDetailsToggler, {
|
|
18
|
+
onClick: noop,
|
|
19
|
+
dataTest: dataTest
|
|
20
|
+
}));
|
|
21
|
+
expect(wrapper.prop('data-test')).toBe(dataTest);
|
|
22
|
+
});
|
|
23
|
+
it('accepts a `disabled` prop', () => {
|
|
24
|
+
const wrapper = shallow( /*#__PURE__*/React.createElement(InterpretationsAndDetailsToggler, {
|
|
25
|
+
disabled: true,
|
|
26
|
+
onClick: noop
|
|
27
|
+
}));
|
|
28
|
+
expect(wrapper.find('button').prop('disabled')).toEqual(true);
|
|
29
|
+
});
|
|
30
|
+
it('accepts an `isShowing` prop', () => {
|
|
31
|
+
const wrapper = shallow( /*#__PURE__*/React.createElement(InterpretationsAndDetailsToggler, {
|
|
32
|
+
onClick: noop
|
|
33
|
+
}));
|
|
34
|
+
const wrapperWithIsShowing = shallow( /*#__PURE__*/React.createElement(InterpretationsAndDetailsToggler, {
|
|
35
|
+
isShowing: true,
|
|
36
|
+
onClick: noop
|
|
37
|
+
}));
|
|
38
|
+
expect(wrapper.find('SvgChevronRight24')).toHaveLength(0);
|
|
39
|
+
expect(wrapper.find('SvgChevronLeft24')).toHaveLength(1);
|
|
40
|
+
expect(wrapperWithIsShowing.find('SvgChevronRight24')).toHaveLength(1);
|
|
41
|
+
expect(wrapperWithIsShowing.find('SvgChevronLeft24')).toHaveLength(0);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { shallow } from 'enzyme';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Toolbar } from '../index.js';
|
|
4
|
+
describe('<Toolbar/>', () => {
|
|
5
|
+
it('renders children', () => {
|
|
6
|
+
const childNode = 'text node';
|
|
7
|
+
const wrapper = shallow( /*#__PURE__*/React.createElement(Toolbar, null, childNode));
|
|
8
|
+
expect(wrapper.containsMatchingElement(childNode)).toBe(true);
|
|
9
|
+
});
|
|
10
|
+
it('accepts a `dataTest` prop', () => {
|
|
11
|
+
const dataTest = 'test';
|
|
12
|
+
const wrapper = shallow( /*#__PURE__*/React.createElement(Toolbar, {
|
|
13
|
+
dataTest: dataTest
|
|
14
|
+
}));
|
|
15
|
+
expect(wrapper.prop('data-test')).toBe(dataTest);
|
|
16
|
+
});
|
|
17
|
+
});
|