@pie-lib/mask-markup 1.13.47-next.1 → 1.14.0-beta.1
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/lib/choices/choice.js +80 -17
- package/lib/choices/choice.js.map +1 -1
- package/lib/choices/index.js +11 -3
- package/lib/choices/index.js.map +1 -1
- package/lib/components/blank.js +146 -34
- package/lib/components/blank.js.map +1 -1
- package/lib/components/correct-input.js +8 -3
- package/lib/components/correct-input.js.map +1 -1
- package/lib/components/dropdown.js +182 -49
- package/lib/components/dropdown.js.map +1 -1
- package/lib/constructed-response.js +87 -23
- package/lib/constructed-response.js.map +1 -1
- package/lib/customizable.js +48 -0
- package/lib/customizable.js.map +1 -0
- package/lib/drag-in-the-blank.js +34 -8
- package/lib/drag-in-the-blank.js.map +1 -1
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -1
- package/lib/inline-dropdown.js +3 -1
- package/lib/inline-dropdown.js.map +1 -1
- package/lib/mask.js +45 -6
- package/lib/mask.js.map +1 -1
- package/lib/with-mask.js +34 -2
- package/lib/with-mask.js.map +1 -1
- 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
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`DragInTheBlank render renders correctly with default props 1`] = `
|
|
4
|
+
<div
|
|
5
|
+
style={
|
|
6
|
+
Object {
|
|
7
|
+
"alignItems": undefined,
|
|
8
|
+
"display": "flex",
|
|
9
|
+
"flexDirection": "column-reverse",
|
|
10
|
+
"justifyContent": undefined,
|
|
11
|
+
"minWidth": "100px",
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
>
|
|
15
|
+
<Choices
|
|
16
|
+
choicePosition="below"
|
|
17
|
+
choices={
|
|
18
|
+
Array [
|
|
19
|
+
Object {
|
|
20
|
+
"id": "0",
|
|
21
|
+
"value": "Jumped",
|
|
22
|
+
},
|
|
23
|
+
Object {
|
|
24
|
+
"id": "1",
|
|
25
|
+
"value": "Laughed",
|
|
26
|
+
},
|
|
27
|
+
Object {
|
|
28
|
+
"id": "2",
|
|
29
|
+
"value": "Spoon",
|
|
30
|
+
},
|
|
31
|
+
Object {
|
|
32
|
+
"id": "3",
|
|
33
|
+
"value": "Fork",
|
|
34
|
+
},
|
|
35
|
+
Object {
|
|
36
|
+
"id": "4",
|
|
37
|
+
"value": "Bumped",
|
|
38
|
+
},
|
|
39
|
+
Object {
|
|
40
|
+
"id": "5",
|
|
41
|
+
"value": "Smiled",
|
|
42
|
+
},
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
disabled={false}
|
|
46
|
+
value={
|
|
47
|
+
Object {
|
|
48
|
+
"0": undefined,
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/>
|
|
52
|
+
<WithMask
|
|
53
|
+
choices={
|
|
54
|
+
Array [
|
|
55
|
+
Object {
|
|
56
|
+
"id": "0",
|
|
57
|
+
"value": "Jumped",
|
|
58
|
+
},
|
|
59
|
+
Object {
|
|
60
|
+
"id": "1",
|
|
61
|
+
"value": "Laughed",
|
|
62
|
+
},
|
|
63
|
+
Object {
|
|
64
|
+
"id": "2",
|
|
65
|
+
"value": "Spoon",
|
|
66
|
+
},
|
|
67
|
+
Object {
|
|
68
|
+
"id": "3",
|
|
69
|
+
"value": "Fork",
|
|
70
|
+
},
|
|
71
|
+
Object {
|
|
72
|
+
"id": "4",
|
|
73
|
+
"value": "Bumped",
|
|
74
|
+
},
|
|
75
|
+
Object {
|
|
76
|
+
"id": "5",
|
|
77
|
+
"value": "Smiled",
|
|
78
|
+
},
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
disabled={false}
|
|
82
|
+
elementType="drag-in-the-blank"
|
|
83
|
+
feedback={Object {}}
|
|
84
|
+
markup="<div>
|
|
85
|
+
<img src=\\"https://image.shutterstock.com/image-vector/cow-jumped-over-moon-traditional-260nw-1152899330.jpg\\"></img>
|
|
86
|
+
<h5>Hey Diddle Diddle <i>by ?</i></h5>
|
|
87
|
+
<p>1: Hey, diddle, diddle,</p>
|
|
88
|
+
<p>2: The cat and the fiddle,</p>
|
|
89
|
+
<p>3: The cow {{0}} over the moon;</p>
|
|
90
|
+
<p>4: The little dog {{1}},</p>
|
|
91
|
+
<p>5: To see such sport,</p>
|
|
92
|
+
<p>6: And the dish ran away with the {{2}}.</p>
|
|
93
|
+
</div>"
|
|
94
|
+
value={
|
|
95
|
+
Object {
|
|
96
|
+
"0": undefined,
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/>
|
|
100
|
+
</div>
|
|
101
|
+
`;
|
|
102
|
+
|
|
103
|
+
exports[`DragInTheBlank render renders correctly with disabled prop as true 1`] = `
|
|
104
|
+
<div
|
|
105
|
+
style={
|
|
106
|
+
Object {
|
|
107
|
+
"alignItems": undefined,
|
|
108
|
+
"display": "flex",
|
|
109
|
+
"flexDirection": "column-reverse",
|
|
110
|
+
"justifyContent": undefined,
|
|
111
|
+
"minWidth": "100px",
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
>
|
|
115
|
+
<Choices
|
|
116
|
+
choicePosition="below"
|
|
117
|
+
choices={
|
|
118
|
+
Array [
|
|
119
|
+
Object {
|
|
120
|
+
"id": "0",
|
|
121
|
+
"value": "Jumped",
|
|
122
|
+
},
|
|
123
|
+
Object {
|
|
124
|
+
"id": "1",
|
|
125
|
+
"value": "Laughed",
|
|
126
|
+
},
|
|
127
|
+
Object {
|
|
128
|
+
"id": "2",
|
|
129
|
+
"value": "Spoon",
|
|
130
|
+
},
|
|
131
|
+
Object {
|
|
132
|
+
"id": "3",
|
|
133
|
+
"value": "Fork",
|
|
134
|
+
},
|
|
135
|
+
Object {
|
|
136
|
+
"id": "4",
|
|
137
|
+
"value": "Bumped",
|
|
138
|
+
},
|
|
139
|
+
Object {
|
|
140
|
+
"id": "5",
|
|
141
|
+
"value": "Smiled",
|
|
142
|
+
},
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
disabled={true}
|
|
146
|
+
value={
|
|
147
|
+
Object {
|
|
148
|
+
"0": undefined,
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/>
|
|
152
|
+
<WithMask
|
|
153
|
+
choices={
|
|
154
|
+
Array [
|
|
155
|
+
Object {
|
|
156
|
+
"id": "0",
|
|
157
|
+
"value": "Jumped",
|
|
158
|
+
},
|
|
159
|
+
Object {
|
|
160
|
+
"id": "1",
|
|
161
|
+
"value": "Laughed",
|
|
162
|
+
},
|
|
163
|
+
Object {
|
|
164
|
+
"id": "2",
|
|
165
|
+
"value": "Spoon",
|
|
166
|
+
},
|
|
167
|
+
Object {
|
|
168
|
+
"id": "3",
|
|
169
|
+
"value": "Fork",
|
|
170
|
+
},
|
|
171
|
+
Object {
|
|
172
|
+
"id": "4",
|
|
173
|
+
"value": "Bumped",
|
|
174
|
+
},
|
|
175
|
+
Object {
|
|
176
|
+
"id": "5",
|
|
177
|
+
"value": "Smiled",
|
|
178
|
+
},
|
|
179
|
+
]
|
|
180
|
+
}
|
|
181
|
+
disabled={true}
|
|
182
|
+
elementType="drag-in-the-blank"
|
|
183
|
+
feedback={Object {}}
|
|
184
|
+
markup="<div>
|
|
185
|
+
<img src=\\"https://image.shutterstock.com/image-vector/cow-jumped-over-moon-traditional-260nw-1152899330.jpg\\"></img>
|
|
186
|
+
<h5>Hey Diddle Diddle <i>by ?</i></h5>
|
|
187
|
+
<p>1: Hey, diddle, diddle,</p>
|
|
188
|
+
<p>2: The cat and the fiddle,</p>
|
|
189
|
+
<p>3: The cow {{0}} over the moon;</p>
|
|
190
|
+
<p>4: The little dog {{1}},</p>
|
|
191
|
+
<p>5: To see such sport,</p>
|
|
192
|
+
<p>6: And the dish ran away with the {{2}}.</p>
|
|
193
|
+
</div>"
|
|
194
|
+
value={
|
|
195
|
+
Object {
|
|
196
|
+
"0": undefined,
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/>
|
|
200
|
+
</div>
|
|
201
|
+
`;
|
|
202
|
+
|
|
203
|
+
exports[`DragInTheBlank render renders correctly with feedback 1`] = `
|
|
204
|
+
<div
|
|
205
|
+
style={
|
|
206
|
+
Object {
|
|
207
|
+
"alignItems": undefined,
|
|
208
|
+
"display": "flex",
|
|
209
|
+
"flexDirection": "column-reverse",
|
|
210
|
+
"justifyContent": undefined,
|
|
211
|
+
"minWidth": "100px",
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
>
|
|
215
|
+
<Choices
|
|
216
|
+
choicePosition="below"
|
|
217
|
+
choices={
|
|
218
|
+
Array [
|
|
219
|
+
Object {
|
|
220
|
+
"id": "0",
|
|
221
|
+
"value": "Jumped",
|
|
222
|
+
},
|
|
223
|
+
Object {
|
|
224
|
+
"id": "1",
|
|
225
|
+
"value": "Laughed",
|
|
226
|
+
},
|
|
227
|
+
Object {
|
|
228
|
+
"id": "2",
|
|
229
|
+
"value": "Spoon",
|
|
230
|
+
},
|
|
231
|
+
Object {
|
|
232
|
+
"id": "3",
|
|
233
|
+
"value": "Fork",
|
|
234
|
+
},
|
|
235
|
+
Object {
|
|
236
|
+
"id": "4",
|
|
237
|
+
"value": "Bumped",
|
|
238
|
+
},
|
|
239
|
+
Object {
|
|
240
|
+
"id": "5",
|
|
241
|
+
"value": "Smiled",
|
|
242
|
+
},
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
disabled={false}
|
|
246
|
+
value={
|
|
247
|
+
Object {
|
|
248
|
+
"0": undefined,
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
/>
|
|
252
|
+
<WithMask
|
|
253
|
+
choices={
|
|
254
|
+
Array [
|
|
255
|
+
Object {
|
|
256
|
+
"id": "0",
|
|
257
|
+
"value": "Jumped",
|
|
258
|
+
},
|
|
259
|
+
Object {
|
|
260
|
+
"id": "1",
|
|
261
|
+
"value": "Laughed",
|
|
262
|
+
},
|
|
263
|
+
Object {
|
|
264
|
+
"id": "2",
|
|
265
|
+
"value": "Spoon",
|
|
266
|
+
},
|
|
267
|
+
Object {
|
|
268
|
+
"id": "3",
|
|
269
|
+
"value": "Fork",
|
|
270
|
+
},
|
|
271
|
+
Object {
|
|
272
|
+
"id": "4",
|
|
273
|
+
"value": "Bumped",
|
|
274
|
+
},
|
|
275
|
+
Object {
|
|
276
|
+
"id": "5",
|
|
277
|
+
"value": "Smiled",
|
|
278
|
+
},
|
|
279
|
+
]
|
|
280
|
+
}
|
|
281
|
+
disabled={false}
|
|
282
|
+
elementType="drag-in-the-blank"
|
|
283
|
+
feedback={
|
|
284
|
+
Object {
|
|
285
|
+
"0": Object {
|
|
286
|
+
"correct": "Jumped",
|
|
287
|
+
"value": "Jumped",
|
|
288
|
+
},
|
|
289
|
+
"1": Object {
|
|
290
|
+
"correct": "Laughed",
|
|
291
|
+
"value": "Laughed",
|
|
292
|
+
},
|
|
293
|
+
"2": Object {
|
|
294
|
+
"correct": "Spoon",
|
|
295
|
+
"value": "Spoon",
|
|
296
|
+
},
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
markup="<div>
|
|
300
|
+
<img src=\\"https://image.shutterstock.com/image-vector/cow-jumped-over-moon-traditional-260nw-1152899330.jpg\\"></img>
|
|
301
|
+
<h5>Hey Diddle Diddle <i>by ?</i></h5>
|
|
302
|
+
<p>1: Hey, diddle, diddle,</p>
|
|
303
|
+
<p>2: The cat and the fiddle,</p>
|
|
304
|
+
<p>3: The cow {{0}} over the moon;</p>
|
|
305
|
+
<p>4: The little dog {{1}},</p>
|
|
306
|
+
<p>5: To see such sport,</p>
|
|
307
|
+
<p>6: And the dish ran away with the {{2}}.</p>
|
|
308
|
+
</div>"
|
|
309
|
+
value={
|
|
310
|
+
Object {
|
|
311
|
+
"0": undefined,
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
/>
|
|
315
|
+
</div>
|
|
316
|
+
`;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Mask render renders correctly a div 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<div
|
|
6
|
+
key="div-0"
|
|
7
|
+
>
|
|
8
|
+
<WithStyles(Component)
|
|
9
|
+
key="p-0"
|
|
10
|
+
>
|
|
11
|
+
Foo
|
|
12
|
+
</WithStyles(Component)>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
exports[`Mask render renders correctly a em 1`] = `
|
|
18
|
+
<WithStyles(Component)>
|
|
19
|
+
Foo
|
|
20
|
+
<em
|
|
21
|
+
key="1"
|
|
22
|
+
>
|
|
23
|
+
x
|
|
24
|
+
</em>
|
|
25
|
+
bar
|
|
26
|
+
</WithStyles(Component)>
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
exports[`Mask render renders correctly a paragraph 1`] = `
|
|
30
|
+
<div>
|
|
31
|
+
<WithStyles(Component)
|
|
32
|
+
key="p-0"
|
|
33
|
+
>
|
|
34
|
+
Foo
|
|
35
|
+
</WithStyles(Component)>
|
|
36
|
+
</div>
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
exports[`Mask render renders correctly with default props 1`] = `
|
|
40
|
+
<div>
|
|
41
|
+
Foo
|
|
42
|
+
</div>
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
exports[`Mask render renders without space under tbody 1`] = `
|
|
46
|
+
<div>
|
|
47
|
+
<tbody
|
|
48
|
+
key="tbody-0"
|
|
49
|
+
>
|
|
50
|
+
<tr
|
|
51
|
+
key="tr-1"
|
|
52
|
+
/>
|
|
53
|
+
</tbody>
|
|
54
|
+
</div>
|
|
55
|
+
`;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`WithMask render renders correctly with default props 1`] = `
|
|
4
|
+
<Mask
|
|
5
|
+
layout={
|
|
6
|
+
Object {
|
|
7
|
+
"data": Object {},
|
|
8
|
+
"nodes": Array [
|
|
9
|
+
Object {
|
|
10
|
+
"data": Object {
|
|
11
|
+
"attributes": Object {},
|
|
12
|
+
"dataset": Object {},
|
|
13
|
+
},
|
|
14
|
+
"nodes": Array [
|
|
15
|
+
Object {
|
|
16
|
+
"leaves": Array [
|
|
17
|
+
Object {
|
|
18
|
+
"text": "Foo bar ",
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
"object": "text",
|
|
22
|
+
},
|
|
23
|
+
Object {
|
|
24
|
+
"data": Object {
|
|
25
|
+
"attributes": Object {
|
|
26
|
+
"data-component": "foo",
|
|
27
|
+
"data-id": "0",
|
|
28
|
+
},
|
|
29
|
+
"dataset": Object {
|
|
30
|
+
"component": "foo",
|
|
31
|
+
"id": "0",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
"nodes": Array [],
|
|
35
|
+
"object": "inline",
|
|
36
|
+
"type": "span",
|
|
37
|
+
},
|
|
38
|
+
Object {
|
|
39
|
+
"leaves": Array [
|
|
40
|
+
Object {
|
|
41
|
+
"text": " over the moon;",
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
"object": "text",
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
"object": "block",
|
|
48
|
+
"type": "p",
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
"object": "document",
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
onChange={[MockFunction]}
|
|
55
|
+
renderChildren={[Function]}
|
|
56
|
+
value={
|
|
57
|
+
Object {
|
|
58
|
+
"0": "blank",
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/>
|
|
62
|
+
`;
|
|
@@ -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
|
+
});
|