explicitly cast to strings for table diffs

This commit is contained in:
Moritz Kobitzsch 2017-02-15 15:56:46 +01:00 committed by Patrick Niklaus
parent 224848fc11
commit 6567e79ec5

View File

@ -36,7 +36,7 @@ module.exports = function (expected, actual) {
} }
} }
}); });
if (!tableError) return null; if (!tableError) return null;
@ -68,7 +68,7 @@ module.exports = function (expected, actual) {
// header row // header row
cells = [] cells = []
headers.forEach( (key) => { headers.forEach( (key) => {
var content = key.padRight(' ', widths[key] ); var content = String(key).padRight(' ', widths[key] );
if (columnStatus[key] == false ) if (columnStatus[key] == false )
content = okStr + content; content = okStr + content;
cells.push( chalk.white( content ) ); cells.push( chalk.white( content ) );
@ -83,7 +83,7 @@ module.exports = function (expected, actual) {
// expected row // expected row
cells = [] cells = []
headers.forEach( (key) => { headers.forEach( (key) => {
var content = row[key].padRight(' ', widths[key] ); var content = String(row[key]).padRight(' ', widths[key] );
if (statusRows[i][key] == false) if (statusRows[i][key] == false)
cells.push( chalk.yellow( wantStr + content) ); cells.push( chalk.yellow( wantStr + content) );
else { else {
@ -105,7 +105,7 @@ module.exports = function (expected, actual) {
if (rowError) { if (rowError) {
cells = [] cells = []
headers.forEach( (key) => { headers.forEach( (key) => {
var content = actual[i][key].padRight(' ', widths[key] ); var content = String(actual[i][key]).padRight(' ', widths[key] );
if (statusRows[i][key] == false) if (statusRows[i][key] == false)
cells.push( chalk.red( gotStr + content) ); cells.push( chalk.red( gotStr + content) );
else { else {