@@ -14,21 +14,14 @@ describe("CodeView", () => {
1414 test ( "correctly renders simple content" , ( ) => {
1515 render ( < CodeView content = { "Hello World" } > </ CodeView > ) ;
1616 const wrapper = createWrapper ( ) ! . findCodeView ( ) ;
17- expect ( wrapper ! . findContent ( ) [ 0 ] . getElement ( ) ) . toHaveTextContent ( "Hello World" ) ;
17+ expect ( wrapper ! . findContent ( ) . getElement ( ) ) . toHaveTextContent ( "Hello World" ) ;
1818 } ) ;
1919
2020 test ( "correctly renders multi line content" , ( ) => {
21- const content = `# Hello World\n\nThis is a markdown example.` ;
22-
23- render ( < CodeView content = { content } > </ CodeView > ) ;
24- const wrapper = createWrapper ( ) ! . findCodeView ( ) ;
25- const contentElements = wrapper ! . findContent ( ) ;
26- expect ( contentElements . length ) . toEqual ( 3 ) ;
27- const renderedContent = contentElements
28- . map ( ( element ) => element . getElement ( ) . textContent )
29- . join ( "" )
30- . trim ( ) ;
31- expect ( renderedContent ) . toBe ( content ) ;
21+ render ( < CodeView content = { `# Hello World\n\nThis is a markdown example.` } > </ CodeView > ) ;
22+ const wrapper = createWrapper ( ) ! . findCodeView ( ) ! ;
23+ const content = wrapper . findContent ( ) ;
24+ expect ( content . getElement ( ) ) . toHaveTextContent ( "# Hello World This is a markdown example." ) ;
3225 } ) ;
3326
3427 test ( "correctly renders copy button slot" , ( ) => {
@@ -73,13 +66,13 @@ describe("CodeView", () => {
7366 > </ CodeView >
7467 ) ;
7568 const wrapper = createWrapper ( ) . findCodeView ( ) ! ;
76- expect ( wrapper ! . findContent ( ) [ 0 ] . getElement ( ) . innerHTML ) . toContain ( "tokenized" ) ;
69+ expect ( wrapper ! . findContent ( ) . getElement ( ) . innerHTML ) . toContain ( "tokenized" ) ;
7770 } ) ;
7871
7972 test ( "correctly tokenizes content if highlight is set to language rules" , ( ) => {
8073 render ( < CodeView content = { 'const hello: string = "world";' } highlight = { typescriptHighlightRules } > </ CodeView > ) ;
8174 const wrapper = createWrapper ( ) . findCodeView ( ) ! ;
82- const element = wrapper ! . findContent ( ) [ 0 ] . getElement ( ) ;
75+ const element = wrapper ! . findContent ( ) . getElement ( ) ;
8376
8477 // Check that the content is tokenized following typescript rules.
8578 expect ( getByText ( element , "const" ) ) . toHaveClass ( "ace_type" ) ;
@@ -91,21 +84,21 @@ describe("CodeView", () => {
9184 test ( "sets nowrap class to line if linesWrapping undefined" , ( ) => {
9285 render ( < CodeView content = { "Hello World" } > </ CodeView > ) ;
9386 const wrapper = createWrapper ( ) . findCodeView ( ) ! ;
94- const element = wrapper ! . findContent ( ) [ 0 ] . getElement ( ) ;
87+ const element = wrapper ! . findContent ( ) . getElement ( ) ;
9588 expect ( element . outerHTML ) . toContain ( "code-line-nowrap" ) ;
9689 } ) ;
9790
9891 test ( "sets nowrap class to line if linesWrapping false" , ( ) => {
9992 render ( < CodeView lineWrapping = { false } content = { "Hello World" } > </ CodeView > ) ;
10093 const wrapper = createWrapper ( ) . findCodeView ( ) ! ;
101- const element = wrapper ! . findContent ( ) [ 0 ] . getElement ( ) ;
94+ const element = wrapper ! . findContent ( ) . getElement ( ) ;
10295 expect ( element . outerHTML ) . toContain ( "code-line-nowrap" ) ;
10396 } ) ;
10497
10598 test ( "sets wrap class to line if linesWrapping true" , ( ) => {
10699 render ( < CodeView lineWrapping = { true } content = { "Hello World" } > </ CodeView > ) ;
107100 const wrapper = createWrapper ( ) . findCodeView ( ) ! ;
108- const element = wrapper ! . findContent ( ) [ 0 ] . getElement ( ) ;
101+ const element = wrapper ! . findContent ( ) . getElement ( ) ;
109102 expect ( element . outerHTML ) . toContain ( "code-line-wrap" ) ;
110103 } ) ;
111104} ) ;
0 commit comments