Skip to content
This repository was archived by the owner on Feb 6, 2023. It is now read-only.

Commit 2d7ad18

Browse files
flarniefacebook-github-bot
authored andcommitted
Regression test for bug with nested block and deleting
Summary: This is a regression test for https://our.intern.facebook.com/intern/diff/D9129494/ Reviewed By: niveditc, mitermayer Differential Revision: D9150680 fbshipit-source-id: 6f94a2f5699577fe9abdba16c3af62c5ed0e606d
1 parent e98e91e commit 2d7ad18

File tree

2 files changed

+212
-0
lines changed

2 files changed

+212
-0
lines changed

src/model/transaction/__tests__/__snapshots__/removeRangeFromContentState-test.js.snap

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,203 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`must merge D and E when deleting range from end of D to start of E 1`] = `
4+
Object {
5+
"A": Object {
6+
"characterList": Array [
7+
Object {
8+
"entity": null,
9+
"style": Array [],
10+
},
11+
Object {
12+
"entity": null,
13+
"style": Array [],
14+
},
15+
Object {
16+
"entity": null,
17+
"style": Array [],
18+
},
19+
Object {
20+
"entity": null,
21+
"style": Array [],
22+
},
23+
Object {
24+
"entity": null,
25+
"style": Array [],
26+
},
27+
],
28+
"children": Array [],
29+
"data": Object {},
30+
"depth": 0,
31+
"key": "A",
32+
"nextSibling": "B",
33+
"parent": null,
34+
"prevSibling": null,
35+
"text": "Alpha",
36+
"type": "unstyled",
37+
},
38+
"B": Object {
39+
"characterList": Array [],
40+
"children": Array [
41+
"C",
42+
"F",
43+
],
44+
"data": Object {},
45+
"depth": 0,
46+
"key": "B",
47+
"nextSibling": "G",
48+
"parent": null,
49+
"prevSibling": "A",
50+
"text": "",
51+
"type": "unstyled",
52+
},
53+
"C": Object {
54+
"characterList": Array [],
55+
"children": Array [
56+
"D",
57+
],
58+
"data": Object {},
59+
"depth": 0,
60+
"key": "C",
61+
"nextSibling": "F",
62+
"parent": "B",
63+
"prevSibling": null,
64+
"text": "",
65+
"type": "unstyled",
66+
},
67+
"D": Object {
68+
"characterList": Array [
69+
Object {
70+
"entity": null,
71+
"style": Array [],
72+
},
73+
Object {
74+
"entity": null,
75+
"style": Array [],
76+
},
77+
Object {
78+
"entity": null,
79+
"style": Array [],
80+
},
81+
Object {
82+
"entity": null,
83+
"style": Array [],
84+
},
85+
Object {
86+
"entity": null,
87+
"style": Array [],
88+
},
89+
Object {
90+
"entity": null,
91+
"style": Array [],
92+
},
93+
Object {
94+
"entity": null,
95+
"style": Array [],
96+
},
97+
Object {
98+
"entity": null,
99+
"style": Array [],
100+
},
101+
Object {
102+
"entity": null,
103+
"style": Array [],
104+
},
105+
Object {
106+
"entity": null,
107+
"style": Array [],
108+
},
109+
Object {
110+
"entity": null,
111+
"style": Array [],
112+
},
113+
Object {
114+
"entity": null,
115+
"style": Array [],
116+
},
117+
Object {
118+
"entity": null,
119+
"style": Array [],
120+
},
121+
],
122+
"children": Array [],
123+
"data": Object {},
124+
"depth": 0,
125+
"key": "D",
126+
"nextSibling": null,
127+
"parent": "C",
128+
"prevSibling": null,
129+
"text": "DeltaElephant",
130+
"type": "unstyled",
131+
},
132+
"F": Object {
133+
"characterList": Array [
134+
Object {
135+
"entity": null,
136+
"style": Array [],
137+
},
138+
Object {
139+
"entity": null,
140+
"style": Array [],
141+
},
142+
Object {
143+
"entity": null,
144+
"style": Array [],
145+
},
146+
Object {
147+
"entity": null,
148+
"style": Array [],
149+
},
150+
],
151+
"children": Array [],
152+
"data": Object {},
153+
"depth": 0,
154+
"key": "F",
155+
"nextSibling": null,
156+
"parent": "B",
157+
"prevSibling": "C",
158+
"text": "Fire",
159+
"type": "unstyled",
160+
},
161+
"G": Object {
162+
"characterList": Array [
163+
Object {
164+
"entity": null,
165+
"style": Array [],
166+
},
167+
Object {
168+
"entity": null,
169+
"style": Array [],
170+
},
171+
Object {
172+
"entity": null,
173+
"style": Array [],
174+
},
175+
Object {
176+
"entity": null,
177+
"style": Array [],
178+
},
179+
Object {
180+
"entity": null,
181+
"style": Array [],
182+
},
183+
Object {
184+
"entity": null,
185+
"style": Array [],
186+
},
187+
],
188+
"children": Array [],
189+
"data": Object {},
190+
"depth": 0,
191+
"key": "G",
192+
"nextSibling": null,
193+
"parent": null,
194+
"prevSibling": "B",
195+
"text": "Gorila",
196+
"type": "unstyled",
197+
},
198+
}
199+
`;
200+
3201
exports[`must preserve B and C since E has not been removed 1`] = `
4202
Object {
5203
"A": Object {

src/model/transaction/__tests__/removeRangeFromContentState-test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,3 +261,17 @@ test('must retain B since F has not been removed', () => {
261261
treeContentState,
262262
);
263263
});
264+
265+
// Simulates having collapsed selection at start of Elephant and hitting backspace
266+
// We expect Elephant will be merged with previous block, Delta
267+
test('must merge D and E when deleting range from end of D to start of E', () => {
268+
assertRemoveRangeFromContentState(
269+
treeSelectionState.merge({
270+
anchorKey: 'D',
271+
focusKey: 'E',
272+
anchorOffset: contentBlockNodes[3].getLength(), // end of D
273+
focusOffset: 0, // start of E
274+
}),
275+
treeContentState,
276+
);
277+
});

0 commit comments

Comments
 (0)