This repository was archived by the owner on Oct 11, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +23
-4
lines changed Expand file tree Collapse file tree 1 file changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,16 @@ import sinon from "sinon";
2
2
import Draft , { EditorState , SelectionState } from "draft-js" ;
3
3
import handleNewCodeBlock from "../handleNewCodeBlock" ;
4
4
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
+
5
15
describe ( "handleNewCodeBlock" , ( ) => {
6
16
describe ( "in unstyled block with three backquotes" , ( ) => {
7
17
const testNewCodeBlock = ( text , data ) => ( ) => {
@@ -23,14 +33,21 @@ describe("handleNewCodeBlock", () => {
23
33
entityMap : { } ,
24
34
blocks : [
25
35
{
26
- key : "item1" ,
27
36
text : "" ,
28
37
type : "code-block" ,
29
38
depth : 0 ,
30
39
inlineStyleRanges : [ ] ,
31
40
entityRanges : [ ] ,
32
41
data,
33
42
} ,
43
+ {
44
+ text : "" ,
45
+ type : "unstyled" ,
46
+ inlineStyleRanges : [ ] ,
47
+ entityRanges : [ ] ,
48
+ data : { } ,
49
+ depth : 0 ,
50
+ } ,
34
51
] ,
35
52
} ;
36
53
const contentState = Draft . convertFromRaw ( beforeRawContentState ) ;
@@ -49,9 +66,11 @@ describe("handleNewCodeBlock", () => {
49
66
it ( "creates new code block" , ( ) => {
50
67
const newEditorState = handleNewCodeBlock ( editorState ) ;
51
68
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 ) ) ;
55
74
} ) ;
56
75
} ;
57
76
You can’t perform that action at this time.
0 commit comments