@salesforce/design-system-react 0.10.50-alpha.1 → 0.10.50

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.
Files changed (69) hide show
  1. package/components/accordion/__tests__/accordion.browser-test.jsx +302 -0
  2. package/components/alert/__tests__/alert.browser-test.jsx +100 -0
  3. package/components/app-launcher/__tests__/app-launcher.browser-test.jsx +228 -0
  4. package/components/app-launcher/__tests__/expandable-section.browser-test.jsx +144 -0
  5. package/components/app-launcher/__tests__/link.browser-test.jsx +107 -0
  6. package/components/app-launcher/__tests__/tile.browser-test.jsx +267 -0
  7. package/components/avatar/__tests__/avatar.browser-test.jsx +207 -0
  8. package/components/builder-header/__tests__/builder-header.browser-test.jsx +53 -0
  9. package/components/button/__tests__/button.browser-test.jsx +226 -0
  10. package/components/button-group/__tests__/button-group.browser-test.jsx +144 -0
  11. package/components/button-stateful/__tests__/button-stateful.browser-test.jsx +125 -0
  12. package/components/card/__tests__/card.browser-test.jsx +255 -0
  13. package/components/carousel/__tests__/carousel.browser-test.jsx +527 -0
  14. package/components/color-picker/__tests__/color-picker.browser-test.jsx +767 -0
  15. package/components/combobox/__tests__/combobox.browser-test.jsx +654 -0
  16. package/components/data-table/__tests__/data-table.browser-test.jsx +1051 -0
  17. package/components/date-picker/__tests__/__snapshots__/datepicker.dom-snapshot-test.jsx.snap +4429 -0
  18. package/components/date-picker/__tests__/date-picker.browser-test.jsx +497 -0
  19. package/components/date-picker/__tests__/datepicker.dom-snapshot-test.jsx +109 -0
  20. package/components/docked-composer/__tests__/docked-composer.browser-test.jsx +83 -0
  21. package/components/expandable-section/__tests__/expandable-section.browser-test.jsx +133 -0
  22. package/components/expression/__tests__/expression.browser-test.jsx +255 -0
  23. package/components/filter/__tests__/filter.browser-test.jsx +147 -0
  24. package/components/forms/input/__tests__/inline.browser-test.jsx +164 -0
  25. package/components/global-header/__tests__/global-header.browser-test.jsx +177 -0
  26. package/components/global-navigation-bar/__tests__/global-navigation-bar.browser-test.jsx +464 -0
  27. package/components/icon/__tests__/icon.browser-test.jsx +214 -0
  28. package/components/illustration/__tests__/illustration.browser-test.jsx +177 -0
  29. package/components/input/__tests__/input.browser-test.jsx +612 -0
  30. package/components/location-map/__tests__/location-map.browser-test.jsx +158 -0
  31. package/components/lookup/__tests__/lookup.browser-test.jsx +353 -0
  32. package/components/media-object/__tests__/media-object.browser-test.jsx +87 -0
  33. package/components/menu-dropdown/__tests__/dropdown.browser-test.jsx +588 -0
  34. package/components/menu-picklist/__tests__/menupicklist.snapshot-old-test.jsx +41 -0
  35. package/components/menu-picklist/__tests__/picklist-base.browser-test.jsx +275 -0
  36. package/components/modal/__tests__/modal.browser-test.jsx +333 -0
  37. package/components/notification/__tests__/notification.browser-test.jsx +113 -0
  38. package/components/page-header/__tests__/page-header.browser-test.jsx +161 -0
  39. package/components/panel/__tests__/__snapshots__/filtering.dom-snapshot-test.jsx.snap +298 -0
  40. package/components/panel/__tests__/filtering.dom-snapshot-test.jsx +9 -0
  41. package/components/pill/__tests__/pill.browser-test.jsx +308 -0
  42. package/components/pill-container/__tests__/pill-container.browser-test.jsx +186 -0
  43. package/components/popover/__tests__/popover.browser-test.jsx +327 -0
  44. package/components/progress-indicator/__tests__/progress-indicator.browser-test.jsx +335 -0
  45. package/components/radio-button-group/__tests__/radio-button-group.browser-test.jsx +122 -0
  46. package/components/radio-group/__tests__/radio-group.browser-test.jsx +119 -0
  47. package/components/setup-assistant/__tests__/setup-assistant.browser-test.jsx +77 -0
  48. package/components/slider/__tests__/slider.browser-test.jsx +389 -0
  49. package/components/spinner/__tests__/spinner.browser-test.jsx +57 -0
  50. package/components/split-view/__tests__/split-view.listbox.browser-test.jsx +225 -0
  51. package/components/split-view/__tests__/split-view.listbox.header.browser-test.jsx +158 -0
  52. package/components/split-view/__tests__/split-view.listbox.unread.browser-test.jsx +114 -0
  53. package/components/tabs/__tests__/tabs.browser-test.jsx +458 -0
  54. package/components/textarea/__tests__/textarea.browser-test.jsx +175 -0
  55. package/components/time-picker/__tests__/time-picker.browser-test.jsx +46 -0
  56. package/components/toast/__tests__/toast.browser-test.jsx +118 -0
  57. package/components/tooltip/__tests__/tooltip.browser-test.jsx +214 -0
  58. package/components/tree/__tests__/tree.browser-test.jsx +303 -0
  59. package/components/vertical-navigation/__tests__/navigation.browser-test.jsx +117 -0
  60. package/components/visual-picker/__tests__/visual-picker.browser-test.jsx +288 -0
  61. package/components/welcome-mat/__tests__/welcome-mat.browser-test.jsx +358 -0
  62. package/design-system-react-components.js +1 -1
  63. package/design-system-react-components.min.js.LICENSE.txt +1 -1
  64. package/design-system-react.js +1 -1
  65. package/design-system-react.min.js.LICENSE.txt +1 -1
  66. package/lib/design-system-react-components.min.js.LICENSE.txt +1 -1
  67. package/lib/design-system-react.min.js.LICENSE.txt +1 -1
  68. package/lib/package.json +1 -1
  69. package/package.json +1 -1
@@ -0,0 +1,133 @@
1
+ import React from 'react';
2
+ import { mount } from 'enzyme';
3
+ import chai from 'chai';
4
+ import assign from 'lodash.assign';
5
+
6
+ import IconSettings from '../../icon-settings';
7
+ import ExpandableSection from '../../expandable-section';
8
+
9
+ const { expect } = chai;
10
+ const should = chai.should();
11
+
12
+ describe('SLDSExpandableSection', () => {
13
+ const handles = {
14
+ section: null,
15
+ };
16
+
17
+ const defaultSectionProps = {
18
+ title: 'All Items',
19
+ };
20
+
21
+ const defaultChildren = 'Expandable section children';
22
+
23
+ const createSection = (props, children) =>
24
+ React.createElement(
25
+ ExpandableSection,
26
+ assign({}, defaultSectionProps, props),
27
+ children
28
+ );
29
+
30
+ function mountSection(props, children = defaultChildren) {
31
+ handles.section = mount(
32
+ <IconSettings iconPath="/assets/icons">
33
+ {createSection(props, children)}
34
+ </IconSettings>
35
+ );
36
+ }
37
+
38
+ describe('App Launcher Section', () => {
39
+ let onToggleOpen;
40
+
41
+ beforeEach(() => {
42
+ onToggleOpen = sinon.spy();
43
+
44
+ mountSection(
45
+ {
46
+ assistiveText: { toggleSection: 'Collapse Section' },
47
+ className: 'this-is-a-custom-class',
48
+ id: 'test-id',
49
+ onToggleOpen,
50
+ title: 'Section Title',
51
+ },
52
+ 'Children test!'
53
+ );
54
+ });
55
+
56
+ it('section exists', () => {
57
+ should.exist(handles.section);
58
+ });
59
+
60
+ it('section has custom class', () => {
61
+ expect(
62
+ handles.section.find('div').at(0).hasClass('this-is-a-custom-class')
63
+ ).to.eql(true);
64
+ });
65
+
66
+ it('section has "slds-is-open" class when open', () => {
67
+ expect(handles.section.find('.slds-section')).to.have.className(
68
+ 'slds-is-open'
69
+ );
70
+ });
71
+
72
+ it('section renders children properly', () => {
73
+ expect(handles.section.find('.slds-section__content').text()).to.eql(
74
+ 'Children test!'
75
+ );
76
+ });
77
+
78
+ it('section uses passed in id properly', () => {
79
+ expect(
80
+ handles.section.find('#test-id-expanded-section-content').length
81
+ ).to.eql(1);
82
+ });
83
+
84
+ it('section has a title', () => {
85
+ should.exist(handles.section.find('.slds-section__title'));
86
+ });
87
+
88
+ it('renders custom section title', () => {
89
+ expect(handles.section.find('h3 .slds-truncate').text()).to.equal(
90
+ 'Section Title'
91
+ );
92
+ });
93
+
94
+ it('renders custom toggle assistve text', () => {
95
+ expect(
96
+ handles.section.find('h3 span.slds-assistive-text').text()
97
+ ).to.equal('Collapse Section');
98
+ });
99
+
100
+ it('toggling section fires callback', () => {
101
+ handles.section.find('h3 button.slds-button').simulate('click');
102
+ expect(onToggleOpen.calledOnce).to.be.true; // eslint-disable-line no-unused-expressions
103
+ });
104
+ });
105
+
106
+ describe('Expandable Section (non-collapsible)', () => {
107
+ beforeEach(() => {
108
+ mountSection({ nonCollapsible: true });
109
+ });
110
+
111
+ it('does not render toggle if non-collapsible is true', () => {
112
+ should.not.exist(
113
+ handles.section.find(
114
+ '.slds-button .slds-button_icon .slds-m-right_small'
115
+ )
116
+ );
117
+ });
118
+ });
119
+
120
+ describe('Expandable Section (closed)', () => {
121
+ beforeEach(() => {
122
+ mountSection({
123
+ isOpen: false,
124
+ });
125
+ });
126
+
127
+ it('section does not have "slds-is-open" class when closed', () => {
128
+ expect(handles.section.find('.slds-section.slds-is-open').length).to.eql(
129
+ 0
130
+ );
131
+ });
132
+ });
133
+ });
@@ -0,0 +1,255 @@
1
+ /* eslint-disable max-lines */
2
+ import React from 'react';
3
+ import chai, { expect } from 'chai';
4
+ import chaiEnzyme from 'chai-enzyme';
5
+ import { mount } from 'enzyme';
6
+
7
+ import ExpressionCondition from '../../../components/expression/condition';
8
+ import IconSettings from '../../icon-settings';
9
+ import { keyObjects } from '../../../utilities/key-code';
10
+ import ExpressionGroup from '../group';
11
+ import ExpressionFormula from '../formula';
12
+
13
+ /* Set Chai to use chaiEnzyme for enzyme compatible assertions:
14
+ * https://github.com/producthunt/chai-enzyme
15
+ */
16
+ chai.use(chaiEnzyme());
17
+
18
+ const ResourcesList = [
19
+ { id: '111', label: 'Resource 1' },
20
+ { id: '112', label: 'Resource 2' },
21
+ { id: '113', label: 'Resource 3' },
22
+ { id: '114', label: 'Resource 4' },
23
+ ];
24
+
25
+ const OperatorsList = [
26
+ { id: '1', label: 'Equals' },
27
+ { id: '2', label: 'Does Not Equals' },
28
+ { id: '3', label: 'Greater Than' },
29
+ { id: '4', label: 'Less Than' },
30
+ ];
31
+
32
+ const DemoCondition = (props) => (
33
+ <ExpressionCondition
34
+ resourcesList={ResourcesList}
35
+ operatorsList={OperatorsList}
36
+ {...props}
37
+ id="test"
38
+ />
39
+ );
40
+
41
+ const DemoGroup = (props) => <ExpressionGroup {...props} id="test" />;
42
+
43
+ const DemoFormula = (props) => <ExpressionFormula {...props} id="test" />;
44
+
45
+ describe('SLDSExpression', function describeFunction() {
46
+ const handles = {
47
+ condition: null,
48
+ group: null,
49
+ formula: null,
50
+ };
51
+
52
+ function mountCondition(props) {
53
+ handles.condition = mount(
54
+ <IconSettings iconPath="/assets/icons">
55
+ {DemoCondition(props)}
56
+ </IconSettings>
57
+ );
58
+ }
59
+
60
+ function mountGroup(props) {
61
+ handles.group = mount(
62
+ <IconSettings iconPath="/assets/icons">{DemoGroup(props)}</IconSettings>
63
+ );
64
+ }
65
+
66
+ function mountFormula(props) {
67
+ handles.formula = mount(
68
+ <IconSettings iconPath="/assets/icons">{DemoFormula(props)}</IconSettings>
69
+ );
70
+ }
71
+
72
+ describe('Expression Condition', () => {
73
+ let resourceChange;
74
+ let operatorChange;
75
+ let valueChange;
76
+ let deleteClicked;
77
+
78
+ const getNodes = (wrapper) => ({
79
+ resourceSelector: wrapper.find('input[id="test-resource-selector"]'),
80
+ operatorSelector: wrapper.find('input[id="test-operator-selector"]'),
81
+ valueInput: wrapper.find('input[id="test-input"]'),
82
+ deleteButton: wrapper.find('button[id="test-delete-button"]'),
83
+ });
84
+
85
+ beforeEach(() => {
86
+ mountCondition({
87
+ events: {
88
+ onChangeResource: (event, data) => {
89
+ resourceChange = { event, data };
90
+ },
91
+ onChangeOperator: (event, data) => {
92
+ operatorChange = { event, data };
93
+ },
94
+ onChangeValue: (event, data) => {
95
+ valueChange = { event, data };
96
+ },
97
+ onDelete: (event, data) => {
98
+ deleteClicked = { event, data };
99
+ },
100
+ },
101
+ });
102
+ });
103
+
104
+ it('Resource selector works', function () {
105
+ const node = getNodes(handles.condition);
106
+ expect(node.resourceSelector).attr('value', '');
107
+ node.resourceSelector.simulate('focus');
108
+ node.resourceSelector.simulate('keyDown', keyObjects.DOWN);
109
+ node.resourceSelector.simulate('keyDown', keyObjects.DOWN);
110
+ node.resourceSelector.simulate('keyDown', keyObjects.ENTER);
111
+ expect(resourceChange !== undefined).to.eql(true);
112
+ expect(typeof resourceChange.event).to.eql('object');
113
+ expect(typeof resourceChange.data).to.eql('object');
114
+ expect(resourceChange.data.selection[0]).to.equal(ResourcesList[0]);
115
+ });
116
+
117
+ it('Operator selector works', function () {
118
+ const node = getNodes(handles.condition);
119
+ expect(node.operatorSelector).attr('value', '');
120
+ node.operatorSelector.simulate('focus');
121
+ node.operatorSelector.simulate('keyDown', keyObjects.DOWN);
122
+ node.operatorSelector.simulate('keyDown', keyObjects.DOWN);
123
+ node.operatorSelector.simulate('keyDown', keyObjects.ENTER);
124
+ expect(operatorChange !== undefined).to.eql(true);
125
+ expect(typeof operatorChange.event).to.eql('object');
126
+ expect(typeof operatorChange.data).to.eql('object');
127
+ expect(operatorChange.data.selection[0]).to.equal(OperatorsList[0]);
128
+ });
129
+
130
+ it('Value input works', function () {
131
+ const node = getNodes(handles.condition);
132
+ expect(node.valueInput).attr('value', '');
133
+ node.valueInput.simulate('focus');
134
+ node.valueInput.simulate('change', { target: { value: 'something' } });
135
+ expect(valueChange.data.value).to.equal('something');
136
+ });
137
+
138
+ it('Delete button works', function () {
139
+ const node = getNodes(handles.condition);
140
+ expect(deleteClicked === undefined).to.equal(true);
141
+ node.deleteButton.simulate('click');
142
+ expect(deleteClicked === undefined).to.equal(false);
143
+ });
144
+ });
145
+
146
+ describe('Expression Group', () => {
147
+ let triggerChange;
148
+ let addGroup;
149
+ let addCondition;
150
+ let customLogic;
151
+
152
+ const getNodes = (wrapper) => ({
153
+ trigger: wrapper.find('input[id="test-take-action-trigger"]'),
154
+ addGroup: wrapper.find('button[id="test-add-group-button"]'),
155
+ addCondition: wrapper.find('button[id="test-add-condition-button"]'),
156
+ customLogicInput: wrapper.find('input[id="test-custom-logic-input"]'),
157
+ });
158
+
159
+ beforeEach(() => {
160
+ mountGroup({
161
+ isRoot: true,
162
+ triggerType: 'custom',
163
+ events: {
164
+ onChangeTrigger: (event, data) => {
165
+ triggerChange = { event, data };
166
+ },
167
+ onAddGroup: (event, data) => {
168
+ addGroup = { event, data };
169
+ },
170
+ onAddCondition: (event, data) => {
171
+ addCondition = { event, data };
172
+ },
173
+ onChangeCustomLogicValue: (event, data) => {
174
+ customLogic = { event, data };
175
+ },
176
+ },
177
+ });
178
+ });
179
+
180
+ it('Trigger change button works', function () {
181
+ const node = getNodes(handles.group);
182
+ expect(node.trigger).attr('value', 'Custom Logic Is Met');
183
+ node.trigger.simulate('focus');
184
+ // Pressing down once would not change the input value
185
+ node.trigger.simulate('keyDown', keyObjects.DOWN);
186
+ node.trigger.simulate('keyDown', keyObjects.UP);
187
+ node.trigger.simulate('keyDown', keyObjects.UP);
188
+ node.trigger.simulate('keyDown', keyObjects.ENTER);
189
+ expect(triggerChange !== undefined).to.eql(true);
190
+ expect(typeof triggerChange.event).to.eql('object');
191
+ expect(typeof triggerChange.data).to.eql('object');
192
+ expect(triggerChange.data.triggerType).to.eql('all');
193
+ });
194
+
195
+ it('Custom logic input works', function () {
196
+ const node = getNodes(handles.group);
197
+ expect(node.customLogicInput).attr('value', '');
198
+ node.customLogicInput.simulate('focus');
199
+ node.customLogicInput.simulate('change', { target: { value: '1 + 2' } });
200
+ expect(customLogic.data.value).to.equal('1 + 2');
201
+ });
202
+
203
+ it('Add group button works', function () {
204
+ const node = getNodes(handles.group);
205
+ expect(addGroup === undefined).to.equal(true);
206
+ node.addGroup.simulate('click');
207
+ expect(addGroup === undefined).to.equal(false);
208
+ });
209
+
210
+ it('Add condition button works', function () {
211
+ const node = getNodes(handles.group);
212
+ expect(addCondition === undefined).to.equal(true);
213
+ node.addCondition.simulate('click');
214
+ expect(addCondition === undefined).to.equal(false);
215
+ });
216
+ });
217
+
218
+ describe('Expression Formula', () => {
219
+ let helpClicked;
220
+ let checkSyntaxClicked;
221
+
222
+ const getNodes = (wrapper) => ({
223
+ helpButton: wrapper.find('button[id="test-help-button"]'),
224
+ checkSyntax: wrapper.find('button[id="test-check-syntax-button"]'),
225
+ contentEditor: wrapper.find('div[id="test-content-editor"]'),
226
+ });
227
+
228
+ beforeEach(() => {
229
+ mountFormula({
230
+ events: {
231
+ onClickHelp: (event, data) => {
232
+ helpClicked = { event, data };
233
+ },
234
+ onClickCheckSyntax: (event, data) => {
235
+ checkSyntaxClicked = { event, data };
236
+ },
237
+ },
238
+ });
239
+ });
240
+
241
+ it('Help button works', function () {
242
+ const node = getNodes(handles.formula);
243
+ expect(helpClicked === undefined).to.equal(true);
244
+ node.helpButton.simulate('click');
245
+ expect(helpClicked === undefined).to.equal(false);
246
+ });
247
+
248
+ it('Check syntax button works', function () {
249
+ const node = getNodes(handles.formula);
250
+ expect(checkSyntaxClicked === undefined).to.equal(true);
251
+ node.checkSyntax.simulate('click');
252
+ expect(checkSyntaxClicked === undefined).to.equal(false);
253
+ });
254
+ });
255
+ });
@@ -0,0 +1,147 @@
1
+ import React from 'react';
2
+
3
+ import PropTypes from 'prop-types';
4
+ import chai, { expect } from 'chai';
5
+ import chaiEnzyme from 'chai-enzyme';
6
+ import { mount } from 'enzyme';
7
+
8
+ /* Enzyme Helpers that can mount and unmount React component instances to
9
+ * the DOM and set `this.wrapper` and `this.dom` within Mocha's `this`
10
+ * context [full source here](tests/enzyme-helpers.js). `this` can
11
+ * only be referenced if inside `function () {}`.
12
+ */
13
+ import {
14
+ createMountNode,
15
+ destroyMountNode,
16
+ } from '../../../tests/enzyme-helpers';
17
+
18
+ // Import your internal dependencies (for example):
19
+ import Popover from '../../popover';
20
+ import Button from '../../button';
21
+ import Filter from '../../filter';
22
+ import IconSettings from '../../icon-settings';
23
+
24
+ /* Set Chai to use chaiEnzyme for enzyme compatible assertions:
25
+ * https://github.com/producthunt/chai-enzyme
26
+ */
27
+ chai.use(chaiEnzyme());
28
+
29
+ const defaultProps = {
30
+ id: 'sample-popover',
31
+ body: <span id="sample-body">This is the body</span>,
32
+ heading: <span id="sample-heading">This is the heading</span>,
33
+ };
34
+
35
+ /* A re-usable demo component fixture outside of `describe` sections
36
+ * can accept props within each test and be unmounted after each tests.
37
+ * This wrapping component will be similar to your wrapping component
38
+ * you will create in the React Storybook for manual testing.
39
+ */
40
+ class DemoComponent extends React.Component {
41
+ static displayName = 'PopoverDemoComponent';
42
+
43
+ static propTypes = {
44
+ isOpen: PropTypes.bool,
45
+ };
46
+
47
+ static defaultProps = defaultProps;
48
+
49
+ state = {};
50
+
51
+ render() {
52
+ return (
53
+ <Popover {...this.props}>
54
+ <Button label="Trigger Popover" />
55
+ </Popover>
56
+ );
57
+ }
58
+ }
59
+
60
+ /* All tests for component being tested should be wrapped in a root `describe`,
61
+ * which should be named after the component being tested.
62
+ * When read aloud, the cumulative `describe` and `it` names should form a coherent
63
+ * sentence, eg "Date Picker default structure and css is present with expected
64
+ * attributes set". If you are having trouble constructing a cumulative short
65
+ * sentence, this may be an indicator that your test is poorly structured.
66
+ * String provided as first parameter names the `describe` section. Limit to nouns
67
+ * as much as possible/appropriate.`
68
+ */
69
+ describe('SLDSFilter', function describeFunction() {
70
+ let mountNode;
71
+ let wrapper;
72
+
73
+ // BASIC STRUCTURE
74
+
75
+ describe('Add custom props to Filter Popover', function () {
76
+ beforeEach(() => {
77
+ mountNode = createMountNode({ context: this });
78
+ });
79
+
80
+ afterEach(() => {
81
+ destroyMountNode({ wrapper, mountNode });
82
+ });
83
+
84
+ it('Filter could take popover as a prop and use the props of popover to render, verifies the custom popover className', () => {
85
+ const demoPopover = (
86
+ <DemoComponent
87
+ className="custom-filter-popover"
88
+ isOpen
89
+ position="absolute"
90
+ />
91
+ );
92
+ wrapper = mount(
93
+ <IconSettings iconPath="/assets/icons">
94
+ <Filter
95
+ property="Show Me"
96
+ predicate="All Opportunities"
97
+ popover={demoPopover}
98
+ />
99
+ </IconSettings>,
100
+ { attachTo: mountNode }
101
+ );
102
+
103
+ expect(wrapper.find('.custom-filter-popover')).to.exist;
104
+ });
105
+ });
106
+
107
+ describe('On click handler when clicking on filter', function () {
108
+ beforeEach(() => {
109
+ mountNode = createMountNode({ context: this });
110
+ });
111
+
112
+ afterEach(() => {
113
+ destroyMountNode({ wrapper, mountNode });
114
+ });
115
+
116
+ it('Filter could take onClick prop and trigger this callback during filter click', (done) => {
117
+ const demoPopover = <DemoComponent className="custom-filter-popover" />;
118
+
119
+ let onFilterClicked = false;
120
+
121
+ const onClick = () => {
122
+ onFilterClicked = true;
123
+ };
124
+
125
+ wrapper = mount(
126
+ <IconSettings iconPath="/assets/icons">
127
+ <Filter
128
+ property="Show Me"
129
+ predicate="All Opportunities"
130
+ popover={demoPopover}
131
+ onClick={onClick}
132
+ />
133
+ </IconSettings>,
134
+ { attachTo: mountNode }
135
+ );
136
+
137
+ setTimeout(() => {
138
+ const filterButton = wrapper.find(
139
+ '.slds-filters__item .slds-button_reset'
140
+ );
141
+ filterButton.simulate('click', {});
142
+ expect(onFilterClicked).to.be.true;
143
+ done();
144
+ }, 0);
145
+ });
146
+ });
147
+ });
@@ -0,0 +1,164 @@
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom';
3
+
4
+ import chai from 'chai';
5
+
6
+ import InlineEdit from '../../../forms/input/inline';
7
+ import IconSettings from '../../../icon-settings';
8
+
9
+ const should = chai.should();
10
+
11
+ describe('Inline Edit: ', function describeFunction() {
12
+ const sampleValue = 'Sample value';
13
+
14
+ const renderInlineEdit = (instance) =>
15
+ function () {
16
+ this.dom = document.createElement('div');
17
+ document.body.appendChild(this.dom);
18
+ /* deepscan-disable REACT_ASYNC_RENDER_RETURN_VALUE */
19
+ // eslint-disable-next-line react/no-render-return-value
20
+ this.component = ReactDOM.render(
21
+ <IconSettings iconPath="/assets/icons">{instance}</IconSettings>,
22
+ this.dom
23
+ );
24
+ /* deepscan-enable REACT_ASYNC_RENDER_RETURN_VALUE */
25
+ };
26
+
27
+ function removeInlineEdit() {
28
+ ReactDOM.unmountComponentAtNode(this.dom);
29
+ document.body.removeChild(this.dom);
30
+ }
31
+
32
+ const getWrapper = (dom) => dom.querySelector('.slds-form-element');
33
+
34
+ const getInput = (dom) => dom.querySelector('.slds-input');
35
+
36
+ const getStatic = (dom) => dom.querySelector('.slds-form-element__static');
37
+
38
+ const getTrigger = (dom) => getStatic(dom).querySelector('.slds-button');
39
+
40
+ describe('Structure', function describeFunction2() {
41
+ beforeEach(
42
+ renderInlineEdit(
43
+ <InlineEdit
44
+ id="inline-edit-standard"
45
+ value={sampleValue}
46
+ silenceDeprecationWarning
47
+ />
48
+ )
49
+ );
50
+
51
+ afterEach(removeInlineEdit);
52
+
53
+ it('renders static by default', function () {
54
+ const wrapper = getWrapper(this.dom);
55
+ const input = getInput(this.dom);
56
+ const staticElement = getStatic(this.dom);
57
+ const trigger = getTrigger(this.dom);
58
+
59
+ should.exist(wrapper);
60
+ should.not.exist(input);
61
+ should.exist(staticElement);
62
+ should.exist(trigger);
63
+ });
64
+
65
+ it('renders the correct value', function () {
66
+ const staticElement = getStatic(this.dom);
67
+ const value = staticElement.textContent;
68
+
69
+ value.should.equal('Sample valueEdit text');
70
+ });
71
+ });
72
+
73
+ // describe('Editable', function () {
74
+ // beforeEach(renderInlineEdit(
75
+ // <InlineEdit id="inline-edit-standard" value={sampleValue} />
76
+ // ));
77
+
78
+ // afterEach(removeInlineEdit);
79
+
80
+ // it('becomes editable on click', function () {
81
+ // const trigger = getTrigger(this.dom);
82
+
83
+ // should.exist(trigger);
84
+
85
+ // Simulate.click(trigger, {});
86
+
87
+ // setTimeout(() => {
88
+ // const input = getInput(this.dom);
89
+ // const staticElement = getStatic(this.dom);
90
+
91
+ // should.exist(input);
92
+ // should.not.exist(staticElement);
93
+ // }, 100);
94
+ // });
95
+ // });
96
+
97
+ // describe('Custom Handler Function', function () {
98
+ // const enterEditModeHanlder = sinon.spy();
99
+ // const leaveEditModeHanlder = sinon.spy();
100
+ // const keyDownHandler = sinon.spy();
101
+ // const keyUpHandler = sinon.spy();
102
+
103
+ // beforeEach(renderInlineEdit(<InlineEdit id="inline-edit-standard" value={sampleValue} onEnterEditMode={enterEditModeHanlder} onLeaveEditMode={leaveEditModeHanlder} onKeyDown={keyDownHandler} onKeyUp={keyUpHandler} />
104
+ // ));
105
+
106
+ // afterEach(removeInlineEdit);
107
+
108
+ // it('enterEditMode and leaveEditMode handler get called', function () {
109
+ // const trigger = getTrigger(this.dom);
110
+
111
+ // should.exist(trigger);
112
+
113
+ // Simulate.click(trigger, {});
114
+
115
+ // setTimeout(() => {
116
+ // const input = getInput(this.dom);
117
+
118
+ // should.exist(input);
119
+
120
+ // expect(enterEditModeHanlder.callCount).to.equal(1);
121
+
122
+ // Simulate.keyDown(input, { key: 'Escape', keyCode: 27, which: 27 });
123
+
124
+ // setTimeout(() => {
125
+ // const input2 = getInput(this.dom);
126
+
127
+ // should.not.exist(input2);
128
+
129
+ // expect(leaveEditModeHanlder.callCount).to.equal(1);
130
+ // expect(leaveEditModeHanlder).to.have.been.called.with(undefined, { cancel: true });
131
+ // }, 100);
132
+ // }, 100);
133
+ // });
134
+
135
+ // it('keyup and keydown handler get called', function () {
136
+ // const trigger = getTrigger(this.dom);
137
+
138
+ // should.exist(trigger);
139
+
140
+ // Simulate.click(trigger, {});
141
+
142
+ // setTimeout(() => {
143
+ // const input = getInput(this.dom);
144
+
145
+ // should.exist(input);
146
+
147
+ // input.value = '1';
148
+
149
+ // Simulate.change(input);
150
+
151
+ // Simulate.keyDown(input, { key: 'Enter', keyCode: 13, which: 13 });
152
+
153
+ // setTimeout(() => {
154
+ // const input2 = getInput(this.dom);
155
+
156
+ // should.not.exist(input2);
157
+
158
+ // expect(keyUpHandler.callCount).to.equal(1);
159
+ // expect(keyDownHandler.callCount).to.equal(1);
160
+ // }, 100);
161
+ // }, 100);
162
+ // });
163
+ // });
164
+ });