Skip to content

Commit 984133f

Browse files
test(html-to-react): add tests for trim option enabled & disabled
1 parent 413eaa0 commit 984133f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/html-to-react.js

+22
Original file line numberDiff line numberDiff line change
@@ -152,5 +152,27 @@ describe('HTML to React', () => {
152152
);
153153
});
154154
});
155+
156+
describe('trim', () => {
157+
it('preserves whitespace text nodes when disabled (default)', () => {
158+
const html = `<table>
159+
<tbody>
160+
</tbody>
161+
</table>`;
162+
const reactElement = parse(html);
163+
assert.strictEqual(render(reactElement), html);
164+
});
165+
166+
it('removes whitespace text nodes when enabled', () => {
167+
const html = `<table>
168+
<tbody><tr><td> text </td><td> </td>\t</tr>\r</tbody>\n</table>`;
169+
const options = { trim: true };
170+
const reactElement = parse(html, options);
171+
assert.strictEqual(
172+
render(reactElement),
173+
'<table><tbody><tr><td> text </td><td></td></tr></tbody></table>'
174+
);
175+
});
176+
});
155177
});
156178
});

0 commit comments

Comments
 (0)