@@ -5,8 +5,8 @@ import stateFromMarkdown from '../stateFromMarkdown';
55import { convertToRaw } from 'draft-js' ;
66
77describe ( 'stateFromMarkdown' , ( ) => {
8- let markdown = 'Hello World' ;
98 it ( 'should create content state' , ( ) => {
9+ let markdown = 'Hello World' ;
1010 let contentState = stateFromMarkdown ( markdown ) ;
1111 let rawContentState = convertToRaw ( contentState ) ;
1212 let blocks = removeKeys ( rawContentState . blocks ) ;
@@ -21,9 +21,9 @@ describe('stateFromMarkdown', () => {
2121 } ,
2222 ] ) ;
2323 } ) ;
24- it ( 'should correctly move code blocks' , ( ) => {
25- let codeMarkdown = "```\nconst a = 'b'\n```" ;
26- let contentState = stateFromMarkdown ( codeMarkdown ) ;
24+ it ( 'should correctly handle code blocks' , ( ) => {
25+ let markdown = "```\nconst a = 'b'\n```" ;
26+ let contentState = stateFromMarkdown ( markdown ) ;
2727 let rawContentState = convertToRaw ( contentState ) ;
2828 let blocks = removeKeys ( rawContentState . blocks ) ;
2929 expect ( blocks ) . toEqual ( [
@@ -43,10 +43,26 @@ describe('stateFromMarkdown', () => {
4343 } ,
4444 ] ) ;
4545 } ) ;
46- it ( 'should correctly move images with complex srcs' , ( ) => {
46+ it ( 'should correctly handle linebreaks option' , ( ) => {
47+ let markdown = 'Hello\nWorld' ;
48+ let contentState = stateFromMarkdown ( markdown , { parserOptions : { breaks : true } } ) ;
49+ let rawContentState = convertToRaw ( contentState ) ;
50+ let blocks = removeKeys ( rawContentState . blocks ) ;
51+ expect ( blocks ) . toEqual ( [
52+ {
53+ text : 'Hello\nWorld' ,
54+ type : 'unstyled' ,
55+ depth : 0 ,
56+ inlineStyleRanges : [ ] ,
57+ entityRanges : [ ] ,
58+ data : { } ,
59+ } ,
60+ ] ) ;
61+ } ) ;
62+ it ( 'should correctly handle images with complex srcs' , ( ) => {
4763 const src = 'https://spectrum.imgix.net/threads/c678032e-68a4-4e14-956d-abfa444a707d/Captura%20de%20pantalla%202017-08-19%20a%20la(s)%2000.14.09.png.0.29802431313299893' ;
48- let input = `` ;
49- let contentState = stateFromMarkdown ( input ) ;
64+ let markdown = `` ;
65+ let contentState = stateFromMarkdown ( markdown ) ;
5066 let rawContentState = convertToRaw ( contentState ) ;
5167 let blocks = removeKeys ( rawContentState . blocks ) ;
5268 expect ( {
0 commit comments