Skip to content

Commit a974042

Browse files
committed
feat(text): trim text by default
closes 152
1 parent b3c12c4 commit a974042

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/wrappers/wrapper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ export default class Wrapper implements BaseWrapper {
389389
throwError('cannot call wrapper.text() on a wrapper without an element')
390390
}
391391

392-
return this.element.textContent
392+
return this.element.textContent.trim()
393393
}
394394

395395
/**

test/unit/specs/mount/Wrapper/text.spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ describe('text', () => {
1010
expect(wrapper.text()).to.equal(text)
1111
})
1212

13+
it('returns trimmed text content of wrapper node', () => {
14+
const text = 'test text prop'
15+
const compiled = compileToFunctions(`
16+
<div>
17+
${text}
18+
</div>`)
19+
const wrapper = mount(compiled)
20+
21+
expect(wrapper.text()).to.equal(text)
22+
})
23+
152
1324
it('throws error if wrapper does not contain element', () => {
1425
const wrapper = mount({ render: (h) => h('div') })
1526
const div = wrapper.find('div')

0 commit comments

Comments
 (0)