Skip to content

Commit

Permalink
issue-1147: Add test for pretty print html
Browse files Browse the repository at this point in the history
  • Loading branch information
addisonssense committed May 9, 2019
1 parent 76afc50 commit 23dc630
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/test-utils/src/wrapper.js
@@ -1,7 +1,7 @@
// @flow

import Vue from 'vue'
import pretty from 'pretty';
import pretty from 'pretty'
import getSelector from './get-selector'
import { REF_SELECTOR, FUNCTIONAL_OPTIONS, VUE_VERSION } from 'shared/consts'
import config from './config'
Expand Down Expand Up @@ -224,7 +224,7 @@ export default class Wrapper implements BaseWrapper {
*/
html(options?: HtmlOptions): string {
if (options && options.prettyPrint) {
return pretty(this.element.outerHTML);
return pretty(this.element.outerHTML)
}
return this.element.outerHTML
}
Expand Down
17 changes: 17 additions & 0 deletions test/specs/wrapper/html.spec.js
Expand Up @@ -39,4 +39,21 @@ describeWithShallowAndMount('html', mountingMethod => {
const wrapper = mountingMethod(compiled)
expect(wrapper.html()).to.equal(expectedHtml)
})

it('returns a Wrappers HTML as a pretty printed string', () => {
const expectedHtml =
'<body>\n' +
' <div>\n' +
' <ul>\n' +
' <li></li>\n' +
' <li></li>\n' +
' </ul>\n' +
' </div>\n' +
'</body>'

const compiled = compileToFunctions(expectedHtml)
const wrapper = mountingMethod(compiled)
const options = { prettyPrint: true }
expect(wrapper.html(options)).to.equal(expectedHtml)
})
})

0 comments on commit 23dc630

Please sign in to comment.