@pie-lib/config-ui 11.9.25-next.0 → 11.9.25-next.1595
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/CHANGELOG.json +8 -1653
- package/CHANGELOG.md +131 -39
- package/NEXT.CHANGELOG.json +1 -0
- package/lib/alert-dialog.js +38 -7
- package/lib/alert-dialog.js.map +1 -1
- package/lib/checkbox.js +6 -1
- package/lib/checkbox.js.map +1 -1
- package/lib/choice-configuration/index.js +19 -8
- package/lib/choice-configuration/index.js.map +1 -1
- package/lib/feedback-config/feedback-selector.js +0 -0
- package/lib/inputs.js +8 -2
- package/lib/inputs.js.map +1 -1
- package/lib/layout/config-layout.js +27 -10
- package/lib/layout/config-layout.js.map +1 -1
- package/lib/number-text-field-custom.js +134 -43
- package/lib/number-text-field-custom.js.map +1 -1
- package/lib/number-text-field.js +17 -18
- package/lib/number-text-field.js.map +1 -1
- package/lib/radio-with-label.js +9 -1
- package/lib/radio-with-label.js.map +1 -1
- package/lib/settings/index.js +3 -1
- package/lib/settings/index.js.map +1 -1
- package/lib/settings/panel.js +7 -4
- package/lib/settings/panel.js.map +1 -1
- package/lib/settings/settings-radio-label.js +9 -1
- package/lib/settings/settings-radio-label.js.map +1 -1
- package/lib/settings/toggle.js +18 -0
- package/lib/settings/toggle.js.map +1 -1
- package/package.json +8 -5
- package/src/__tests__/__snapshots__/langs.test.jsx.snap +32 -0
- package/src/__tests__/__snapshots__/settings-panel.test.js.snap +115 -0
- package/src/__tests__/__snapshots__/two-choice.test.js.snap +171 -0
- package/src/__tests__/choice-utils.test.js +12 -0
- package/src/__tests__/langs.test.jsx +37 -0
- package/src/__tests__/number-text-field.test.jsx +148 -0
- package/src/__tests__/settings-panel.test.js +204 -0
- package/src/__tests__/two-choice.test.js +24 -0
- package/src/alert-dialog.jsx +27 -7
- package/src/checkbox.jsx +8 -1
- package/src/choice-configuration/__tests__/__snapshots__/feedback-menu.test.jsx.snap +51 -0
- package/src/choice-configuration/__tests__/__snapshots__/index.test.jsx.snap +519 -0
- package/src/choice-configuration/__tests__/feedback-menu.test.jsx +10 -0
- package/src/choice-configuration/__tests__/index.test.jsx +92 -0
- package/src/choice-configuration/index.jsx +14 -3
- package/src/feedback-config/__tests__/__snapshots__/feedback-config.test.jsx.snap +27 -0
- package/src/feedback-config/__tests__/__snapshots__/feedback-selector.test.jsx.snap +38 -0
- package/src/feedback-config/__tests__/feedback-config.test.jsx +71 -0
- package/src/feedback-config/__tests__/feedback-selector.test.jsx +60 -0
- package/src/feedback-config/feedback-selector.jsx +0 -0
- package/src/inputs.jsx +9 -2
- package/src/layout/__tests__/__snapshots__/config.layout.test.jsx.snap +59 -0
- package/src/layout/__tests__/config.layout.test.jsx +42 -0
- package/src/layout/__tests__/layout-content.test.jsx +3 -0
- package/src/layout/config-layout.jsx +16 -8
- package/src/number-text-field-custom.jsx +86 -28
- package/src/number-text-field.jsx +6 -5
- package/src/radio-with-label.jsx +6 -2
- package/src/settings/index.js +2 -1
- package/src/settings/panel.jsx +5 -2
- package/src/settings/settings-radio-label.jsx +6 -2
- package/src/settings/toggle.jsx +20 -2
- package/src/tags-input/__tests__/__snapshots__/index.test.jsx.snap +170 -0
- package/src/tags-input/__tests__/index.test.jsx +62 -0
- package/README.md +0 -12
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`langs snapshot renders 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<WithStyles(FormControl)>
|
|
6
|
+
<WithStyles(WithFormControlContext(InputLabel))
|
|
7
|
+
htmlFor="1"
|
|
8
|
+
/>
|
|
9
|
+
<WithStyles(WithFormControlContext(Select))
|
|
10
|
+
input={
|
|
11
|
+
<WithStyles(Input)
|
|
12
|
+
id="1"
|
|
13
|
+
/>
|
|
14
|
+
}
|
|
15
|
+
onChange={[Function]}
|
|
16
|
+
>
|
|
17
|
+
<WithStyles(MenuItem)
|
|
18
|
+
key="0"
|
|
19
|
+
value="en-US"
|
|
20
|
+
>
|
|
21
|
+
en-US
|
|
22
|
+
</WithStyles(MenuItem)>
|
|
23
|
+
<WithStyles(MenuItem)
|
|
24
|
+
key="1"
|
|
25
|
+
value="es-ES"
|
|
26
|
+
>
|
|
27
|
+
es-ES
|
|
28
|
+
</WithStyles(MenuItem)>
|
|
29
|
+
</WithStyles(WithFormControlContext(Select))>
|
|
30
|
+
</WithStyles(FormControl)>
|
|
31
|
+
</div>
|
|
32
|
+
`;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Settings Panel snapshot does not render radio buttons 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<WithStyles(Component)
|
|
6
|
+
configuration={
|
|
7
|
+
Object {
|
|
8
|
+
"editChoiceLabel": false,
|
|
9
|
+
"orientationLabel": "Orientation",
|
|
10
|
+
"settingsOrientation": true,
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
group={
|
|
14
|
+
Object {
|
|
15
|
+
"choiceAreaLayout": false,
|
|
16
|
+
"editChoiceLabel": Object {
|
|
17
|
+
"isConfigProperty": true,
|
|
18
|
+
"label": "Edit choice label",
|
|
19
|
+
"type": "toggle",
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
key="Group 1"
|
|
24
|
+
label="Group 1"
|
|
25
|
+
model={
|
|
26
|
+
Object {
|
|
27
|
+
"choiceAreaLayout": "vertical",
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
onChange={[Function]}
|
|
31
|
+
/>
|
|
32
|
+
</div>
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
exports[`Settings Panel snapshot renders 1`] = `
|
|
36
|
+
<div>
|
|
37
|
+
<WithStyles(Component)
|
|
38
|
+
configuration={
|
|
39
|
+
Object {
|
|
40
|
+
"editChoiceLabel": false,
|
|
41
|
+
"orientationLabel": "Orientation",
|
|
42
|
+
"settingsOrientation": true,
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
group={
|
|
46
|
+
Object {
|
|
47
|
+
"choiceAreaLayout": Object {
|
|
48
|
+
"choices": Array [
|
|
49
|
+
Object {
|
|
50
|
+
"label": "opt1",
|
|
51
|
+
"value": "opt1",
|
|
52
|
+
},
|
|
53
|
+
Object {
|
|
54
|
+
"label": "opt2",
|
|
55
|
+
"value": "opt2",
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
"equationEditor": Object {
|
|
59
|
+
"choices": Array [
|
|
60
|
+
"geometry",
|
|
61
|
+
"advanced-algebra",
|
|
62
|
+
"statistics",
|
|
63
|
+
"miscellaneous",
|
|
64
|
+
],
|
|
65
|
+
"isConfigProperty": false,
|
|
66
|
+
"label": "Dropdown",
|
|
67
|
+
"type": "dropdown",
|
|
68
|
+
},
|
|
69
|
+
"graph": Object {
|
|
70
|
+
"fields": Object {
|
|
71
|
+
"domain": Object {
|
|
72
|
+
"isConfigProperty": false,
|
|
73
|
+
"label": "Domain",
|
|
74
|
+
"suffix": "px",
|
|
75
|
+
"type": "numberField",
|
|
76
|
+
},
|
|
77
|
+
"range": Object {
|
|
78
|
+
"isConfigProperty": false,
|
|
79
|
+
"label": "Range",
|
|
80
|
+
"suffix": "px",
|
|
81
|
+
"type": "numberField",
|
|
82
|
+
},
|
|
83
|
+
"width": Object {
|
|
84
|
+
"isConfigProperty": false,
|
|
85
|
+
"label": "Width",
|
|
86
|
+
"max": 250,
|
|
87
|
+
"min": 50,
|
|
88
|
+
"suffix": "px",
|
|
89
|
+
"type": "numberField",
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
"label": "Graph Display Size",
|
|
93
|
+
"type": "numberFields",
|
|
94
|
+
},
|
|
95
|
+
"label": "Orientation",
|
|
96
|
+
"type": "radio",
|
|
97
|
+
},
|
|
98
|
+
"editChoiceLabel": Object {
|
|
99
|
+
"isConfigProperty": true,
|
|
100
|
+
"label": "Edit choice label",
|
|
101
|
+
"type": "toggle",
|
|
102
|
+
},
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
key="Group 1"
|
|
106
|
+
label="Group 1"
|
|
107
|
+
model={
|
|
108
|
+
Object {
|
|
109
|
+
"choiceAreaLayout": "vertical",
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
onChange={[Function]}
|
|
113
|
+
/>
|
|
114
|
+
</div>
|
|
115
|
+
`;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`NChoice renders n choice radio buttons vertical correctly 1`] = `
|
|
4
|
+
<div
|
|
5
|
+
className="MuiFormControl-root-5 RawInputContainer-formControl-3"
|
|
6
|
+
>
|
|
7
|
+
<label
|
|
8
|
+
className="MuiFormLabel-root-20 MuiInputLabel-root-9 MuiInputLabel-formControl-14 MuiInputLabel-animated-17 MuiInputLabel-shrink-16 RawInputContainer-label-4"
|
|
9
|
+
data-shrink={true}
|
|
10
|
+
>
|
|
11
|
+
n-choice-vertical
|
|
12
|
+
</label>
|
|
13
|
+
<div
|
|
14
|
+
className="RawNChoice-group-1 RawNChoice-vertical-2"
|
|
15
|
+
>
|
|
16
|
+
<label
|
|
17
|
+
className="MuiFormControlLabel-root-29"
|
|
18
|
+
>
|
|
19
|
+
<span
|
|
20
|
+
className="MuiButtonBase-root-50 MuiIconButton-root-44 MuiPrivateSwitchBase-root-40 MuiRadio-root-35 MuiRadio-colorSecondary-39 MuiPrivateSwitchBase-checked-41 MuiRadio-checked-36 Component-customColor-28"
|
|
21
|
+
onBlur={[Function]}
|
|
22
|
+
onContextMenu={[Function]}
|
|
23
|
+
onFocus={[Function]}
|
|
24
|
+
onKeyDown={[Function]}
|
|
25
|
+
onKeyUp={[Function]}
|
|
26
|
+
onMouseDown={[Function]}
|
|
27
|
+
onMouseLeave={[Function]}
|
|
28
|
+
onMouseUp={[Function]}
|
|
29
|
+
onTouchEnd={[Function]}
|
|
30
|
+
onTouchMove={[Function]}
|
|
31
|
+
onTouchStart={[Function]}
|
|
32
|
+
tabIndex={null}
|
|
33
|
+
>
|
|
34
|
+
<span
|
|
35
|
+
className="MuiIconButton-label-49"
|
|
36
|
+
>
|
|
37
|
+
<svg
|
|
38
|
+
aria-hidden="true"
|
|
39
|
+
className="MuiSvgIcon-root-53"
|
|
40
|
+
focusable="false"
|
|
41
|
+
role="presentation"
|
|
42
|
+
viewBox="0 0 24 24"
|
|
43
|
+
>
|
|
44
|
+
<path
|
|
45
|
+
d="M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5zm0-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
|
|
46
|
+
/>
|
|
47
|
+
</svg>
|
|
48
|
+
<input
|
|
49
|
+
checked={true}
|
|
50
|
+
className="MuiPrivateSwitchBase-input-43"
|
|
51
|
+
disabled={false}
|
|
52
|
+
onChange={[Function]}
|
|
53
|
+
type="radio"
|
|
54
|
+
value="left"
|
|
55
|
+
/>
|
|
56
|
+
</span>
|
|
57
|
+
<span
|
|
58
|
+
className="MuiTouchRipple-root-98"
|
|
59
|
+
/>
|
|
60
|
+
</span>
|
|
61
|
+
<span
|
|
62
|
+
className="MuiTypography-root-62 MuiTypography-body1-71 MuiFormControlLabel-label-34 Component-label-27"
|
|
63
|
+
>
|
|
64
|
+
left
|
|
65
|
+
</span>
|
|
66
|
+
</label>
|
|
67
|
+
<label
|
|
68
|
+
className="MuiFormControlLabel-root-29"
|
|
69
|
+
>
|
|
70
|
+
<span
|
|
71
|
+
className="MuiButtonBase-root-50 MuiIconButton-root-44 MuiPrivateSwitchBase-root-40 MuiRadio-root-35 MuiRadio-colorSecondary-39 Component-customColor-28"
|
|
72
|
+
onBlur={[Function]}
|
|
73
|
+
onContextMenu={[Function]}
|
|
74
|
+
onFocus={[Function]}
|
|
75
|
+
onKeyDown={[Function]}
|
|
76
|
+
onKeyUp={[Function]}
|
|
77
|
+
onMouseDown={[Function]}
|
|
78
|
+
onMouseLeave={[Function]}
|
|
79
|
+
onMouseUp={[Function]}
|
|
80
|
+
onTouchEnd={[Function]}
|
|
81
|
+
onTouchMove={[Function]}
|
|
82
|
+
onTouchStart={[Function]}
|
|
83
|
+
tabIndex={null}
|
|
84
|
+
>
|
|
85
|
+
<span
|
|
86
|
+
className="MuiIconButton-label-49"
|
|
87
|
+
>
|
|
88
|
+
<svg
|
|
89
|
+
aria-hidden="true"
|
|
90
|
+
className="MuiSvgIcon-root-53"
|
|
91
|
+
focusable="false"
|
|
92
|
+
role="presentation"
|
|
93
|
+
viewBox="0 0 24 24"
|
|
94
|
+
>
|
|
95
|
+
<path
|
|
96
|
+
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
|
|
97
|
+
/>
|
|
98
|
+
</svg>
|
|
99
|
+
<input
|
|
100
|
+
checked={false}
|
|
101
|
+
className="MuiPrivateSwitchBase-input-43"
|
|
102
|
+
disabled={false}
|
|
103
|
+
onChange={[Function]}
|
|
104
|
+
type="radio"
|
|
105
|
+
value="center"
|
|
106
|
+
/>
|
|
107
|
+
</span>
|
|
108
|
+
<span
|
|
109
|
+
className="MuiTouchRipple-root-98"
|
|
110
|
+
/>
|
|
111
|
+
</span>
|
|
112
|
+
<span
|
|
113
|
+
className="MuiTypography-root-62 MuiTypography-body1-71 MuiFormControlLabel-label-34 Component-label-27"
|
|
114
|
+
>
|
|
115
|
+
center
|
|
116
|
+
</span>
|
|
117
|
+
</label>
|
|
118
|
+
<label
|
|
119
|
+
className="MuiFormControlLabel-root-29"
|
|
120
|
+
>
|
|
121
|
+
<span
|
|
122
|
+
className="MuiButtonBase-root-50 MuiIconButton-root-44 MuiPrivateSwitchBase-root-40 MuiRadio-root-35 MuiRadio-colorSecondary-39 Component-customColor-28"
|
|
123
|
+
onBlur={[Function]}
|
|
124
|
+
onContextMenu={[Function]}
|
|
125
|
+
onFocus={[Function]}
|
|
126
|
+
onKeyDown={[Function]}
|
|
127
|
+
onKeyUp={[Function]}
|
|
128
|
+
onMouseDown={[Function]}
|
|
129
|
+
onMouseLeave={[Function]}
|
|
130
|
+
onMouseUp={[Function]}
|
|
131
|
+
onTouchEnd={[Function]}
|
|
132
|
+
onTouchMove={[Function]}
|
|
133
|
+
onTouchStart={[Function]}
|
|
134
|
+
tabIndex={null}
|
|
135
|
+
>
|
|
136
|
+
<span
|
|
137
|
+
className="MuiIconButton-label-49"
|
|
138
|
+
>
|
|
139
|
+
<svg
|
|
140
|
+
aria-hidden="true"
|
|
141
|
+
className="MuiSvgIcon-root-53"
|
|
142
|
+
focusable="false"
|
|
143
|
+
role="presentation"
|
|
144
|
+
viewBox="0 0 24 24"
|
|
145
|
+
>
|
|
146
|
+
<path
|
|
147
|
+
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
|
|
148
|
+
/>
|
|
149
|
+
</svg>
|
|
150
|
+
<input
|
|
151
|
+
checked={false}
|
|
152
|
+
className="MuiPrivateSwitchBase-input-43"
|
|
153
|
+
disabled={false}
|
|
154
|
+
onChange={[Function]}
|
|
155
|
+
type="radio"
|
|
156
|
+
value="right"
|
|
157
|
+
/>
|
|
158
|
+
</span>
|
|
159
|
+
<span
|
|
160
|
+
className="MuiTouchRipple-root-98"
|
|
161
|
+
/>
|
|
162
|
+
</span>
|
|
163
|
+
<span
|
|
164
|
+
className="MuiTypography-root-62 MuiTypography-body1-71 MuiFormControlLabel-label-34 Component-label-27"
|
|
165
|
+
>
|
|
166
|
+
right
|
|
167
|
+
</span>
|
|
168
|
+
</label>
|
|
169
|
+
</div>
|
|
170
|
+
</div>
|
|
171
|
+
`;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { firstAvailableIndex } from '../choice-utils';
|
|
2
|
+
|
|
3
|
+
describe('firstAvailableIndex', () => {
|
|
4
|
+
const assert = (values, index, expected) => {
|
|
5
|
+
it(`[${values.join(',')}], ${index} ==> ${expected}`, () => {
|
|
6
|
+
expect(firstAvailableIndex(['0'], 0)).toEqual('1');
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
assert(['0'], 0, '1');
|
|
10
|
+
assert(['0', '1', '2'], 0, '3');
|
|
11
|
+
assert(['0', '1', '2'], 100, '100');
|
|
12
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { shallow } from 'enzyme';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { RawLangs } from '../langs';
|
|
4
|
+
|
|
5
|
+
describe('langs', () => {
|
|
6
|
+
let onChange;
|
|
7
|
+
const wrapper = (extras) => {
|
|
8
|
+
const defaults = {
|
|
9
|
+
uid: '1',
|
|
10
|
+
onChange,
|
|
11
|
+
classes: {},
|
|
12
|
+
langs: ['en-US', 'es-ES'],
|
|
13
|
+
};
|
|
14
|
+
const props = { ...defaults, ...extras };
|
|
15
|
+
return shallow(<RawLangs {...props} />);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
onChange = jest.fn();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe('snapshot', () => {
|
|
23
|
+
it('renders', () => {
|
|
24
|
+
expect(wrapper()).toMatchSnapshot();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe('logic', () => {
|
|
29
|
+
describe('choose', () => {
|
|
30
|
+
it('calls onChange', () => {
|
|
31
|
+
const w = wrapper();
|
|
32
|
+
w.instance().choose({ target: { value: 'en-US' } });
|
|
33
|
+
expect(onChange).toBeCalledWith('en-US');
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shallow } from 'enzyme';
|
|
3
|
+
import { NumberTextField } from '../number-text-field';
|
|
4
|
+
import TextField from '@material-ui/core/TextField';
|
|
5
|
+
|
|
6
|
+
describe('NumberTextField', () => {
|
|
7
|
+
describe('render', () => {
|
|
8
|
+
let value = 1;
|
|
9
|
+
let onChange, component, textField, onBlur;
|
|
10
|
+
let min = 1;
|
|
11
|
+
let max = 10;
|
|
12
|
+
|
|
13
|
+
describe('TextField', () => {
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
onChange = jest.fn();
|
|
16
|
+
onBlur = jest.fn();
|
|
17
|
+
component = shallow(
|
|
18
|
+
<NumberTextField value={value} min={min} max={max} classes={{}} onChange={onChange} onBlur={onBlur} />,
|
|
19
|
+
);
|
|
20
|
+
textField = component.find(TextField);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('should render mui TextField', () => {
|
|
24
|
+
expect(textField.length).toEqual(1);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe('props', () => {
|
|
28
|
+
let props;
|
|
29
|
+
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
props = textField.props();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should contain value', () => {
|
|
35
|
+
expect(props.value).toEqual(value);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe('logic', () => {
|
|
40
|
+
describe('clamp', () => {
|
|
41
|
+
const assertClamp = (input, expected) => {
|
|
42
|
+
it(`${input} => ${expected}`, () => {
|
|
43
|
+
const result = component.instance().clamp(input);
|
|
44
|
+
expect(result).toEqual(expected);
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
assertClamp('foo', 1);
|
|
49
|
+
assertClamp(1, 1);
|
|
50
|
+
assertClamp(2, 2);
|
|
51
|
+
assertClamp(0, 1);
|
|
52
|
+
assertClamp(-1, 1);
|
|
53
|
+
assertClamp(10, 10);
|
|
54
|
+
assertClamp(11, 10);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe('onBlur', () => {
|
|
58
|
+
const event = (value) => ({
|
|
59
|
+
target: { value },
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe('called with valid string representation of int', () => {
|
|
63
|
+
it('should be called with parsed int', () => {
|
|
64
|
+
const e = event('1');
|
|
65
|
+
|
|
66
|
+
textField.simulate('change', e);
|
|
67
|
+
|
|
68
|
+
expect(component.state('value')).toEqual('1');
|
|
69
|
+
|
|
70
|
+
e.target.value = '100';
|
|
71
|
+
|
|
72
|
+
textField.simulate('change', e);
|
|
73
|
+
|
|
74
|
+
expect(component.state('value')).toEqual('100');
|
|
75
|
+
|
|
76
|
+
const beforeMax = (max - 1).toString();
|
|
77
|
+
e.target.value = beforeMax;
|
|
78
|
+
|
|
79
|
+
textField.simulate('blur', e);
|
|
80
|
+
|
|
81
|
+
expect(component.state('value')).toEqual(beforeMax);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
describe('called with invalid string representation of int', () => {
|
|
86
|
+
it('should be called with min value', () => {
|
|
87
|
+
const e = event('aa');
|
|
88
|
+
|
|
89
|
+
textField.simulate('change', e);
|
|
90
|
+
|
|
91
|
+
expect(component.state('value')).toEqual('aa');
|
|
92
|
+
|
|
93
|
+
textField.simulate('blur', e);
|
|
94
|
+
|
|
95
|
+
expect(component.state('value')).toEqual(min.toString());
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
describe('called with empty string', () => {
|
|
100
|
+
it('should be called with min value', () => {
|
|
101
|
+
const e = event('');
|
|
102
|
+
|
|
103
|
+
textField.simulate('change', e);
|
|
104
|
+
|
|
105
|
+
expect(component.state('value')).toEqual('');
|
|
106
|
+
|
|
107
|
+
textField.simulate('blur', e);
|
|
108
|
+
|
|
109
|
+
expect(component.state('value')).toEqual(min.toString());
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
describe('string int less than min', () => {
|
|
114
|
+
const value = (min - 1).toString();
|
|
115
|
+
|
|
116
|
+
it('should be called with value of min', () => {
|
|
117
|
+
const e = event(value);
|
|
118
|
+
|
|
119
|
+
textField.simulate('change', e);
|
|
120
|
+
|
|
121
|
+
expect(component.state('value')).toEqual(value);
|
|
122
|
+
|
|
123
|
+
textField.simulate('blur', e);
|
|
124
|
+
|
|
125
|
+
expect(component.state('value')).toEqual(min.toString());
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
describe('string int exceeds max', () => {
|
|
130
|
+
const value = (max + 1).toString();
|
|
131
|
+
|
|
132
|
+
it('should be called with value of max', () => {
|
|
133
|
+
const e = event(value);
|
|
134
|
+
|
|
135
|
+
textField.simulate('change', e);
|
|
136
|
+
|
|
137
|
+
expect(component.state('value')).toEqual(value);
|
|
138
|
+
|
|
139
|
+
textField.simulate('blur', e);
|
|
140
|
+
|
|
141
|
+
expect(component.state('value')).toEqual(max.toString());
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
});
|