From 23dc630ef1a6d6f098147f4e47e0f5d06c9f480b Mon Sep 17 00:00:00 2001 From: addisonssense Date: Thu, 9 May 2019 14:14:33 -0400 Subject: [PATCH] issue-1147: Add test for pretty print html --- packages/test-utils/src/wrapper.js | 4 ++-- test/specs/wrapper/html.spec.js | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/test-utils/src/wrapper.js b/packages/test-utils/src/wrapper.js index 90e106cb7..237abce2c 100644 --- a/packages/test-utils/src/wrapper.js +++ b/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' @@ -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 } diff --git a/test/specs/wrapper/html.spec.js b/test/specs/wrapper/html.spec.js index 538891032..ab3c4a005 100644 --- a/test/specs/wrapper/html.spec.js +++ b/test/specs/wrapper/html.spec.js @@ -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 = + '\n' + + '
\n' + + ' \n' + + '
\n' + + '' + + const compiled = compileToFunctions(expectedHtml) + const wrapper = mountingMethod(compiled) + const options = { prettyPrint: true } + expect(wrapper.html(options)).to.equal(expectedHtml) + }) })