@@ -3,6 +3,12 @@ import { defineComponent, h } from 'vue'
3
3
4
4
import { mount } from '../src'
5
5
6
+ const nestedTemplate =
7
+ '<div><div class="element"><span>Text 1</span></div><div>Text 2</div></div>'
8
+ const NestedNodes = defineComponent ( {
9
+ template : nestedTemplate
10
+ } )
11
+
6
12
describe ( 'html' , ( ) => {
7
13
it ( 'returns html when mounting single root node' , ( ) => {
8
14
const Component = defineComponent ( {
@@ -16,6 +22,29 @@ describe('html', () => {
16
22
expect ( wrapper . html ( ) ) . toBe ( '<div>Text content</div>' )
17
23
} )
18
24
25
+ it ( 'returns formatted html string' , ( ) => {
26
+ const wrapper = mount ( NestedNodes )
27
+
28
+ expect ( wrapper . html ( ) ) . toBe (
29
+ '<div>\n' +
30
+ ' <div class="element"><span>Text 1</span></div>\n' +
31
+ ' <div>Text 2</div>\n' +
32
+ '</div>'
33
+ )
34
+ expect ( wrapper . html ( ) ) . toBe (
35
+ '<div>\n' +
36
+ ' <div class="element"><span>Text 1</span></div>\n' +
37
+ ' <div>Text 2</div>\n' +
38
+ '</div>'
39
+ )
40
+ } )
41
+
42
+ it ( 'returns raw html string' , ( ) => {
43
+ const wrapper = mount ( NestedNodes )
44
+
45
+ expect ( wrapper . html ( { raw : true } ) ) . toBe ( nestedTemplate )
46
+ } )
47
+
19
48
describe ( 'multiple root components' , ( ) => {
20
49
const originalTemplate = [
21
50
'<div>foo</div>' ,
@@ -35,6 +64,11 @@ describe('html', () => {
35
64
expect ( wrapper . html ( ) ) . toBe ( originalTemplate . join ( '\n' ) )
36
65
} )
37
66
67
+ it ( 'returns the raw html when mounting multiple root nodes' , ( ) => {
68
+ const wrapper = mount ( Component )
69
+ expect ( wrapper . html ( { raw : true } ) ) . toBe ( originalTemplate . join ( '' ) )
70
+ } )
71
+
38
72
it ( 'returns the html when multiple root component is located inside other component' , ( ) => {
39
73
const ParentComponent = defineComponent ( {
40
74
components : { MultipleRoots : Component } ,
0 commit comments