@pie-lib/mask-markup 1.13.46 → 1.14.1-beta.0
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.md +15 -56
- package/NEXT.CHANGELOG.json +1 -0
- package/package.json +9 -5
- package/src/__tests__/__snapshots__/drag-in-the-blank.test.js.snap +316 -0
- package/src/__tests__/__snapshots__/mask.test.js.snap +55 -0
- package/src/__tests__/__snapshots__/with-mask.test.js.snap +62 -0
- package/src/__tests__/drag-in-the-blank.test.js +71 -0
- package/src/__tests__/index.test.js +39 -0
- package/src/__tests__/mask.test.js +152 -0
- package/src/__tests__/serialization.test.js +54 -0
- package/src/__tests__/utils.js +1 -0
- package/src/__tests__/with-mask.test.js +51 -0
- package/src/choices/__tests__/__snapshots__/index.test.js.snap +209 -0
- package/src/choices/__tests__/index.test.js +62 -0
- package/src/choices/choice.jsx +60 -6
- package/src/choices/index.jsx +2 -2
- package/src/components/__tests__/__snapshots__/blank.test.js.snap +111 -0
- package/src/components/__tests__/__snapshots__/correct-input.test.js.snap +64 -0
- package/src/components/__tests__/__snapshots__/dropdown.test.js.snap +133 -0
- package/src/components/__tests__/__snapshots__/input.test.js.snap +34 -0
- package/src/components/__tests__/blank.test.js +202 -0
- package/src/components/__tests__/correct-input.test.js +49 -0
- package/src/components/__tests__/dropdown.test.js +51 -0
- package/src/components/__tests__/input.test.js +50 -0
- package/src/components/blank.jsx +139 -28
- package/src/components/correct-input.jsx +6 -1
- package/src/components/dropdown.jsx +192 -71
- package/src/constructed-response.jsx +76 -18
- package/src/customizable.jsx +35 -0
- package/src/drag-in-the-blank.jsx +26 -3
- package/src/index.js +10 -1
- package/src/inline-dropdown.jsx +2 -0
- package/src/mask.jsx +30 -5
- package/src/with-mask.jsx +39 -2
- package/README.md +0 -14
- package/lib/choices/choice.js +0 -158
- package/lib/choices/choice.js.map +0 -1
- package/lib/choices/index.js +0 -127
- package/lib/choices/index.js.map +0 -1
- package/lib/componentize.js +0 -25
- package/lib/componentize.js.map +0 -1
- package/lib/components/blank.js +0 -303
- package/lib/components/blank.js.map +0 -1
- package/lib/components/correct-input.js +0 -113
- package/lib/components/correct-input.js.map +0 -1
- package/lib/components/dropdown.js +0 -216
- package/lib/components/dropdown.js.map +0 -1
- package/lib/components/input.js +0 -57
- package/lib/components/input.js.map +0 -1
- package/lib/constructed-response.js +0 -52
- package/lib/constructed-response.js.map +0 -1
- package/lib/drag-in-the-blank.js +0 -191
- package/lib/drag-in-the-blank.js.map +0 -1
- package/lib/index.js +0 -54
- package/lib/index.js.map +0 -1
- package/lib/inline-dropdown.js +0 -46
- package/lib/inline-dropdown.js.map +0 -1
- package/lib/mask.js +0 -215
- package/lib/mask.js.map +0 -1
- package/lib/serialization.js +0 -207
- package/lib/serialization.js.map +0 -1
- package/lib/with-mask.js +0 -93
- package/lib/with-mask.js.map +0 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Blank render renders correctly with default props 1`] = `
|
|
4
|
+
<WithStyles(Chip)
|
|
5
|
+
className="undefined"
|
|
6
|
+
clickable={false}
|
|
7
|
+
component="span"
|
|
8
|
+
disabled={true}
|
|
9
|
+
label={
|
|
10
|
+
<React.Fragment>
|
|
11
|
+
<span
|
|
12
|
+
className=""
|
|
13
|
+
>
|
|
14
|
+
|
|
15
|
+
</span>
|
|
16
|
+
</React.Fragment>
|
|
17
|
+
}
|
|
18
|
+
style={
|
|
19
|
+
Object {
|
|
20
|
+
"height": 0,
|
|
21
|
+
"minHeight": 32,
|
|
22
|
+
"minWidth": 90,
|
|
23
|
+
"width": 0,
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/>
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
exports[`Blank render renders correctly with disabled prop as true 1`] = `
|
|
30
|
+
<WithStyles(Chip)
|
|
31
|
+
className="undefined"
|
|
32
|
+
clickable={false}
|
|
33
|
+
component="span"
|
|
34
|
+
disabled={true}
|
|
35
|
+
label={
|
|
36
|
+
<React.Fragment>
|
|
37
|
+
<span
|
|
38
|
+
className=""
|
|
39
|
+
>
|
|
40
|
+
|
|
41
|
+
</span>
|
|
42
|
+
</React.Fragment>
|
|
43
|
+
}
|
|
44
|
+
style={
|
|
45
|
+
Object {
|
|
46
|
+
"height": 0,
|
|
47
|
+
"minHeight": 32,
|
|
48
|
+
"minWidth": 90,
|
|
49
|
+
"width": 0,
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
variant="outlined"
|
|
53
|
+
/>
|
|
54
|
+
`;
|
|
55
|
+
|
|
56
|
+
exports[`Blank render renders correctly with draggedItem 1`] = `
|
|
57
|
+
<WithStyles(Chip)
|
|
58
|
+
className="undefined"
|
|
59
|
+
clickable={false}
|
|
60
|
+
component="span"
|
|
61
|
+
disabled={true}
|
|
62
|
+
label={
|
|
63
|
+
<React.Fragment>
|
|
64
|
+
<span
|
|
65
|
+
className=""
|
|
66
|
+
>
|
|
67
|
+
|
|
68
|
+
</span>
|
|
69
|
+
</React.Fragment>
|
|
70
|
+
}
|
|
71
|
+
style={
|
|
72
|
+
Object {
|
|
73
|
+
"height": 0,
|
|
74
|
+
"minHeight": 32,
|
|
75
|
+
"minWidth": 90,
|
|
76
|
+
"width": 0,
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/>
|
|
80
|
+
`;
|
|
81
|
+
|
|
82
|
+
exports[`Blank render renders correctly with draggedItem and isOver 1`] = `
|
|
83
|
+
<WithStyles(Chip)
|
|
84
|
+
className="undefined"
|
|
85
|
+
clickable={false}
|
|
86
|
+
component="span"
|
|
87
|
+
disabled={true}
|
|
88
|
+
label={
|
|
89
|
+
<React.Fragment>
|
|
90
|
+
<span
|
|
91
|
+
className="undefined"
|
|
92
|
+
>
|
|
93
|
+
|
|
94
|
+
</span>
|
|
95
|
+
<span
|
|
96
|
+
className=""
|
|
97
|
+
>
|
|
98
|
+
|
|
99
|
+
</span>
|
|
100
|
+
</React.Fragment>
|
|
101
|
+
}
|
|
102
|
+
style={
|
|
103
|
+
Object {
|
|
104
|
+
"height": 0,
|
|
105
|
+
"minHeight": 32,
|
|
106
|
+
"minWidth": 90,
|
|
107
|
+
"width": 0,
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/>
|
|
111
|
+
`;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`CorrectInput render renders correctly with correct as false 1`] = `
|
|
4
|
+
<Component
|
|
5
|
+
classes={
|
|
6
|
+
Object {
|
|
7
|
+
"box": "Component-box-5",
|
|
8
|
+
"correct": "Component-correct-3",
|
|
9
|
+
"crInput": "Component-crInput-2",
|
|
10
|
+
"incorrect": "Component-incorrect-4",
|
|
11
|
+
"input": "Component-input-1",
|
|
12
|
+
"notchedOutline": "Component-notchedOutline-7",
|
|
13
|
+
"outlinedInput": "Component-outlinedInput-6",
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
correct={false}
|
|
17
|
+
disabled={false}
|
|
18
|
+
onChange={[MockFunction]}
|
|
19
|
+
value="Cow"
|
|
20
|
+
variant="outlined"
|
|
21
|
+
/>
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
exports[`CorrectInput render renders correctly with default props 1`] = `
|
|
25
|
+
<Component
|
|
26
|
+
classes={
|
|
27
|
+
Object {
|
|
28
|
+
"box": "Component-box-5",
|
|
29
|
+
"correct": "Component-correct-3",
|
|
30
|
+
"crInput": "Component-crInput-2",
|
|
31
|
+
"incorrect": "Component-incorrect-4",
|
|
32
|
+
"input": "Component-input-1",
|
|
33
|
+
"notchedOutline": "Component-notchedOutline-7",
|
|
34
|
+
"outlinedInput": "Component-outlinedInput-6",
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
correct={false}
|
|
38
|
+
disabled={false}
|
|
39
|
+
onChange={[MockFunction]}
|
|
40
|
+
value="Cow"
|
|
41
|
+
variant="outlined"
|
|
42
|
+
/>
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
exports[`CorrectInput render renders correctly with disabled prop as true 1`] = `
|
|
46
|
+
<Component
|
|
47
|
+
classes={
|
|
48
|
+
Object {
|
|
49
|
+
"box": "Component-box-5",
|
|
50
|
+
"correct": "Component-correct-3",
|
|
51
|
+
"crInput": "Component-crInput-2",
|
|
52
|
+
"incorrect": "Component-incorrect-4",
|
|
53
|
+
"input": "Component-input-1",
|
|
54
|
+
"notchedOutline": "Component-notchedOutline-7",
|
|
55
|
+
"outlinedInput": "Component-outlinedInput-6",
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
correct={false}
|
|
59
|
+
disabled={true}
|
|
60
|
+
onChange={[MockFunction]}
|
|
61
|
+
value="Cow"
|
|
62
|
+
variant="outlined"
|
|
63
|
+
/>
|
|
64
|
+
`;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Dropdown render renders correctly with correct as true 1`] = `
|
|
4
|
+
<Dropdown
|
|
5
|
+
choices={
|
|
6
|
+
Array [
|
|
7
|
+
Object {
|
|
8
|
+
"id": undefined,
|
|
9
|
+
"label": "Jumped",
|
|
10
|
+
"value": "Jumped",
|
|
11
|
+
},
|
|
12
|
+
Object {
|
|
13
|
+
"id": undefined,
|
|
14
|
+
"label": "Laughed",
|
|
15
|
+
"value": "Laughed",
|
|
16
|
+
},
|
|
17
|
+
Object {
|
|
18
|
+
"id": undefined,
|
|
19
|
+
"label": "Smiled",
|
|
20
|
+
"value": "Smiled",
|
|
21
|
+
},
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
classes={
|
|
25
|
+
Object {
|
|
26
|
+
"correctIcon": "Dropdown-correctIcon-10",
|
|
27
|
+
"correctnessIndicatorIcon": "Dropdown-correctnessIndicatorIcon-9",
|
|
28
|
+
"disabledCorrect": "Dropdown-disabledCorrect-2",
|
|
29
|
+
"disabledIncorrect": "Dropdown-disabledIncorrect-3",
|
|
30
|
+
"incorrectIcon": "Dropdown-incorrectIcon-11",
|
|
31
|
+
"label": "Dropdown-label-7",
|
|
32
|
+
"menuRoot": "Dropdown-menuRoot-6",
|
|
33
|
+
"root": "Dropdown-root-1",
|
|
34
|
+
"selectMenu": "Dropdown-selectMenu-4",
|
|
35
|
+
"selected": "Dropdown-selected-5",
|
|
36
|
+
"srOnly": "Dropdown-srOnly-8",
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
correct={true}
|
|
40
|
+
disabled={false}
|
|
41
|
+
id="1"
|
|
42
|
+
onChange={[MockFunction]}
|
|
43
|
+
value="Jumped"
|
|
44
|
+
/>
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
exports[`Dropdown render renders correctly with default props 1`] = `
|
|
48
|
+
<Dropdown
|
|
49
|
+
choices={
|
|
50
|
+
Array [
|
|
51
|
+
Object {
|
|
52
|
+
"id": undefined,
|
|
53
|
+
"label": "Jumped",
|
|
54
|
+
"value": "Jumped",
|
|
55
|
+
},
|
|
56
|
+
Object {
|
|
57
|
+
"id": undefined,
|
|
58
|
+
"label": "Laughed",
|
|
59
|
+
"value": "Laughed",
|
|
60
|
+
},
|
|
61
|
+
Object {
|
|
62
|
+
"id": undefined,
|
|
63
|
+
"label": "Smiled",
|
|
64
|
+
"value": "Smiled",
|
|
65
|
+
},
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
classes={
|
|
69
|
+
Object {
|
|
70
|
+
"correctIcon": "Dropdown-correctIcon-10",
|
|
71
|
+
"correctnessIndicatorIcon": "Dropdown-correctnessIndicatorIcon-9",
|
|
72
|
+
"disabledCorrect": "Dropdown-disabledCorrect-2",
|
|
73
|
+
"disabledIncorrect": "Dropdown-disabledIncorrect-3",
|
|
74
|
+
"incorrectIcon": "Dropdown-incorrectIcon-11",
|
|
75
|
+
"label": "Dropdown-label-7",
|
|
76
|
+
"menuRoot": "Dropdown-menuRoot-6",
|
|
77
|
+
"root": "Dropdown-root-1",
|
|
78
|
+
"selectMenu": "Dropdown-selectMenu-4",
|
|
79
|
+
"selected": "Dropdown-selected-5",
|
|
80
|
+
"srOnly": "Dropdown-srOnly-8",
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
correct={false}
|
|
84
|
+
disabled={false}
|
|
85
|
+
id="1"
|
|
86
|
+
onChange={[MockFunction]}
|
|
87
|
+
value="Jumped"
|
|
88
|
+
/>
|
|
89
|
+
`;
|
|
90
|
+
|
|
91
|
+
exports[`Dropdown render renders correctly with disabled prop as true 1`] = `
|
|
92
|
+
<Dropdown
|
|
93
|
+
choices={
|
|
94
|
+
Array [
|
|
95
|
+
Object {
|
|
96
|
+
"id": undefined,
|
|
97
|
+
"label": "Jumped",
|
|
98
|
+
"value": "Jumped",
|
|
99
|
+
},
|
|
100
|
+
Object {
|
|
101
|
+
"id": undefined,
|
|
102
|
+
"label": "Laughed",
|
|
103
|
+
"value": "Laughed",
|
|
104
|
+
},
|
|
105
|
+
Object {
|
|
106
|
+
"id": undefined,
|
|
107
|
+
"label": "Smiled",
|
|
108
|
+
"value": "Smiled",
|
|
109
|
+
},
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
classes={
|
|
113
|
+
Object {
|
|
114
|
+
"correctIcon": "Dropdown-correctIcon-10",
|
|
115
|
+
"correctnessIndicatorIcon": "Dropdown-correctnessIndicatorIcon-9",
|
|
116
|
+
"disabledCorrect": "Dropdown-disabledCorrect-2",
|
|
117
|
+
"disabledIncorrect": "Dropdown-disabledIncorrect-3",
|
|
118
|
+
"incorrectIcon": "Dropdown-incorrectIcon-11",
|
|
119
|
+
"label": "Dropdown-label-7",
|
|
120
|
+
"menuRoot": "Dropdown-menuRoot-6",
|
|
121
|
+
"root": "Dropdown-root-1",
|
|
122
|
+
"selectMenu": "Dropdown-selectMenu-4",
|
|
123
|
+
"selected": "Dropdown-selected-5",
|
|
124
|
+
"srOnly": "Dropdown-srOnly-8",
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
correct={false}
|
|
128
|
+
disabled={true}
|
|
129
|
+
id="1"
|
|
130
|
+
onChange={[MockFunction]}
|
|
131
|
+
value="Jumped"
|
|
132
|
+
/>
|
|
133
|
+
`;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Input render renders correctly with correct as false 1`] = `
|
|
4
|
+
<WithStyles(Component)
|
|
5
|
+
correct={false}
|
|
6
|
+
disabled={false}
|
|
7
|
+
isBox={true}
|
|
8
|
+
onChange={[Function]}
|
|
9
|
+
value="Cow"
|
|
10
|
+
variant="outlined"
|
|
11
|
+
/>
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
exports[`Input render renders correctly with default props 1`] = `
|
|
15
|
+
<WithStyles(Component)
|
|
16
|
+
correct={false}
|
|
17
|
+
disabled={false}
|
|
18
|
+
isBox={true}
|
|
19
|
+
onChange={[Function]}
|
|
20
|
+
value="Cow"
|
|
21
|
+
variant="outlined"
|
|
22
|
+
/>
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
exports[`Input render renders correctly with disabled prop as true 1`] = `
|
|
26
|
+
<WithStyles(Component)
|
|
27
|
+
correct={false}
|
|
28
|
+
disabled={true}
|
|
29
|
+
isBox={true}
|
|
30
|
+
onChange={[Function]}
|
|
31
|
+
value="Cow"
|
|
32
|
+
variant="outlined"
|
|
33
|
+
/>
|
|
34
|
+
`;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { shallow } from 'enzyme';
|
|
3
|
+
import { BlankContent as Blank } from '../blank';
|
|
4
|
+
|
|
5
|
+
describe('Blank', () => {
|
|
6
|
+
const onChange = jest.fn();
|
|
7
|
+
const defaultProps = {
|
|
8
|
+
disabled: false,
|
|
9
|
+
value: 'Cow',
|
|
10
|
+
classes: {},
|
|
11
|
+
isOver: false,
|
|
12
|
+
dragItem: {},
|
|
13
|
+
correct: false,
|
|
14
|
+
onChange,
|
|
15
|
+
};
|
|
16
|
+
let wrapper;
|
|
17
|
+
let instance;
|
|
18
|
+
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
wrapper = shallow(<Blank {...defaultProps} />);
|
|
21
|
+
instance = wrapper.instance();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('render', () => {
|
|
25
|
+
it('renders correctly with default props', () => {
|
|
26
|
+
expect(wrapper).toMatchSnapshot();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('renders correctly with disabled prop as true', () => {
|
|
30
|
+
wrapper.setProps({ disabled: true });
|
|
31
|
+
expect(wrapper).toMatchSnapshot();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('renders correctly with draggedItem', () => {
|
|
35
|
+
wrapper.setProps({ dragItem: { choice: { value: 'Dog' } } });
|
|
36
|
+
expect(wrapper).toMatchSnapshot();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('renders correctly with draggedItem and isOver', () => {
|
|
40
|
+
wrapper.setProps({ dragItem: { choice: { value: 'Dog' } }, isOver: true });
|
|
41
|
+
expect(wrapper).toMatchSnapshot();
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('onDelete', () => {
|
|
46
|
+
it('should be undefined if disabled is true', () => {
|
|
47
|
+
wrapper.setProps({ disabled: true });
|
|
48
|
+
|
|
49
|
+
expect(wrapper.props().onDelete).toEqual(undefined);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('should be undefined if no value is set', () => {
|
|
53
|
+
wrapper.setProps({ disabled: false, value: undefined });
|
|
54
|
+
|
|
55
|
+
expect(wrapper.props().onDelete).toEqual(undefined);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe('updateDimensions', () => {
|
|
60
|
+
let span;
|
|
61
|
+
let rootRef;
|
|
62
|
+
|
|
63
|
+
const setSpanDimensions = (height, width) => {
|
|
64
|
+
Object.defineProperty(span, 'offsetHeight', { value: height, configurable: true });
|
|
65
|
+
Object.defineProperty(span, 'offsetWidth', { value: width, configurable: true });
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
beforeEach(() => {
|
|
69
|
+
wrapper = shallow(<Blank {...defaultProps} />);
|
|
70
|
+
instance = wrapper.instance();
|
|
71
|
+
|
|
72
|
+
span = document.createElement('span');
|
|
73
|
+
rootRef = document.createElement('span');
|
|
74
|
+
|
|
75
|
+
instance.spanRef = span;
|
|
76
|
+
instance.rootRef = rootRef;
|
|
77
|
+
|
|
78
|
+
Object.defineProperty(span, 'offsetHeight', { value: 0, configurable: true });
|
|
79
|
+
Object.defineProperty(span, 'offsetWidth', { value: 0, configurable: true });
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should update dimensions if span size exceeds the response area size', () => {
|
|
83
|
+
setSpanDimensions(50, 50);
|
|
84
|
+
|
|
85
|
+
instance.updateDimensions();
|
|
86
|
+
|
|
87
|
+
expect(instance.state).toEqual({
|
|
88
|
+
width: 74,
|
|
89
|
+
height: 74,
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('should not update dimensions if span size does not exceed the response area size', () => {
|
|
94
|
+
wrapper.setProps({
|
|
95
|
+
emptyResponseAreaHeight: 50,
|
|
96
|
+
emptyResponseAreaWidth: 50,
|
|
97
|
+
});
|
|
98
|
+
setSpanDimensions(30, 30);
|
|
99
|
+
|
|
100
|
+
instance.updateDimensions();
|
|
101
|
+
|
|
102
|
+
expect(instance.state).toEqual({
|
|
103
|
+
width: 54, // with padding it does exceed (30 + 24 > 50) so it's updating
|
|
104
|
+
height: 54, // with padding it does exceed (30 + 24 > 50) so it's updating
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('should handle non-numeric emptyResponseAreaHeight and emptyResponseAreaWidth', () => {
|
|
109
|
+
wrapper.setProps({
|
|
110
|
+
emptyResponseAreaHeight: 'non-numeric',
|
|
111
|
+
emptyResponseAreaWidth: 'non-numeric',
|
|
112
|
+
});
|
|
113
|
+
setSpanDimensions(50, 50);
|
|
114
|
+
|
|
115
|
+
instance.updateDimensions();
|
|
116
|
+
|
|
117
|
+
expect(instance.state).toEqual({
|
|
118
|
+
width: 74,
|
|
119
|
+
height: 74,
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
describe('getRootDimensions', () => {
|
|
125
|
+
it('should return state dimensions if set', () => {
|
|
126
|
+
instance.setState({ height: 50, width: 50 });
|
|
127
|
+
|
|
128
|
+
const dimensions = instance.getRootDimensions();
|
|
129
|
+
|
|
130
|
+
expect(dimensions).toEqual({
|
|
131
|
+
height: 50,
|
|
132
|
+
width: 50,
|
|
133
|
+
minWidth: 90,
|
|
134
|
+
minHeight: 32,
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('should return state height and props width if state width is not set', () => {
|
|
139
|
+
instance.setState({ height: 50, width: 0 });
|
|
140
|
+
|
|
141
|
+
const dimensions = instance.getRootDimensions();
|
|
142
|
+
|
|
143
|
+
expect(dimensions).toEqual({
|
|
144
|
+
height: 50,
|
|
145
|
+
width: 0,
|
|
146
|
+
minWidth: 90,
|
|
147
|
+
minHeight: 32,
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('should return props height and state width if state height is not set', () => {
|
|
152
|
+
instance.setState({ height: 0, width: 50 });
|
|
153
|
+
|
|
154
|
+
const dimensions = instance.getRootDimensions();
|
|
155
|
+
|
|
156
|
+
expect(dimensions).toEqual({
|
|
157
|
+
height: 0,
|
|
158
|
+
width: 50,
|
|
159
|
+
minWidth: 90,
|
|
160
|
+
minHeight: 32,
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it('should return props dimensions if state dimensions are zero', () => {
|
|
165
|
+
instance.setState({ height: 0, width: 0 });
|
|
166
|
+
wrapper.setProps({ emptyResponseAreaHeight: 60, emptyResponseAreaWidth: 60 });
|
|
167
|
+
|
|
168
|
+
const dimensions = instance.getRootDimensions();
|
|
169
|
+
|
|
170
|
+
expect(dimensions).toEqual({
|
|
171
|
+
height: 60,
|
|
172
|
+
width: 60,
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it('should return state dimensions over props dimensions if both are set', () => {
|
|
177
|
+
instance.setState({ height: 50, width: 50 });
|
|
178
|
+
wrapper.setProps({ emptyResponseAreaHeight: 60, emptyResponseAreaWidth: 60 });
|
|
179
|
+
|
|
180
|
+
const dimensions = instance.getRootDimensions();
|
|
181
|
+
|
|
182
|
+
expect(dimensions).toEqual({
|
|
183
|
+
height: 50,
|
|
184
|
+
width: 50,
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('should return minWidth and minHeight if state and props dimensions are zero or undefined', () => {
|
|
189
|
+
instance.setState({ height: 0, width: 0 });
|
|
190
|
+
wrapper.setProps({ emptyResponseAreaHeight: undefined, emptyResponseAreaWidth: undefined });
|
|
191
|
+
|
|
192
|
+
const dimensions = instance.getRootDimensions();
|
|
193
|
+
|
|
194
|
+
expect(dimensions).toEqual({
|
|
195
|
+
height: 0,
|
|
196
|
+
width: 0,
|
|
197
|
+
minWidth: 90,
|
|
198
|
+
minHeight: 32,
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { shallow } from 'enzyme';
|
|
3
|
+
import CorrectInput from '../correct-input';
|
|
4
|
+
|
|
5
|
+
describe('CorrectInput', () => {
|
|
6
|
+
const onChange = jest.fn();
|
|
7
|
+
const defaultProps = {
|
|
8
|
+
disabled: false,
|
|
9
|
+
correct: false,
|
|
10
|
+
variant: 'outlined',
|
|
11
|
+
value: 'Cow',
|
|
12
|
+
onChange,
|
|
13
|
+
};
|
|
14
|
+
let wrapper;
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
wrapper = shallow(<CorrectInput {...defaultProps} />);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe('render', () => {
|
|
21
|
+
it('renders correctly with default props', () => {
|
|
22
|
+
expect(wrapper).toMatchSnapshot();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('renders correctly with disabled prop as true', () => {
|
|
26
|
+
wrapper.setProps({ disabled: true });
|
|
27
|
+
expect(wrapper).toMatchSnapshot();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('renders correctly with correct as false', () => {
|
|
31
|
+
wrapper.setProps({ correct: false });
|
|
32
|
+
expect(wrapper).toMatchSnapshot();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe('onChange', () => {
|
|
37
|
+
const event = (value) => ({
|
|
38
|
+
target: { value },
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should be called', () => {
|
|
42
|
+
const e = event('1');
|
|
43
|
+
|
|
44
|
+
wrapper.simulate('change', e);
|
|
45
|
+
|
|
46
|
+
expect(onChange).toBeCalledWith(e);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { shallow } from 'enzyme';
|
|
3
|
+
import { choice } from '../../__tests__/utils';
|
|
4
|
+
import Dropdown from '../dropdown';
|
|
5
|
+
|
|
6
|
+
describe('Dropdown', () => {
|
|
7
|
+
const onChange = jest.fn();
|
|
8
|
+
const defaultProps = {
|
|
9
|
+
onChange,
|
|
10
|
+
id: '1',
|
|
11
|
+
correct: false,
|
|
12
|
+
disabled: false,
|
|
13
|
+
value: 'Jumped',
|
|
14
|
+
choices: [choice('Jumped'), choice('Laughed'), choice('Smiled')],
|
|
15
|
+
};
|
|
16
|
+
let wrapper;
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
wrapper = shallow(<Dropdown {...defaultProps} />);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe('render', () => {
|
|
23
|
+
it('renders correctly with default props', () => {
|
|
24
|
+
expect(wrapper).toMatchSnapshot();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('renders correctly with disabled prop as true', () => {
|
|
28
|
+
wrapper.setProps({ disabled: true });
|
|
29
|
+
expect(wrapper).toMatchSnapshot();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('renders correctly with correct as true', () => {
|
|
33
|
+
wrapper.setProps({ correct: true });
|
|
34
|
+
expect(wrapper).toMatchSnapshot();
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe('onChange', () => {
|
|
39
|
+
const event = (value) => ({
|
|
40
|
+
target: { value },
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('should be called with an appropriate value', () => {
|
|
44
|
+
const e = event('Laughed');
|
|
45
|
+
|
|
46
|
+
wrapper.simulate('change', e);
|
|
47
|
+
|
|
48
|
+
expect(onChange).toHaveBeenCalledWith({ target: { value: e.target.value } });
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { shallow } from 'enzyme';
|
|
3
|
+
import Input from '../input';
|
|
4
|
+
|
|
5
|
+
describe('Input', () => {
|
|
6
|
+
const onChange = jest.fn();
|
|
7
|
+
const defaultProps = {
|
|
8
|
+
disabled: false,
|
|
9
|
+
correct: false,
|
|
10
|
+
variant: 'outlined',
|
|
11
|
+
value: 'Cow',
|
|
12
|
+
id: '1',
|
|
13
|
+
onChange,
|
|
14
|
+
};
|
|
15
|
+
let wrapper;
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
wrapper = shallow(<Input {...defaultProps} />);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
describe('render', () => {
|
|
22
|
+
it('renders correctly with default props', () => {
|
|
23
|
+
expect(wrapper).toMatchSnapshot();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('renders correctly with disabled prop as true', () => {
|
|
27
|
+
wrapper.setProps({ disabled: true });
|
|
28
|
+
expect(wrapper).toMatchSnapshot();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('renders correctly with correct as false', () => {
|
|
32
|
+
wrapper.setProps({ correct: false });
|
|
33
|
+
expect(wrapper).toMatchSnapshot();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('onChange', () => {
|
|
38
|
+
const event = (value) => ({
|
|
39
|
+
target: { value },
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should be called', () => {
|
|
43
|
+
const e = event('20');
|
|
44
|
+
|
|
45
|
+
wrapper.simulate('change', e);
|
|
46
|
+
|
|
47
|
+
expect(onChange).toHaveBeenCalledWith('1', e.target.value);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
});
|