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

Commit

Permalink
Regression test for bug with nested block and deleting
Browse files Browse the repository at this point in the history
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
  • Loading branch information
flarnie authored and facebook-github-bot committed Aug 7, 2018
1 parent e98e91e commit 2d7ad18
Show file tree
Hide file tree
Showing 2 changed files with 212 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,203 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`must merge D and E when deleting range from end of D to start of E 1`] = `
Object {
"A": Object {
"characterList": Array [
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "A",
"nextSibling": "B",
"parent": null,
"prevSibling": null,
"text": "Alpha",
"type": "unstyled",
},
"B": Object {
"characterList": Array [],
"children": Array [
"C",
"F",
],
"data": Object {},
"depth": 0,
"key": "B",
"nextSibling": "G",
"parent": null,
"prevSibling": "A",
"text": "",
"type": "unstyled",
},
"C": Object {
"characterList": Array [],
"children": Array [
"D",
],
"data": Object {},
"depth": 0,
"key": "C",
"nextSibling": "F",
"parent": "B",
"prevSibling": null,
"text": "",
"type": "unstyled",
},
"D": Object {
"characterList": Array [
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "D",
"nextSibling": null,
"parent": "C",
"prevSibling": null,
"text": "DeltaElephant",
"type": "unstyled",
},
"F": Object {
"characterList": Array [
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "F",
"nextSibling": null,
"parent": "B",
"prevSibling": "C",
"text": "Fire",
"type": "unstyled",
},
"G": Object {
"characterList": Array [
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "G",
"nextSibling": null,
"parent": null,
"prevSibling": "B",
"text": "Gorila",
"type": "unstyled",
},
}
`;

exports[`must preserve B and C since E has not been removed 1`] = `
Object {
"A": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,17 @@ test('must retain B since F has not been removed', () => {
treeContentState,
);
});

// Simulates having collapsed selection at start of Elephant and hitting backspace
// We expect Elephant will be merged with previous block, Delta
test('must merge D and E when deleting range from end of D to start of E', () => {
assertRemoveRangeFromContentState(
treeSelectionState.merge({
anchorKey: 'D',
focusKey: 'E',
anchorOffset: contentBlockNodes[3].getLength(), // end of D
focusOffset: 0, // start of E
}),
treeContentState,
);
});

0 comments on commit 2d7ad18

Please sign in to comment.