@pie-lib/mask-markup 1.13.47-next.1 → 1.14.0-beta.2
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 +22 -47
- 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,71 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { shallow } from 'enzyme';
|
|
3
|
+
import DragInTheBlank from '../drag-in-the-blank';
|
|
4
|
+
|
|
5
|
+
const markup = `<div>
|
|
6
|
+
<img src="https://image.shutterstock.com/image-vector/cow-jumped-over-moon-traditional-260nw-1152899330.jpg"></img>
|
|
7
|
+
<h5>Hey Diddle Diddle <i>by ?</i></h5>
|
|
8
|
+
<p>1: Hey, diddle, diddle,</p>
|
|
9
|
+
<p>2: The cat and the fiddle,</p>
|
|
10
|
+
<p>3: The cow {{0}} over the moon;</p>
|
|
11
|
+
<p>4: The little dog {{1}},</p>
|
|
12
|
+
<p>5: To see such sport,</p>
|
|
13
|
+
<p>6: And the dish ran away with the {{2}}.</p>
|
|
14
|
+
</div>`;
|
|
15
|
+
const choice = (v, id) => ({ value: v, id });
|
|
16
|
+
|
|
17
|
+
describe('DragInTheBlank', () => {
|
|
18
|
+
const defaultProps = {
|
|
19
|
+
disabled: false,
|
|
20
|
+
feedback: {},
|
|
21
|
+
markup,
|
|
22
|
+
choices: [
|
|
23
|
+
choice('Jumped', '0'),
|
|
24
|
+
choice('Laughed', '1'),
|
|
25
|
+
choice('Spoon', '2'),
|
|
26
|
+
choice('Fork', '3'),
|
|
27
|
+
choice('Bumped', '4'),
|
|
28
|
+
choice('Smiled', '5'),
|
|
29
|
+
],
|
|
30
|
+
|
|
31
|
+
value: {
|
|
32
|
+
0: undefined,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
let wrapper;
|
|
36
|
+
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
wrapper = shallow(<DragInTheBlank {...defaultProps} />);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('render', () => {
|
|
42
|
+
it('renders correctly with default props', () => {
|
|
43
|
+
expect(wrapper).toMatchSnapshot();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('renders correctly with disabled prop as true', () => {
|
|
47
|
+
wrapper.setProps({ disabled: true });
|
|
48
|
+
expect(wrapper).toMatchSnapshot();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('renders correctly with feedback', () => {
|
|
52
|
+
wrapper.setProps({
|
|
53
|
+
feedback: {
|
|
54
|
+
0: {
|
|
55
|
+
value: 'Jumped',
|
|
56
|
+
correct: 'Jumped',
|
|
57
|
+
},
|
|
58
|
+
1: {
|
|
59
|
+
value: 'Laughed',
|
|
60
|
+
correct: 'Laughed',
|
|
61
|
+
},
|
|
62
|
+
2: {
|
|
63
|
+
value: 'Spoon',
|
|
64
|
+
correct: 'Spoon',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
expect(wrapper).toMatchSnapshot();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import componentize from '../componentize';
|
|
3
|
+
import { deserialize } from '../serialization';
|
|
4
|
+
|
|
5
|
+
describe('index', () => {
|
|
6
|
+
describe('componentize', () => {
|
|
7
|
+
it('should return an array with the appropriate markup', () => {
|
|
8
|
+
const dropDownMarkup = componentize('{{0}} foo {{1}}', 'dropdown');
|
|
9
|
+
|
|
10
|
+
expect(dropDownMarkup).toEqual({
|
|
11
|
+
markup:
|
|
12
|
+
'<span data-component="dropdown" data-id="0"></span> foo <span data-component="dropdown" data-id="1"></span>',
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
describe('serialization', () => {
|
|
18
|
+
it('should have default node a span', () => {
|
|
19
|
+
expect(deserialize('something')).toEqual(
|
|
20
|
+
expect.objectContaining({
|
|
21
|
+
object: 'value',
|
|
22
|
+
document: {
|
|
23
|
+
object: 'document',
|
|
24
|
+
data: {},
|
|
25
|
+
nodes: [
|
|
26
|
+
{
|
|
27
|
+
object: 'block',
|
|
28
|
+
data: {},
|
|
29
|
+
isVoid: false,
|
|
30
|
+
type: 'span',
|
|
31
|
+
nodes: [{ object: 'text', leaves: [{ text: 'something' }] }],
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { shallow } from 'enzyme';
|
|
3
|
+
import Mask from '../mask';
|
|
4
|
+
|
|
5
|
+
describe('Mask', () => {
|
|
6
|
+
const renderChildren = jest.fn();
|
|
7
|
+
const onChange = jest.fn();
|
|
8
|
+
const defaultProps = {
|
|
9
|
+
renderChildren,
|
|
10
|
+
onChange,
|
|
11
|
+
layout: {
|
|
12
|
+
nodes: [
|
|
13
|
+
{
|
|
14
|
+
object: 'text',
|
|
15
|
+
leaves: [
|
|
16
|
+
{
|
|
17
|
+
text: 'Foo',
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
value: {},
|
|
24
|
+
};
|
|
25
|
+
let wrapper;
|
|
26
|
+
|
|
27
|
+
beforeEach(() => {
|
|
28
|
+
wrapper = shallow(<Mask {...defaultProps} />);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe('render', () => {
|
|
32
|
+
it('renders correctly with default props', () => {
|
|
33
|
+
expect(wrapper).toMatchSnapshot();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('renders correctly a paragraph', () => {
|
|
37
|
+
wrapper.setProps({
|
|
38
|
+
layout: {
|
|
39
|
+
nodes: [
|
|
40
|
+
{
|
|
41
|
+
type: 'p',
|
|
42
|
+
nodes: [
|
|
43
|
+
{
|
|
44
|
+
object: 'text',
|
|
45
|
+
leaves: [
|
|
46
|
+
{
|
|
47
|
+
text: 'Foo',
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
expect(wrapper).toMatchSnapshot();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('renders correctly a div', () => {
|
|
61
|
+
wrapper.setProps({
|
|
62
|
+
layout: {
|
|
63
|
+
nodes: [
|
|
64
|
+
{
|
|
65
|
+
type: 'div',
|
|
66
|
+
data: {
|
|
67
|
+
attributes: {},
|
|
68
|
+
},
|
|
69
|
+
nodes: [
|
|
70
|
+
{
|
|
71
|
+
type: 'p',
|
|
72
|
+
data: {
|
|
73
|
+
attributes: {},
|
|
74
|
+
},
|
|
75
|
+
nodes: [
|
|
76
|
+
{
|
|
77
|
+
object: 'text',
|
|
78
|
+
leaves: [
|
|
79
|
+
{
|
|
80
|
+
text: 'Foo',
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
expect(wrapper).toMatchSnapshot();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it.only('renders correctly a em', () => {
|
|
96
|
+
wrapper.setProps({
|
|
97
|
+
layout: {
|
|
98
|
+
nodes: [
|
|
99
|
+
{
|
|
100
|
+
leaves: [{ text: 'Foo ' }],
|
|
101
|
+
object: 'text',
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
leaves: [
|
|
105
|
+
{
|
|
106
|
+
marks: [
|
|
107
|
+
{
|
|
108
|
+
data: undefined,
|
|
109
|
+
type: 'italic',
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
text: 'x',
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
object: 'text',
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
leaves: [{ text: ' bar' }],
|
|
119
|
+
object: 'text',
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
object: 'block',
|
|
123
|
+
type: 'div',
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
expect(wrapper).toMatchSnapshot();
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const da = () => ({ data: { attributes: {} } });
|
|
131
|
+
it('renders without space under tbody', () => {
|
|
132
|
+
wrapper.setProps({
|
|
133
|
+
layout: {
|
|
134
|
+
nodes: [
|
|
135
|
+
{
|
|
136
|
+
type: 'tbody',
|
|
137
|
+
...da(),
|
|
138
|
+
nodes: [
|
|
139
|
+
{
|
|
140
|
+
object: 'text',
|
|
141
|
+
leaves: [{ text: ' ' }],
|
|
142
|
+
},
|
|
143
|
+
{ type: 'tr', ...da(), nodes: [] },
|
|
144
|
+
],
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
expect(wrapper).toMatchSnapshot();
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { deserialize } from '../serialization';
|
|
2
|
+
|
|
3
|
+
describe('serialization', () => {
|
|
4
|
+
it('ignores comments', () => {
|
|
5
|
+
const out = deserialize(`<!-- hi -->`);
|
|
6
|
+
expect(out.document.nodes[0]).toEqual(expect.objectContaining({ type: 'span' }));
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('ignores comments', () => {
|
|
10
|
+
const out = deserialize(`<!-- hi --><div>foo</div>`);
|
|
11
|
+
expect(out.document.nodes[0]).toEqual(
|
|
12
|
+
expect.objectContaining({
|
|
13
|
+
type: 'div',
|
|
14
|
+
nodes: [
|
|
15
|
+
expect.objectContaining({
|
|
16
|
+
object: 'text',
|
|
17
|
+
leaves: [{ text: 'foo' }],
|
|
18
|
+
}),
|
|
19
|
+
],
|
|
20
|
+
}),
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('deserializes an em', () => {
|
|
25
|
+
const out = deserialize(`<!-- hi --><div> <em>x</em> </div>`);
|
|
26
|
+
expect(out.document.nodes[0]).toEqual(
|
|
27
|
+
expect.objectContaining({
|
|
28
|
+
type: 'div',
|
|
29
|
+
nodes: [
|
|
30
|
+
expect.objectContaining({
|
|
31
|
+
object: 'text',
|
|
32
|
+
}),
|
|
33
|
+
expect.objectContaining({
|
|
34
|
+
leaves: [
|
|
35
|
+
{
|
|
36
|
+
marks: [
|
|
37
|
+
{
|
|
38
|
+
data: undefined,
|
|
39
|
+
type: 'italic',
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
text: 'x',
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
object: 'text',
|
|
46
|
+
}),
|
|
47
|
+
expect.objectContaining({
|
|
48
|
+
object: 'text',
|
|
49
|
+
}),
|
|
50
|
+
],
|
|
51
|
+
}),
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const choice = (v, id) => ({ label: v, value: v, id });
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { shallow } from 'enzyme';
|
|
3
|
+
import { withMask } from '../with-mask';
|
|
4
|
+
|
|
5
|
+
describe('WithMask', () => {
|
|
6
|
+
const onChange = jest.fn();
|
|
7
|
+
const defaultProps = {
|
|
8
|
+
markup: '<p>Foo bar {{0}} over the moon;</p>',
|
|
9
|
+
value: {
|
|
10
|
+
0: 'blank',
|
|
11
|
+
},
|
|
12
|
+
onChange,
|
|
13
|
+
};
|
|
14
|
+
const Masked = withMask('foo', (props) => (node) => {
|
|
15
|
+
const dataset = node.data ? node.data.dataset || {} : {};
|
|
16
|
+
|
|
17
|
+
if (dataset.component === 'foo') {
|
|
18
|
+
return <input type="text" value="Foo" />;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
let wrapper;
|
|
23
|
+
|
|
24
|
+
beforeEach(() => {
|
|
25
|
+
wrapper = shallow(<Masked {...defaultProps} />);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe('render', () => {
|
|
29
|
+
it('renders correctly with default props', () => {
|
|
30
|
+
expect(wrapper).toMatchSnapshot();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('onChange', () => {
|
|
35
|
+
const event = (value) => ({
|
|
36
|
+
target: { value },
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('should call the function', () => {
|
|
40
|
+
const e = event('ceva');
|
|
41
|
+
|
|
42
|
+
wrapper.simulate('change', e);
|
|
43
|
+
|
|
44
|
+
expect(onChange).toHaveBeenCalledWith({
|
|
45
|
+
target: {
|
|
46
|
+
value: 'ceva',
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`index Choice render renders correctly with default props 1`] = `
|
|
4
|
+
<BlankContentComp
|
|
5
|
+
classes={
|
|
6
|
+
Object {
|
|
7
|
+
"chip": "BlankContentComp-chip-2",
|
|
8
|
+
"chipLabel": "BlankContentComp-chipLabel-3",
|
|
9
|
+
"choice": "BlankContentComp-choice-1",
|
|
10
|
+
"disabled": "BlankContentComp-disabled-4",
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
disabled={false}
|
|
14
|
+
label="Label"
|
|
15
|
+
targetId="1"
|
|
16
|
+
value="1"
|
|
17
|
+
/>
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
exports[`index Choice render renders correctly with disabled prop as true 1`] = `
|
|
21
|
+
<BlankContentComp
|
|
22
|
+
classes={
|
|
23
|
+
Object {
|
|
24
|
+
"chip": "BlankContentComp-chip-2",
|
|
25
|
+
"chipLabel": "BlankContentComp-chipLabel-3",
|
|
26
|
+
"choice": "BlankContentComp-choice-1",
|
|
27
|
+
"disabled": "BlankContentComp-disabled-4",
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
disabled={true}
|
|
31
|
+
label="Label"
|
|
32
|
+
targetId="1"
|
|
33
|
+
value="1"
|
|
34
|
+
/>
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
exports[`index Choices renders correctly with default props 1`] = `
|
|
38
|
+
<div
|
|
39
|
+
style={
|
|
40
|
+
Object {
|
|
41
|
+
"margin": "0 40px 0 0",
|
|
42
|
+
"minWidth": "100px",
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
>
|
|
46
|
+
<DropTarget(DroppablePlaceholder)
|
|
47
|
+
disabled={false}
|
|
48
|
+
>
|
|
49
|
+
<DragSource(WithStyles(BlankContentComp))
|
|
50
|
+
choice={
|
|
51
|
+
Object {
|
|
52
|
+
"id": "0",
|
|
53
|
+
"label": "Jumped",
|
|
54
|
+
"value": "Jumped",
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
disabled={false}
|
|
58
|
+
key="Jumped-0"
|
|
59
|
+
/>
|
|
60
|
+
<DragSource(WithStyles(BlankContentComp))
|
|
61
|
+
choice={
|
|
62
|
+
Object {
|
|
63
|
+
"id": "1",
|
|
64
|
+
"label": "Laughed",
|
|
65
|
+
"value": "Laughed",
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
disabled={false}
|
|
69
|
+
key="Laughed-1"
|
|
70
|
+
/>
|
|
71
|
+
<DragSource(WithStyles(BlankContentComp))
|
|
72
|
+
choice={
|
|
73
|
+
Object {
|
|
74
|
+
"id": "2",
|
|
75
|
+
"label": "Spoon",
|
|
76
|
+
"value": "Spoon",
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
disabled={false}
|
|
80
|
+
key="Spoon-2"
|
|
81
|
+
/>
|
|
82
|
+
</DropTarget(DroppablePlaceholder)>
|
|
83
|
+
</div>
|
|
84
|
+
`;
|
|
85
|
+
|
|
86
|
+
exports[`index Choices renders correctly with disabled prop as true 1`] = `
|
|
87
|
+
<div
|
|
88
|
+
style={
|
|
89
|
+
Object {
|
|
90
|
+
"margin": "0 40px 0 0",
|
|
91
|
+
"minWidth": "100px",
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
>
|
|
95
|
+
<DropTarget(DroppablePlaceholder)
|
|
96
|
+
disabled={true}
|
|
97
|
+
>
|
|
98
|
+
<DragSource(WithStyles(BlankContentComp))
|
|
99
|
+
choice={
|
|
100
|
+
Object {
|
|
101
|
+
"id": "0",
|
|
102
|
+
"label": "Jumped",
|
|
103
|
+
"value": "Jumped",
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
disabled={true}
|
|
107
|
+
key="Jumped-0"
|
|
108
|
+
/>
|
|
109
|
+
<DragSource(WithStyles(BlankContentComp))
|
|
110
|
+
choice={
|
|
111
|
+
Object {
|
|
112
|
+
"id": "1",
|
|
113
|
+
"label": "Laughed",
|
|
114
|
+
"value": "Laughed",
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
disabled={true}
|
|
118
|
+
key="Laughed-1"
|
|
119
|
+
/>
|
|
120
|
+
<DragSource(WithStyles(BlankContentComp))
|
|
121
|
+
choice={
|
|
122
|
+
Object {
|
|
123
|
+
"id": "2",
|
|
124
|
+
"label": "Spoon",
|
|
125
|
+
"value": "Spoon",
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
disabled={true}
|
|
129
|
+
key="Spoon-2"
|
|
130
|
+
/>
|
|
131
|
+
</DropTarget(DroppablePlaceholder)>
|
|
132
|
+
</div>
|
|
133
|
+
`;
|
|
134
|
+
|
|
135
|
+
exports[`index Choices renders with duplicates 1`] = `
|
|
136
|
+
<div
|
|
137
|
+
style={
|
|
138
|
+
Object {
|
|
139
|
+
"margin": "0 40px 0 0",
|
|
140
|
+
"minWidth": "100px",
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
>
|
|
144
|
+
<DropTarget(DroppablePlaceholder)
|
|
145
|
+
disabled={false}
|
|
146
|
+
>
|
|
147
|
+
<DragSource(WithStyles(BlankContentComp))
|
|
148
|
+
choice={
|
|
149
|
+
Object {
|
|
150
|
+
"id": "0",
|
|
151
|
+
"label": "Jumped",
|
|
152
|
+
"value": "Jumped",
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
disabled={false}
|
|
156
|
+
key="Jumped-0"
|
|
157
|
+
/>
|
|
158
|
+
<DragSource(WithStyles(BlankContentComp))
|
|
159
|
+
choice={
|
|
160
|
+
Object {
|
|
161
|
+
"id": "1",
|
|
162
|
+
"label": "Laughed",
|
|
163
|
+
"value": "Laughed",
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
disabled={false}
|
|
167
|
+
key="Laughed-1"
|
|
168
|
+
/>
|
|
169
|
+
<DragSource(WithStyles(BlankContentComp))
|
|
170
|
+
choice={
|
|
171
|
+
Object {
|
|
172
|
+
"id": "2",
|
|
173
|
+
"label": "Spoon",
|
|
174
|
+
"value": "Spoon",
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
disabled={false}
|
|
178
|
+
key="Spoon-2"
|
|
179
|
+
/>
|
|
180
|
+
</DropTarget(DroppablePlaceholder)>
|
|
181
|
+
</div>
|
|
182
|
+
`;
|
|
183
|
+
|
|
184
|
+
exports[`index Choices renders without duplicates 1`] = `
|
|
185
|
+
<div
|
|
186
|
+
style={
|
|
187
|
+
Object {
|
|
188
|
+
"margin": "0 40px 0 0",
|
|
189
|
+
"minWidth": "100px",
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
>
|
|
193
|
+
<DropTarget(DroppablePlaceholder)
|
|
194
|
+
disabled={false}
|
|
195
|
+
>
|
|
196
|
+
<DragSource(WithStyles(BlankContentComp))
|
|
197
|
+
choice={
|
|
198
|
+
Object {
|
|
199
|
+
"id": "2",
|
|
200
|
+
"label": "Spoon",
|
|
201
|
+
"value": "Spoon",
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
disabled={false}
|
|
205
|
+
key="Spoon-0"
|
|
206
|
+
/>
|
|
207
|
+
</DropTarget(DroppablePlaceholder)>
|
|
208
|
+
</div>
|
|
209
|
+
`;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { shallow } from 'enzyme';
|
|
3
|
+
import { BlankContent as Choice } from '../choice';
|
|
4
|
+
import { choice } from '../../__tests__/utils';
|
|
5
|
+
import Choices from '../index';
|
|
6
|
+
|
|
7
|
+
describe('index', () => {
|
|
8
|
+
describe('Choices', () => {
|
|
9
|
+
const defaultProps = {
|
|
10
|
+
disabled: false,
|
|
11
|
+
choices: [choice('Jumped', '0'), choice('Laughed', '1'), choice('Spoon', '2')],
|
|
12
|
+
};
|
|
13
|
+
let wrapper;
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
wrapper = shallow(<Choices {...defaultProps} />);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('renders correctly with default props', () => {
|
|
20
|
+
expect(wrapper).toMatchSnapshot();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('renders correctly with disabled prop as true', () => {
|
|
24
|
+
wrapper.setProps({ disabled: true });
|
|
25
|
+
expect(wrapper).toMatchSnapshot();
|
|
26
|
+
});
|
|
27
|
+
it('renders without duplicates', () => {
|
|
28
|
+
wrapper.setProps({ duplicates: undefined, value: { 0: '0', 1: '1' } });
|
|
29
|
+
expect(wrapper).toMatchSnapshot();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('renders with duplicates', () => {
|
|
33
|
+
wrapper.setProps({ duplicates: true, value: { 0: '0', 1: '1' } });
|
|
34
|
+
expect(wrapper).toMatchSnapshot();
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe('Choice', () => {
|
|
39
|
+
const defaultProps = {
|
|
40
|
+
disabled: false,
|
|
41
|
+
value: '1',
|
|
42
|
+
label: 'Label',
|
|
43
|
+
targetId: '1',
|
|
44
|
+
};
|
|
45
|
+
let wrapper;
|
|
46
|
+
|
|
47
|
+
beforeEach(() => {
|
|
48
|
+
wrapper = shallow(<Choice {...defaultProps} />);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe('render', () => {
|
|
52
|
+
it('renders correctly with default props', () => {
|
|
53
|
+
expect(wrapper).toMatchSnapshot();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('renders correctly with disabled prop as true', () => {
|
|
57
|
+
wrapper.setProps({ disabled: true });
|
|
58
|
+
expect(wrapper).toMatchSnapshot();
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
});
|