diff --git a/package-lock.json b/package-lock.json index 7376aca4..5e549e94 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "q-table", - "version": "5.0.3", + "version": "5.0.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "q-table", - "version": "5.0.3", + "version": "5.0.4", "license": "MIT", "dependencies": { "@hapi/boom": "^9.1.3", diff --git a/package.json b/package.json index c790dc7e..72bee37d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "q-table", - "version": "5.0.3", + "version": "5.0.4", "description": "", "main": "index.js", "scripts": { diff --git a/resources/fixtures/data/one-column.json b/resources/fixtures/data/one-column.json new file mode 100644 index 00000000..6014fbf9 --- /dev/null +++ b/resources/fixtures/data/one-column.json @@ -0,0 +1,51 @@ +{ + "title": "FIXTURE: simple one-column short table with numeric values", + "subtitle": "some subtitle here", + "data": { + "table": [ + [ + "Punkte" + ], + [ + "10000000" + ], + [ + "20000000" + ], + [ + "355547.5" + ], + [ + "-3500000" + ] + ], + "metaData": { + "cells": [] + } + }, + "options": { + "cardLayout": false, + "cardLayoutIfSmall": false, + "minibar": { + "invertColors": false, + "barColor": { + "positive": { + "className": "", + "colorCode": "" + }, + "negative": { + "className": "", + "colorCode": "" + } + }, + "selectedColumn": null + } + }, + "notes": "Anmerkungen", + "sources": [ + { + "link": {}, + "text": "Bloomberg" + } + ] +} diff --git a/routes/option-availability.js b/routes/option-availability.js index 46bd0b23..6dbcd934 100644 --- a/routes/option-availability.js +++ b/routes/option-availability.js @@ -35,7 +35,7 @@ module.exports = { if (item.data.table.length !== 0) { if ( !item.options.cardLayout && - item.data.table[0].length >= 3 && + item.data.table[0].length >= 2 && getNumericColumns(item.data.table).length >= 1 ) { isAvailable = true; @@ -112,7 +112,7 @@ module.exports = { if (item.data.table.length > 2) { if ( !item.options.cardLayout && - item.data.table[0].length >= 3 && + item.data.table[0].length >= 2 && item.data.table.length >= 1 ) { isAvailable = true; diff --git a/test/e2e-tests.js b/test/e2e-tests.js index 8afd0ec5..da6d30ed 100644 --- a/test/e2e-tests.js +++ b/test/e2e-tests.js @@ -129,7 +129,7 @@ lab.experiment("option availability endpoint", () => { expect(response.result.available).to.be.equal(true); }); - it("returns false for option availability of minibar selectedColumn", async () => { + it("returns true for option availability of minibar selectedColumn", async () => { const request = { method: "POST", url: "/option-availability/selectedColumnMinibar", @@ -138,6 +138,18 @@ lab.experiment("option availability endpoint", () => { }, }; const response = await server.inject(request); + expect(response.result.available).to.be.equal(true); + }); + + it("Minibar is not available from a certain number of columns", async () => { + const request = { + method: "POST", + url: "/option-availability/selectedColumnMinibar", + payload: { + item: require("../resources/fixtures/data/one-column.json"), + }, + }; + const response = await server.inject(request); expect(response.result.available).to.be.equal(false); }); @@ -153,7 +165,7 @@ lab.experiment("option availability endpoint", () => { expect(response.result.available).to.be.equal(true); }); - it("returns false for option availability of colorColumn selectedColumn", async () => { + it("returns true for option availability of colorColumn selectedColumn", async () => { const request = { method: "POST", url: "/option-availability/selectedColorColumn", @@ -162,6 +174,18 @@ lab.experiment("option availability endpoint", () => { }, }; const response = await server.inject(request); + expect(response.result.available).to.be.equal(true); + }); + + it("ColorColumn is not available from a certain number of columns", async () => { + const request = { + method: "POST", + url: "/option-availability/selectedColorColumn", + payload: { + item: require("../resources/fixtures/data/one-column.json"), + }, + }; + const response = await server.inject(request); expect(response.result.available).to.be.equal(false); }); });