Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit 522a5bc

Browse files
committed
Fix tests
1 parent 4e314bd commit 522a5bc

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

src/modifiers/__test__/handleNewCodeBlock-test.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ import sinon from "sinon";
22
import Draft, { EditorState, SelectionState } from "draft-js";
33
import handleNewCodeBlock from "../handleNewCodeBlock";
44

5+
const removeBlockKeys = rawContentState => {
6+
return {
7+
...rawContentState,
8+
blocks: rawContentState.blocks.map(block => {
9+
delete block.key;
10+
return block;
11+
}),
12+
};
13+
};
14+
515
describe("handleNewCodeBlock", () => {
616
describe("in unstyled block with three backquotes", () => {
717
const testNewCodeBlock = (text, data) => () => {
@@ -23,14 +33,21 @@ describe("handleNewCodeBlock", () => {
2333
entityMap: {},
2434
blocks: [
2535
{
26-
key: "item1",
2736
text: "",
2837
type: "code-block",
2938
depth: 0,
3039
inlineStyleRanges: [],
3140
entityRanges: [],
3241
data,
3342
},
43+
{
44+
text: "",
45+
type: "unstyled",
46+
inlineStyleRanges: [],
47+
entityRanges: [],
48+
data: {},
49+
depth: 0,
50+
},
3451
],
3552
};
3653
const contentState = Draft.convertFromRaw(beforeRawContentState);
@@ -49,9 +66,11 @@ describe("handleNewCodeBlock", () => {
4966
it("creates new code block", () => {
5067
const newEditorState = handleNewCodeBlock(editorState);
5168
expect(newEditorState).not.toEqual(editorState);
52-
expect(Draft.convertToRaw(newEditorState.getCurrentContent())).toEqual(
53-
afterRawContentState
54-
);
69+
expect(
70+
removeBlockKeys(
71+
Draft.convertToRaw(newEditorState.getCurrentContent())
72+
)
73+
).toEqual(removeBlockKeys(afterRawContentState));
5574
});
5675
};
5776

0 commit comments

Comments
 (0)