Skip to content

Commit

Permalink
add test for trailing text
Browse files Browse the repository at this point in the history
  • Loading branch information
siva-sundar committed Oct 6, 2017
1 parent d49229f commit 44fba8f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions tests/integration/components/dummy-component-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,18 @@ describe('HBS Minifier plugin', function() {
});

it('Collapse leading/trailing text from ElementNode nodes', function() {
this.render(hbs`<div>x {{foo}} y </div>`);
this.render(hbs`<div>x {{foo}} y {{bar}} z</div>`);

let childNodes = this.$('div')[0].childNodes;
expect(childNodes.length).to.equal(3);
expect(childNodes.length).to.equal(5);
expect(childNodes[0]).to.be.a('text');
expect(childNodes[0]).to.have.a.property('textContent', 'x ');
expect(childNodes[1]).to.be.a('text');
expect(childNodes[1]).to.have.a.property('textContent', 'foo');
expect(childNodes[2]).to.be.a('text');
expect(childNodes[2]).to.have.a.property('textContent', ' y ');
expect(childNodes[3]).to.have.a.property('textContent', 'bar');
expect(childNodes[4]).to.have.a.property('textContent', ' z');
});

it('does not strip inside of <pre> tags', function() {
Expand Down
2 changes: 1 addition & 1 deletion utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const isWhitespaceTextNode = function(node) {

const hasLeadingOrTrailingWhiteSpace = function(chars) {
chars = encodeURIComponent(chars);
return matchHorizontalTABAndNewLineEnd.test(chars) || matchHorizontalTABAndNewLineEnd.test(chars);
return matchHorizontalTABAndNewLineBegin.test(chars) || matchHorizontalTABAndNewLineEnd.test(chars);
};

const getElementAttribute = function(node, attrName) {
Expand Down

0 comments on commit 44fba8f

Please sign in to comment.