Improve formatting of generated test code input
Summary: Make input html easier to read by indenting it and adding a space between children. The code to do this could very well be improved but it works for the current set of inputs. Reviewed By: lucasr Differential Revision: D3798087 fbshipit-source-id: 0d50ff276000f14ed078cf5ce2e7560ace285a6a
This commit is contained in:
committed by
Facebook Github Bot 5
parent
57725e849a
commit
059384f277
@@ -27,13 +27,27 @@ function printTest(rootNode, layoutTree) {
|
||||
lines.push('/**');
|
||||
lines.push(' * @Generated by gentest/gentest.sh with the following input');
|
||||
lines.push(' *');
|
||||
|
||||
var indentation = 0;
|
||||
lines.push(rootNode.innerHTML.split('\n').map(function(line) {
|
||||
return line.trim();
|
||||
}).filter(function(line) {
|
||||
return line.length > 0 && line !== '<div id="default"></div>';
|
||||
}).map(function(line) {
|
||||
return ' * ' + line;
|
||||
var result;
|
||||
if (line.indexOf('</div') == 0) {
|
||||
result = ' * ' + ' '.repeat(indentation - 1) + line;
|
||||
} else {
|
||||
result = ' * ' + ' '.repeat(indentation) + line;
|
||||
}
|
||||
|
||||
indentation += (line.match(/<div/g) || []).length;
|
||||
indentation -= (line.match(/<\/div/g) || []).length;
|
||||
return result;
|
||||
}).reduce(function(curr, prev) {
|
||||
if (prev.indexOf(' * <div') == 0) {
|
||||
prev = ' * \n' + prev;
|
||||
}
|
||||
return curr + '\n' + prev;
|
||||
}));
|
||||
lines.push(' *');
|
||||
|
Reference in New Issue
Block a user