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";
22import Draft , { EditorState , SelectionState } from "draft-js" ;
33import 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+
515describe ( "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
You can’t perform that action at this time.
0 commit comments