@nestio/pam 2.0.5-beta.4 → 2.0.6
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/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/inspectionProfiles/profiles_settings.xml +6 -0
- package/.idea/misc.xml +4 -0
- package/.idea/modules.xml +8 -0
- package/.idea/pam.iml +15 -0
- package/.idea/vcs.xml +6 -0
- package/README.md +26 -0
- package/examples/components/Select.jsx +12 -26
- package/examples/index.html +0 -5
- package/lib/components/MultiSelect.js +3 -3
- package/lib/components/MultiSelectOption.js +3 -22
- package/lib/components/OptionListSet.js +3 -11
- package/lib/components/SelectCore.js +26 -84
- package/lib/components/SelectOption.js +11 -44
- package/lib/components/SingleSelect.js +0 -2
- package/lib/components/TagBoxMenuSelect.js +0 -2
- package/lib/components/styles/MultiSelectOption.scss +0 -4
- package/lib/components/styles/SelectOption.scss +0 -12
- package/lib/components/styles/_variables.scss +0 -1
- package/lib/components/styles/icons/05a4d7fb.eot +0 -0
- package/lib/components/styles/icons/05a4d7fb.otf +0 -0
- package/lib/components/styles/icons/05a4d7fb.ttf +0 -0
- package/lib/components/styles/icons/05a4d7fb.woff +0 -0
- package/lib/components/styles/icons/icons.css +57 -1
- package/package.json +3 -3
- package/src/components/MultiSelect.jsx +2 -2
- package/src/components/MultiSelectOption.jsx +3 -21
- package/src/components/OptionListSet.jsx +2 -9
- package/src/components/SelectCore.jsx +11 -62
- package/src/components/SelectOption.jsx +8 -27
- package/src/components/SingleSelect.jsx +0 -2
- package/src/components/TagBoxMenuSelect.jsx +0 -2
- package/src/components/__tests__/MultiSelect.spec.js +2 -0
- package/src/components/__tests__/MultiSelectOption.spec.js +2 -42
- package/src/components/__tests__/OptionListSet.spec.js +1 -24
- package/src/components/__tests__/SelectCore.spec.js +0 -103
- package/src/components/__tests__/SelectOption.spec.js +2 -33
- package/src/components/__tests__/SingleSelectOption.spec.js +1 -2
- package/src/components/styles/MultiSelectOption.scss +0 -4
- package/src/components/styles/SelectOption.scss +0 -12
- package/src/components/styles/_variables.scss +0 -1
- package/src/components/styles/icons/05a4d7fb.eot +0 -0
- package/src/components/styles/icons/05a4d7fb.otf +0 -0
- package/src/components/styles/icons/05a4d7fb.ttf +0 -0
- package/src/components/styles/icons/05a4d7fb.woff +0 -0
- package/src/components/styles/icons/icons.css +57 -1
- package/lib/components/Collapse.js +0 -50
- package/lib/constants.js +0 -7
- package/src/components/Collapse.jsx +0 -30
- package/src/components/__tests__/Collapse.spec.js +0 -26
- package/src/constants.js +0 -2
|
@@ -3,8 +3,6 @@ import { shallow, mount } from 'enzyme';
|
|
|
3
3
|
import SelectCore, { PureSelectCore } from '../SelectCore';
|
|
4
4
|
import SingleSelectValueAdapter from '../../adapters/SingleSelectValueAdapter';
|
|
5
5
|
import MultiSelectValueAdapter from '../../adapters/MultiSelectValueAdapter';
|
|
6
|
-
import { OPTION_NOT_COLLAPSED, OPTION_COLLAPSED } from '../../constants';
|
|
7
|
-
|
|
8
6
|
import { createFakeEvent } from 'test/utils/enzyme-utils';
|
|
9
7
|
|
|
10
8
|
const MenuComponent = () => <ul></ul>;
|
|
@@ -492,107 +490,6 @@ describe('filtering options', function(){
|
|
|
492
490
|
wrapper.instance()._getFilteredOptions();
|
|
493
491
|
expect(mockFilterOption).toHaveBeenCalledTimes(4);
|
|
494
492
|
});
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
it('calls onOptionsFiltered with filtered options', function(){
|
|
498
|
-
const onOptionsFiltered = jest.fn();
|
|
499
|
-
const wrapper = mount(<PureSelectCore {...defaultProps} filterOption={filterOption} onOptionsFiltered={onOptionsFiltered} />, {lifecycleExperimental: true});
|
|
500
|
-
wrapper.instance().changeText('Tw');
|
|
501
|
-
expect(onOptionsFiltered).toHaveBeenCalledTimes(1);
|
|
502
|
-
expect(onOptionsFiltered).toHaveBeenCalledWith([defaultProps.options[1]]);
|
|
503
|
-
wrapper.instance().changeText('');
|
|
504
|
-
expect(onOptionsFiltered).toHaveBeenCalledTimes(2);
|
|
505
|
-
expect(onOptionsFiltered).toHaveBeenCalledWith(defaultProps.options);
|
|
506
|
-
});
|
|
507
|
-
|
|
508
|
-
it('calls onChangeText with updated text', function(){
|
|
509
|
-
const onChangeText = jest.fn();
|
|
510
|
-
const wrapper = mount(<PureSelectCore {...defaultProps} filterOption={filterOption} onChangeText={onChangeText} />, {lifecycleExperimental: true});
|
|
511
|
-
wrapper.instance().changeText('Tw');
|
|
512
|
-
expect(onChangeText).toHaveBeenCalledTimes(1);
|
|
513
|
-
expect(onChangeText).toHaveBeenCalledWith('Tw');
|
|
514
|
-
wrapper.instance().changeText('');
|
|
515
|
-
expect(onChangeText).toHaveBeenCalledTimes(2);
|
|
516
|
-
expect(onChangeText).toHaveBeenCalledWith('');
|
|
517
|
-
});
|
|
518
|
-
});
|
|
519
|
-
|
|
520
|
-
describe('collapse behavior', function () {
|
|
521
|
-
const optionsWithCollapse = [{value: 1, label: 'One'}, {value: 2, label: 'Two', collapsedBy: 1}, {value: 3, label: 'Three', collapsedBy: 1}, {value: 4, label: 'Four'}, {value: 5, label: 'Five', collapsedBy: 4}]
|
|
522
|
-
|
|
523
|
-
describe('when there are no collapsibleOptions', function ( ) {
|
|
524
|
-
it('does not return collapsible state and does not filter options', function(){
|
|
525
|
-
const wrapper = shallow(<PureSelectCore {...defaultProps} options={optionsWithCollapse} />);
|
|
526
|
-
expect(wrapper.instance().getCollapsibleState(1)).toEqual(null)
|
|
527
|
-
expect(wrapper.instance().getCollapsibleState(2)).toEqual(null)
|
|
528
|
-
expect(wrapper.instance().getCollapsibleState(3)).toEqual(null)
|
|
529
|
-
expect(wrapper.instance().getCollapsibleState(4)).toEqual(null)
|
|
530
|
-
expect(wrapper.instance().getCollapsibleState(5)).toEqual(null)
|
|
531
|
-
expect(wrapper.instance()._getFilteredOptions()).toEqual(optionsWithCollapse);
|
|
532
|
-
wrapper.instance().toggleCollapsedValue(1);
|
|
533
|
-
expect(wrapper.instance().getCollapsibleState(1)).toEqual(null)
|
|
534
|
-
expect(wrapper.instance().getCollapsibleState(2)).toEqual(null)
|
|
535
|
-
expect(wrapper.instance().getCollapsibleState(3)).toEqual(null)
|
|
536
|
-
expect(wrapper.instance().getCollapsibleState(4)).toEqual(null)
|
|
537
|
-
expect(wrapper.instance().getCollapsibleState(5)).toEqual(null)
|
|
538
|
-
expect(wrapper.instance()._getFilteredOptions()).toEqual(optionsWithCollapse);
|
|
539
|
-
});
|
|
540
|
-
});
|
|
541
|
-
|
|
542
|
-
describe('when collapsibleOptions are provided but select is filtered', function () {
|
|
543
|
-
it('does not return collapsible state and does not filter options', function(){
|
|
544
|
-
const wrapper = shallow(<PureSelectCore {...defaultProps} options={optionsWithCollapse} collapsibleOptions={[1, 4]} />);
|
|
545
|
-
wrapper.instance().toggleCollapsedValue(1);
|
|
546
|
-
wrapper.instance().changeText('Tw');
|
|
547
|
-
expect(wrapper.instance().getCollapsibleState(1)).toEqual(null)
|
|
548
|
-
expect(wrapper.instance().getCollapsibleState(2)).toEqual(null)
|
|
549
|
-
expect(wrapper.instance().getCollapsibleState(3)).toEqual(null)
|
|
550
|
-
expect(wrapper.instance().getCollapsibleState(4)).toEqual(null)
|
|
551
|
-
expect(wrapper.instance().getCollapsibleState(5)).toEqual(null)
|
|
552
|
-
// becaused filtered, we are returning it even though its referenced by collapsedBy
|
|
553
|
-
expect(wrapper.instance()._getFilteredOptions()).toEqual([optionsWithCollapse[1]]);
|
|
554
|
-
});
|
|
555
|
-
});
|
|
556
|
-
|
|
557
|
-
describe('when collapsedValue is not one of the collapsibleOptions', function(){
|
|
558
|
-
it('returns null and not collapsed for others', function(){
|
|
559
|
-
const wrapper = shallow(<PureSelectCore {...defaultProps} options={optionsWithCollapse} collapsibleOptions={[1, 4]} />);
|
|
560
|
-
wrapper.instance().toggleCollapsedValue(2);
|
|
561
|
-
expect(wrapper.instance().getCollapsibleState(1)).toEqual(OPTION_NOT_COLLAPSED)
|
|
562
|
-
expect(wrapper.instance().getCollapsibleState(2)).toEqual(null)
|
|
563
|
-
expect(wrapper.instance().getCollapsibleState(3)).toEqual(null)
|
|
564
|
-
expect(wrapper.instance().getCollapsibleState(4)).toEqual(OPTION_NOT_COLLAPSED)
|
|
565
|
-
expect(wrapper.instance().getCollapsibleState(5)).toEqual(null)
|
|
566
|
-
expect(wrapper.instance()._getFilteredOptions()).toEqual(optionsWithCollapse);
|
|
567
|
-
});
|
|
568
|
-
})
|
|
569
|
-
|
|
570
|
-
describe('when value is collapsed', function() {
|
|
571
|
-
it('returns OPTION_COLLAPSED and filters out options with collapsedBy attribute', function () {
|
|
572
|
-
const wrapper = shallow(<PureSelectCore {...defaultProps} options={optionsWithCollapse} collapsibleOptions={[1, 4]} />);
|
|
573
|
-
wrapper.instance().toggleCollapsedValue(1);
|
|
574
|
-
expect(wrapper.instance().getCollapsibleState(1)).toEqual(OPTION_COLLAPSED)
|
|
575
|
-
expect(wrapper.instance().getCollapsibleState(2)).toEqual(null)
|
|
576
|
-
expect(wrapper.instance().getCollapsibleState(3)).toEqual(null)
|
|
577
|
-
expect(wrapper.instance().getCollapsibleState(4)).toEqual(OPTION_NOT_COLLAPSED)
|
|
578
|
-
expect(wrapper.instance().getCollapsibleState(5)).toEqual(null)
|
|
579
|
-
expect(wrapper.instance()._getFilteredOptions()).toEqual([optionsWithCollapse[0], optionsWithCollapse[3], optionsWithCollapse[4]]);
|
|
580
|
-
});
|
|
581
|
-
});
|
|
582
|
-
|
|
583
|
-
describe('when value is toggled', function() {
|
|
584
|
-
it('returns OPTION_NOT_COLLAPSED and does not filter out options with collapsedBy attribute', function(){
|
|
585
|
-
const wrapper = shallow(<PureSelectCore {...defaultProps} options={optionsWithCollapse} collapsibleOptions={[1, 4]} />);
|
|
586
|
-
wrapper.instance().toggleCollapsedValue(1);
|
|
587
|
-
wrapper.instance().toggleCollapsedValue(1);
|
|
588
|
-
expect(wrapper.instance().getCollapsibleState(1)).toEqual(OPTION_NOT_COLLAPSED)
|
|
589
|
-
expect(wrapper.instance().getCollapsibleState(2)).toEqual(null)
|
|
590
|
-
expect(wrapper.instance().getCollapsibleState(3)).toEqual(null)
|
|
591
|
-
expect(wrapper.instance().getCollapsibleState(4)).toEqual(OPTION_NOT_COLLAPSED)
|
|
592
|
-
expect(wrapper.instance().getCollapsibleState(5)).toEqual(null)
|
|
593
|
-
expect(wrapper.instance()._getFilteredOptions()).toEqual(optionsWithCollapse);
|
|
594
|
-
});
|
|
595
|
-
});
|
|
596
493
|
});
|
|
597
494
|
|
|
598
495
|
describe('render components', function(){
|
|
@@ -3,8 +3,7 @@ import { shallow } from 'enzyme';
|
|
|
3
3
|
|
|
4
4
|
import { createFakeEvent } from 'test/utils/enzyme-utils';
|
|
5
5
|
import SelectOption from '../SelectOption';
|
|
6
|
-
|
|
7
|
-
import { OPTION_NOT_COLLAPSED, OPTION_COLLAPSED } from '../../constants';
|
|
6
|
+
|
|
8
7
|
|
|
9
8
|
let defaultProps;
|
|
10
9
|
|
|
@@ -18,9 +17,7 @@ beforeEach(function(){
|
|
|
18
17
|
option: {value: 1, label: 'one'},
|
|
19
18
|
unselectOnClick: true,
|
|
20
19
|
renderOptionLabel: jest.fn(),
|
|
21
|
-
index: 0
|
|
22
|
-
toggleCollapsedValue: jest.fn(),
|
|
23
|
-
collapsibleState: null
|
|
20
|
+
index: 0
|
|
24
21
|
};
|
|
25
22
|
})
|
|
26
23
|
|
|
@@ -66,31 +63,3 @@ test('it triggers setIndex on mouse enter', () => {
|
|
|
66
63
|
wrapper.find('li').simulate('mouseenter');
|
|
67
64
|
expect(defaultProps.setIndex).toHaveBeenCalledTimes(1);
|
|
68
65
|
});
|
|
69
|
-
|
|
70
|
-
test('it renders Collapse if collapsibleState is not null', function(){
|
|
71
|
-
const wrapper = shallow(<SelectOption {...defaultProps}><span /></SelectOption>);
|
|
72
|
-
expect(wrapper.find(Collapse).length).toEqual(0);
|
|
73
|
-
wrapper.setProps({collapsibleState: OPTION_COLLAPSED});
|
|
74
|
-
expect(wrapper.find(Collapse).length).toEqual(1);
|
|
75
|
-
expect(wrapper.find(Collapse).at(0).prop('collapsibleState')).toEqual(OPTION_COLLAPSED);
|
|
76
|
-
|
|
77
|
-
wrapper.setProps({collapsibleState: OPTION_NOT_COLLAPSED});
|
|
78
|
-
expect(wrapper.find(Collapse).length).toEqual(1);
|
|
79
|
-
expect(wrapper.find(Collapse).at(0).prop('collapsibleState')).toEqual(OPTION_NOT_COLLAPSED);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
test('clicking on Collapse calls toggleCollapsedValue', function(){
|
|
83
|
-
const wrapper = shallow(<SelectOption {...defaultProps} collapsibleState={OPTION_COLLAPSED}><span /></SelectOption>);
|
|
84
|
-
expect(defaultProps.toggleCollapsedValue).not.toHaveBeenCalled();
|
|
85
|
-
const e = {stopPropagation: jest.fn(), nativeEvent: { stopImmediatePropagation: jest.fn()}};
|
|
86
|
-
wrapper.find(Collapse).at(0).simulate('click', e);
|
|
87
|
-
expect(defaultProps.toggleCollapsedValue).toHaveBeenCalledWith(defaultProps.option.value);
|
|
88
|
-
expect(e.stopPropagation).toHaveBeenCalled();
|
|
89
|
-
expect(e.nativeEvent.stopImmediatePropagation).toHaveBeenCalled();
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
test('adds classname if option.optionClassName', function(){
|
|
93
|
-
const option = {label: 'One', value: 1, optionClassName: 'some-class'};
|
|
94
|
-
const wrapper = shallow(<SelectOption {...defaultProps} option={option}><span /></SelectOption>);
|
|
95
|
-
expect(wrapper.find('li').hasClass('some-class')).toBe(true);
|
|
96
|
-
});
|
|
@@ -15,8 +15,7 @@ const getDefaultProps = () => ({
|
|
|
15
15
|
option: {value: 1, label: 'one'},
|
|
16
16
|
isHighlighted: false,
|
|
17
17
|
index: 0,
|
|
18
|
-
setIndex: sinon.spy()
|
|
19
|
-
toggleCollapsedValue: jest.fn()
|
|
18
|
+
setIndex: sinon.spy()
|
|
20
19
|
});
|
|
21
20
|
|
|
22
21
|
test('it passes the correct classnames based on props', () => {
|
|
@@ -18,19 +18,7 @@
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
22
21
|
.highlighted {
|
|
23
22
|
background-color: $select-hover-background-color;
|
|
24
23
|
color: $select-hover-text-color;
|
|
25
24
|
}
|
|
26
|
-
|
|
27
|
-
.collapse {
|
|
28
|
-
vertical-align: top;
|
|
29
|
-
padding-right: 8px;
|
|
30
|
-
width: 16px;
|
|
31
|
-
display: inline-block;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.option .collapse-icon {
|
|
35
|
-
font-size: 10px;
|
|
36
|
-
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1,57 @@
|
|
|
1
|
-
@font-face
|
|
1
|
+
@font-face {
|
|
2
|
+
font-family: 'Pam';
|
|
3
|
+
src: url('./05a4d7fb.eot');
|
|
4
|
+
src: url('./05a4d7fb.eot?#iefix') format('embedded-opentype'),
|
|
5
|
+
url('./05a4d7fb.woff') format('woff'),
|
|
6
|
+
url('./05a4d7fb.ttf') format('truetype'),
|
|
7
|
+
url('./05a4d7fb.otf') format('opentype');
|
|
8
|
+
font-weight: normal;
|
|
9
|
+
font-style: normal;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.pamicon {
|
|
13
|
+
display: inline-block;
|
|
14
|
+
font: normal normal normal 14px/1 'Pam';
|
|
15
|
+
font-size: inherit;
|
|
16
|
+
text-rendering: auto;
|
|
17
|
+
-webkit-font-smoothing: antialiased;
|
|
18
|
+
-moz-osx-font-smoothing: grayscale;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.pamicon-lg {
|
|
22
|
+
font-size: 1.33333333em;
|
|
23
|
+
line-height: 0.75em;
|
|
24
|
+
vertical-align: -15%;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.pamicon-2x {
|
|
28
|
+
font-size: 2em;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.pamicon-3x {
|
|
32
|
+
font-size: 3em;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.pamicon-4x {
|
|
36
|
+
font-size: 4em;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.pamicon-5x {
|
|
40
|
+
font-size: 5em;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.pamicon-checkbox-checked:before {
|
|
44
|
+
content: '\f000';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.pamicon-checkbox-unchecked:before {
|
|
48
|
+
content: '\f001';
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.pamicon-triangle-down:before {
|
|
52
|
+
content: '\f002';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.pamicon-checkbox-intermediate:before {
|
|
56
|
+
content: '\f003';
|
|
57
|
+
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = Collapse;
|
|
7
|
-
|
|
8
|
-
var _classnames = require('classnames');
|
|
9
|
-
|
|
10
|
-
var _classnames2 = _interopRequireDefault(_classnames);
|
|
11
|
-
|
|
12
|
-
var _propTypes = require('prop-types');
|
|
13
|
-
|
|
14
|
-
var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
15
|
-
|
|
16
|
-
var _react = require('react');
|
|
17
|
-
|
|
18
|
-
var _react2 = _interopRequireDefault(_react);
|
|
19
|
-
|
|
20
|
-
var _constants = require('../constants');
|
|
21
|
-
|
|
22
|
-
var _icons = require('./styles/icons/icons.css');
|
|
23
|
-
|
|
24
|
-
var _icons2 = _interopRequireDefault(_icons);
|
|
25
|
-
|
|
26
|
-
var _SelectOption = require('./styles/SelectOption.scss');
|
|
27
|
-
|
|
28
|
-
var _SelectOption2 = _interopRequireDefault(_SelectOption);
|
|
29
|
-
|
|
30
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
-
|
|
32
|
-
function Collapse(_ref) {
|
|
33
|
-
var onClick = _ref.onClick,
|
|
34
|
-
collapsibleState = _ref.collapsibleState;
|
|
35
|
-
|
|
36
|
-
return _react2.default.createElement(
|
|
37
|
-
'span',
|
|
38
|
-
{
|
|
39
|
-
onClick: onClick,
|
|
40
|
-
className: _SelectOption2.default['collapse'],
|
|
41
|
-
role: 'button'
|
|
42
|
-
},
|
|
43
|
-
_react2.default.createElement('i', { className: (0, _classnames2.default)(_icons2.default.pamicon, collapsibleState == _constants.OPTION_COLLAPSED ? _icons2.default['pamicon-triangle-up'] : _icons2.default['pamicon-triangle-down'], _SelectOption2.default['collapse-icon']) })
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
Collapse.propTypes = {
|
|
48
|
-
onClick: _propTypes2.default.func,
|
|
49
|
-
collapsibleState: _propTypes2.default.string
|
|
50
|
-
};
|
package/lib/constants.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import cn from 'classnames';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
|
|
5
|
-
import { OPTION_COLLAPSED } from '../constants';
|
|
6
|
-
import icons from './styles/icons/icons.css';
|
|
7
|
-
import styles from './styles/SelectOption.scss';
|
|
8
|
-
|
|
9
|
-
export default function Collapse ({onClick, collapsibleState}) {
|
|
10
|
-
return (
|
|
11
|
-
<span
|
|
12
|
-
onClick={onClick}
|
|
13
|
-
className={styles['collapse']}
|
|
14
|
-
role="button"
|
|
15
|
-
>
|
|
16
|
-
<i className={
|
|
17
|
-
cn(
|
|
18
|
-
icons.pamicon,
|
|
19
|
-
collapsibleState == OPTION_COLLAPSED ? icons['pamicon-triangle-up'] : icons['pamicon-triangle-down'],
|
|
20
|
-
styles['collapse-icon']
|
|
21
|
-
)
|
|
22
|
-
} />
|
|
23
|
-
</span>
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
Collapse.propTypes = {
|
|
28
|
-
onClick: PropTypes.func,
|
|
29
|
-
collapsibleState: PropTypes.string
|
|
30
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
|
|
4
|
-
import { whereClassName } from 'test/utils/enzyme-utils';
|
|
5
|
-
|
|
6
|
-
import Collapse from '../Collapse';
|
|
7
|
-
import icons from '../styles/icons/icons.css';
|
|
8
|
-
|
|
9
|
-
import { OPTION_NOT_COLLAPSED, OPTION_COLLAPSED } from '../../constants';
|
|
10
|
-
|
|
11
|
-
it('passes onClick handler', function(){
|
|
12
|
-
const onClick = jest.fn();
|
|
13
|
-
const wrapper = shallow(<Collapse collapsibleState={OPTION_NOT_COLLAPSED} onClick={onClick} />);
|
|
14
|
-
wrapper.find('[role="button"]').simulate('click');
|
|
15
|
-
expect(onClick).toHaveBeenCalled();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('renders correct class based on collapsibleState', function(){
|
|
19
|
-
const onClick = jest.fn();
|
|
20
|
-
const wrapper = shallow(<Collapse collapsibleState={OPTION_NOT_COLLAPSED} onClick={onClick} />);
|
|
21
|
-
expect(wrapper.findWhere(whereClassName(icons['pamicon-triangle-up'])).length).toEqual(0);
|
|
22
|
-
expect(wrapper.findWhere(whereClassName(icons['pamicon-triangle-down'])).length).toEqual(1);
|
|
23
|
-
wrapper.setProps({collapsibleState: OPTION_COLLAPSED});
|
|
24
|
-
expect(wrapper.findWhere(whereClassName(icons['pamicon-triangle-up'])).length).toEqual(1);
|
|
25
|
-
expect(wrapper.findWhere(whereClassName(icons['pamicon-triangle-down'])).length).toEqual(0);
|
|
26
|
-
});
|
package/src/constants.js
DELETED