From ef39f3a3803c7da6aeac172f6b6387b1d1df0a9f Mon Sep 17 00:00:00 2001 From: Lloyd Brookes Date: Thu, 18 Jul 2024 19:13:33 +0300 Subject: [PATCH] add a test to verify the CommonJS build --- package.json | 2 +- test/common-js.cjs | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 test/common-js.cjs diff --git a/package.json b/package.json index 8c03042..50bb6dc 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ }, "scripts": { "test": "npm run dist && npm run test:ci", - "test:ci": "test-runner 'test/**/*.js'", + "test:ci": "test-runner 'test/**/*.js' 'test/**/*.cjs'", "docs": "jsdoc2md index.js -p list --member-index-format list > docs/API.md", "dist": "rollup -c" }, diff --git a/test/common-js.cjs b/test/common-js.cjs new file mode 100644 index 0000000..bc1c574 --- /dev/null +++ b/test/common-js.cjs @@ -0,0 +1,24 @@ +const Tom = require('@test-runner/tom') +const Table = require('table-layout') +const assert = require('assert') +const a = assert.strict + +const eol = '\n' +const tom = new Tom() + +tom.test('new Table()', function () { + const options = { + maxWidth: 40, + padding: { left: '<', right: '>' } + } + const data = [ + { one: 'row 1 column one .. .. ..', two: 'r1 c2' }, + { one: 'r2 c1', two: 'row two column 2' } + ] + const table = new Table(data, options) + + a.equal(table.rows.list.length, 2) + a.equal(table.columns.list.length, 2) +}) + +module.exports = tom