Test for react-native 0.29.0

This commit is contained in:
Antonino Porcino 2016-07-07 13:52:23 +02:00
parent bde2f67e01
commit fb8d4028dd
4 changed files with 65 additions and 3 deletions

View File

@ -0,0 +1,23 @@
'use strict';
var ReactNative = require('react-native');
var React = require('react');
var _ = require('lodash');
module.exports = function () {
function renderRow1(rowData) {
return React.createElement(ReactNative.Text, {}, rowData);
}
function renderRow2(item) {
return React.createElement(ReactNative.Text, {}, item);
}
return React.createElement(ReactNative.View, {}, React.createElement(ReactNative.ListView, {
'dataSource': this.state.dataSource,
'renderRow': renderRow1.bind(this)
}), React.createElement(MyComp, {
'data': [
1,
2,
3
],
'renderRow': renderRow2.bind(this)
}));
};

View File

@ -0,0 +1,13 @@
'use strict';
var ReactNative = require('react-native');
var React = require('react');
var _ = require('lodash');
module.exports = function () {
function renderRow1(rowData) {
return React.createElement(ReactNative.Text, {}, rowData);
}
return React.createElement(ReactNative.View, {}, React.createElement(ReactNative.ListView, {
'dataSource': this.state.dataSource,
'renderRow': renderRow1.bind(this)
}));
};

View File

@ -0,0 +1,7 @@
'use strict';
var ReactNative = require('react-native');
var React = require('react');
var _ = require('lodash');
module.exports = function () {
return React.createElement(ReactNative.View, {});
};

View File

@ -1,4 +1,5 @@
'use strict';
const _ = require('lodash');
const reactTemplates = require('../../src/reactTemplates');
const testUtils = require('./testUtils');
const readFileNormalized = testUtils.readFileNormalized;
@ -54,9 +55,27 @@ module.exports = {
}
},
native: true
};
const files = ['native/nativeView.rt', 'native/listViewTemplate.rt', 'native/listViewAndCustomTemplate.rt'];
testFiles(t, files, options);
};
const optionsNew = _.assign({nativeTargetVersion: '0.29.0'}, options);
const files = [
{source: 'native/nativeView.rt', expected: 'native/nativeView.rt.js', options},
{source: 'native/listViewTemplate.rt', expected: 'native/listViewTemplate.rt.js', options},
{source: 'native/listViewAndCustomTemplate.rt', expected: 'native/listViewAndCustomTemplate.rt.js', options},
{source: 'native/nativeView.rt', expected: 'native/nativeView.rt.v029.js', options: optionsNew},
{source: 'native/listViewTemplate.rt', expected: 'native/listViewTemplate.rt.v029.js', options: optionsNew},
{source: 'native/listViewAndCustomTemplate.rt', expected: 'native/listViewAndCustomTemplate.rt.v029.js', options: optionsNew}
];
t.plan(files.length);
files.forEach(check);
function check(testData) {
const filename = path.join(dataPath, testData.source);
const html = readFileNormalized(filename);
const expected = readFileNormalized(path.join(dataPath, testData.expected));
const actual = reactTemplates.convertTemplateToReact(html, testData.options).replace(/\r/g, '').trim();
compareAndWrite(t, actual, expected, filename);
}
});
test('convert div with all module types', t => {