Test for --normalize-html-whitespace CLI option

This commit is contained in:
Antonino Porcino 2016-07-08 14:07:27 +02:00
parent 6348e53306
commit 720db6c121
3 changed files with 38 additions and 0 deletions

23
test/data/whitespace.rt Normal file
View File

@ -0,0 +1,23 @@
<div>
<div>
This is a
{this.props.name}
example
</div>
<div> &#160; </div>
<pre>
This is a
{this.props.name}
example
</pre>
<textarea>
This is a
{this.props.name}
example
<textarea>
<div rt-pre>
This is a
{this.props.name}
example
</pre>
</div>

View File

@ -0,0 +1,9 @@
define([
'react',
'lodash'
], function (React, _) {
'use strict';
return function () {
return React.createElement('div', {}, React.createElement('div', {}, ' This is a ', this.props.name, ' example '), React.createElement('div', {}, ' \xA0 '), React.createElement('pre', {}, '\n This is a \n ', this.props.name, ' \n example\n '), React.createElement('textarea', {}, '\n This is a \n ', this.props.name, ' \n example\n ', React.createElement('textarea', {}, React.createElement('div', {}, '\n This is a \n ', this.props.name, ' \n example\n \n'))));
};
});

View File

@ -90,6 +90,12 @@ module.exports = {
files.forEach(file => check(t, file));
});
test('normalize whitespace', t => {
const files = ['whitespace.rt'];
const options = {normalizeHtmlWhitespace: true, modules: 'amd'};
testFiles(t, files, options);
});
test('convert comment with AMD and ES6 modules', t => {
const files = [
{source: 'comment.rt', expected: 'comment.rt.amd.js', options: {modules: 'amd'}},