diff --git a/lib/index.js b/lib/index.js index b44ae8a..c8d1790 100644 --- a/lib/index.js +++ b/lib/index.js @@ -48,7 +48,7 @@ function Table (options){ , head: [] }, options); - if (options.rows) { + if (options && options.rows) { for (var i = 0; i < options.rows.length; i++) { this.push(options.rows[i]); } diff --git a/test/index.test.js b/test/index.test.js index 11af839..1839f7b 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -309,4 +309,9 @@ module.exports = { table.toString().should.eql(expected.join("\n")); }, + 'test table with no options provided in constructor': () => { + const table = new Table(); + + table.should.exist; + }, };