mirror of
https://github.com/bobwen-dev/react-templates
synced 2025-04-12 00:56:39 +02:00
Test for react-native 0.29.0
This commit is contained in:
parent
bde2f67e01
commit
fb8d4028dd
23
test/data/native/listViewAndCustomTemplate.rt.v029.js
Normal file
23
test/data/native/listViewAndCustomTemplate.rt.v029.js
Normal 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)
|
||||
}));
|
||||
};
|
13
test/data/native/listViewTemplate.rt.v029.js
Normal file
13
test/data/native/listViewTemplate.rt.v029.js
Normal 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)
|
||||
}));
|
||||
};
|
7
test/data/native/nativeView.rt.v029.js
Normal file
7
test/data/native/nativeView.rt.v029.js
Normal 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, {});
|
||||
};
|
@ -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 => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user