From dfe908a336cf5150fc3340afb5b070f8625c5f00 Mon Sep 17 00:00:00 2001 From: Shusetsu Toda Date: Wed, 13 Jun 2018 14:12:49 +0200 Subject: [PATCH 1/2] :bug: Fix to check null for the object --- src/utils/tablify.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/tablify.js b/src/utils/tablify.js index 4259b097..85d8fc56 100644 --- a/src/utils/tablify.js +++ b/src/utils/tablify.js @@ -34,7 +34,7 @@ const chars = { }; const getKeyValueObject = object => { - if (typeof object !== 'object') { + if (!object || typeof object !== 'object') { return object; } return Object.entries(object) From d2b3c0a431e60989cece598ab1e8238c5b052100 Mon Sep 17 00:00:00 2001 From: Shusetsu Toda Date: Wed, 13 Jun 2018 14:22:46 +0200 Subject: [PATCH 2/2] :white_check_mark: Add tests for null --- test/steps/general/1_given.js | 1 + test/steps/printing/3_then.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/test/steps/general/1_given.js b/test/steps/general/1_given.js index 060d328b..9998db94 100644 --- a/test/steps/general/1_given.js +++ b/test/steps/general/1_given.js @@ -60,6 +60,7 @@ export function aNonEmptyObject() { export function aDeeplyNestedObject() { this.test.ctx.testObject = { root: 'value', + nullObject: null, nested: { object: 'values', testing: 123, diff --git a/test/steps/printing/3_then.js b/test/steps/printing/3_then.js index f46cfa56..b5460b45 100644 --- a/test/steps/printing/3_then.js +++ b/test/steps/printing/3_then.js @@ -145,7 +145,7 @@ export function theReturnedTableShouldHaveARowWithTheObjectKeyAndStringifiedNest const { returnValue, testObject } = this.test.ctx; return Object.entries(testObject).forEach(([key, value], arrayKey) => { const strValue = - typeof value === 'object' + typeof value === 'object' && value !== null ? Object.entries(value) .map( ([vKey, vValue]) =>