Skip to content

Commit 23dc630

Browse files
committed
issue-1147: Add test for pretty print html
1 parent 76afc50 commit 23dc630

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

Diff for: packages/test-utils/src/wrapper.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @flow
22

33
import Vue from 'vue'
4-
import pretty from 'pretty';
4+
import pretty from 'pretty'
55
import getSelector from './get-selector'
66
import { REF_SELECTOR, FUNCTIONAL_OPTIONS, VUE_VERSION } from 'shared/consts'
77
import config from './config'
@@ -224,7 +224,7 @@ export default class Wrapper implements BaseWrapper {
224224
*/
225225
html(options?: HtmlOptions): string {
226226
if (options && options.prettyPrint) {
227-
return pretty(this.element.outerHTML);
227+
return pretty(this.element.outerHTML)
228228
}
229229
return this.element.outerHTML
230230
}

Diff for: test/specs/wrapper/html.spec.js

+17
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,21 @@ describeWithShallowAndMount('html', mountingMethod => {
3939
const wrapper = mountingMethod(compiled)
4040
expect(wrapper.html()).to.equal(expectedHtml)
4141
})
42+
43+
it('returns a Wrappers HTML as a pretty printed string', () => {
44+
const expectedHtml =
45+
'<body>\n' +
46+
' <div>\n' +
47+
' <ul>\n' +
48+
' <li></li>\n' +
49+
' <li></li>\n' +
50+
' </ul>\n' +
51+
' </div>\n' +
52+
'</body>'
53+
54+
const compiled = compileToFunctions(expectedHtml)
55+
const wrapper = mountingMethod(compiled)
56+
const options = { prettyPrint: true }
57+
expect(wrapper.html(options)).to.equal(expectedHtml)
58+
})
4259
})

0 commit comments

Comments
 (0)