@@ -24,6 +24,21 @@ describe("CodeView", () => {
2424 const wrapper = createWrapper ( ) ! . findCodeView ( ) ! ;
2525 const content = wrapper . findContent ( ) ;
2626 expect ( content . getElement ( ) ) . toHaveTextContent ( "# Hello World This is a markdown example." ) ;
27+ expect ( wrapper ! . findContent ( ) [ 0 ] . getElement ( ) ) . toHaveTextContent ( "Hello World" ) ;
28+ } ) ;
29+
30+ test ( "correctly renders multi line content" , ( ) => {
31+ const content = `# Hello World\n\nThis is a markdown example.` ;
32+
33+ render ( < CodeView content = { content } > </ CodeView > ) ;
34+ const wrapper = createWrapper ( ) ! . findCodeView ( ) ;
35+ const contentElements = wrapper ! . findContent ( ) ;
36+ expect ( contentElements . length ) . toEqual ( 3 ) ;
37+ const renderedContent = contentElements
38+ . map ( ( element ) => element . getElement ( ) . textContent )
39+ . join ( "" )
40+ . trim ( ) ;
41+ expect ( renderedContent ) . toBe ( content ) ;
2742 } ) ;
2843
2944 test ( "correctly renders copy button slot" , ( ) => {
@@ -68,13 +83,13 @@ describe("CodeView", () => {
6883 > </ CodeView > ,
6984 ) ;
7085 const wrapper = createWrapper ( ) . findCodeView ( ) ! ;
71- expect ( wrapper ! . findContent ( ) . getElement ( ) . innerHTML ) . toContain ( "tokenized" ) ;
86+ expect ( wrapper ! . findContent ( ) [ 0 ] . getElement ( ) . innerHTML ) . toContain ( "tokenized" ) ;
7287 } ) ;
7388
7489 test ( "correctly tokenizes content if highlight is set to language rules" , ( ) => {
7590 render ( < CodeView content = { 'const hello: string = "world";' } highlight = { typescriptHighlightRules } > </ CodeView > ) ;
7691 const wrapper = createWrapper ( ) . findCodeView ( ) ! ;
77- const element = wrapper ! . findContent ( ) . getElement ( ) ;
92+ const element = wrapper ! . findContent ( ) [ 0 ] . getElement ( ) ;
7893
7994 // Check that the content is tokenized following typescript rules.
8095 expect ( getByText ( element , "const" ) ) . toHaveClass ( "ace_type" ) ;
@@ -86,21 +101,21 @@ describe("CodeView", () => {
86101 test ( "sets nowrap class to line if linesWrapping undefined" , ( ) => {
87102 render ( < CodeView content = { "Hello World" } > </ CodeView > ) ;
88103 const wrapper = createWrapper ( ) . findCodeView ( ) ! ;
89- const element = wrapper ! . findContent ( ) . getElement ( ) ;
104+ const element = wrapper ! . findContent ( ) [ 0 ] . getElement ( ) ;
90105 expect ( element . outerHTML ) . toContain ( "code-line-nowrap" ) ;
91106 } ) ;
92107
93108 test ( "sets nowrap class to line if linesWrapping false" , ( ) => {
94109 render ( < CodeView lineWrapping = { false } content = { "Hello World" } > </ CodeView > ) ;
95110 const wrapper = createWrapper ( ) . findCodeView ( ) ! ;
96- const element = wrapper ! . findContent ( ) . getElement ( ) ;
111+ const element = wrapper ! . findContent ( ) [ 0 ] . getElement ( ) ;
97112 expect ( element . outerHTML ) . toContain ( "code-line-nowrap" ) ;
98113 } ) ;
99114
100115 test ( "sets wrap class to line if linesWrapping true" , ( ) => {
101116 render ( < CodeView lineWrapping = { true } content = { "Hello World" } > </ CodeView > ) ;
102117 const wrapper = createWrapper ( ) . findCodeView ( ) ! ;
103- const element = wrapper ! . findContent ( ) . getElement ( ) ;
118+ const element = wrapper ! . findContent ( ) [ 0 ] . getElement ( ) ;
104119 expect ( element . outerHTML ) . toContain ( "code-line-wrap" ) ;
105120 } ) ;
106121} ) ;
0 commit comments