Skip to content

Commit

Permalink
fixed typo; remove replace spaces (ReactWrapper.text() not removing a…
Browse files Browse the repository at this point in the history
…ny spaces); fix env on Windows;
  • Loading branch information
Idan Levin committed Nov 14, 2017
1 parent 6d0dbe4 commit 3077c0b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
8 changes: 5 additions & 3 deletions packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1633,17 +1633,19 @@ describe('shallow', () => {
matchesRender(<div>&gt;</div>);
});

it('should handle spaces with same behavior as ReactWarpper.text()', () => {
it('should handle spaces with same behavior as ReactWrapper.text()', () => {
const Space = (
<div>
<div> test </div>
<div>Hello


World</div>
World
</div>
<div>Hello World</div>
<div>Hello
World</div>
World
</div>
<div>Hello World</div>
<div>&nbsp;</div>
<div>&nbsp;&nbsp;</div>
Expand Down
5 changes: 1 addition & 4 deletions packages/enzyme/src/RSTTraversal.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,5 @@ export function getTextFromNode(node) {
}

return childrenOfNode(node).map(getTextFromNode)
.join('')
.replace(/^[ \t\n\r]+$/g, '') // remove empty nodes
.replace(/[ \t\n\r]+/, ' ') // remove double spaces
.replace(/(^[ \t\n\r]*|[ \t\n\r]*$)/, ''); // remove spaces from beginning or end
.join('');
}

0 comments on commit 3077c0b

Please sign in to comment.