diff --git a/packages/iris-grid/src/IrisGridModel.test.ts b/packages/iris-grid/src/IrisGridModel.test.ts index 34bd4bf7f1..a480324c06 100644 --- a/packages/iris-grid/src/IrisGridModel.test.ts +++ b/packages/iris-grid/src/IrisGridModel.test.ts @@ -150,6 +150,16 @@ it('updates the model correctly when adding and removing a rollup config', async expect(table.rollup).not.toHaveBeenCalled(); }); +it('isRollupAvailable checks if the rollup method is defined', async () => { + const table = irisGridTestUtils.makeTable(); + + const mock = jest.fn(); + table.rollup = mock; + const model = irisGridTestUtils.makeModel(table); + + expect(model.isRollupAvailable).toBe(true); +}); + it('closes the table correctly when the model is closed', () => { const table = irisGridTestUtils.makeTable(); table.close = jest.fn(); diff --git a/packages/iris-grid/src/IrisGridTableModel.ts b/packages/iris-grid/src/IrisGridTableModel.ts index 3719f34864..9768c2886b 100644 --- a/packages/iris-grid/src/IrisGridTableModel.ts +++ b/packages/iris-grid/src/IrisGridTableModel.ts @@ -63,10 +63,6 @@ class IrisGridTableModel return this.table.getColumnStatistics != null; } - get isValuesTableAvailable(): boolean { - return this.table.selectDistinct != null && this.table.copy != null; - } - get isRollupAvailable(): boolean { return this.table.rollup != null; } diff --git a/packages/iris-grid/src/IrisGridTableModelTemplate.ts b/packages/iris-grid/src/IrisGridTableModelTemplate.ts index 51407547f0..90c0c53ed6 100644 --- a/packages/iris-grid/src/IrisGridTableModelTemplate.ts +++ b/packages/iris-grid/src/IrisGridTableModelTemplate.ts @@ -446,6 +446,10 @@ class IrisGridTableModelTemplate< : 0; } + get isValuesTableAvailable(): boolean { + return this.table.selectDistinct != null && this.table.copy != null; + } + get isChartBuilderAvailable(): boolean { return true; } diff --git a/packages/iris-grid/src/IrisGridTreeTableModel.test.ts b/packages/iris-grid/src/IrisGridTreeTableModel.test.ts index 9228a23167..0fc72a3329 100644 --- a/packages/iris-grid/src/IrisGridTreeTableModel.test.ts +++ b/packages/iris-grid/src/IrisGridTreeTableModel.test.ts @@ -32,6 +32,23 @@ describe('IrisGridTreeTableModel virtual columns', () => { expect(model.columns).toEqual(expected); } ); + + test.each([ + ['filter', 'Filter'], + ['sort', 'Sort'], + ['formatColor', 'Color'], + ['get', 'get'], + ['getFormat', 'getFormat'], + ['formatNumber', 'formatNumber'], + ['formatDate', 'formatDate'], + ])('virtual column method %s is not implemented', (method, displayName) => { + const groupedColumns = columns.slice(0, 2); + const table = irisGridTestUtils.makeTreeTable(columns, groupedColumns); + const model = new IrisGridTreeTableModel(dh, table); + expect(() => model.columns[0][method]()).toThrow( + new Error(`${displayName} not implemented for virtual column`) + ); + }); }); describe('IrisGridTreeTableModel layoutHints', () => { @@ -78,3 +95,13 @@ describe('IrisGridTreeTableModel layoutHints', () => { expect(model.layoutHints).toEqual(undefined); }); }); + +describe('IrisGridTreeTableModel values table', () => { + it('is available for tree tables', () => { + const columns = irisGridTestUtils.makeColumns(); + const table = irisGridTestUtils.makeTreeTable(columns, columns, 100, []); + const model = new IrisGridTreeTableModel(dh, table); + + expect(model.isValuesTableAvailable).toBe(true); + }); +}); diff --git a/packages/iris-grid/src/IrisGridTreeTableModel.ts b/packages/iris-grid/src/IrisGridTreeTableModel.ts index eb2c00b5e8..4323591966 100644 --- a/packages/iris-grid/src/IrisGridTreeTableModel.ts +++ b/packages/iris-grid/src/IrisGridTreeTableModel.ts @@ -30,7 +30,7 @@ const VirtualGroupColumn = Object.freeze({ throw new Error('Filter not implemented for virtual column'); }, sort: () => { - throw new Error('Sort not implemented virtual column'); + throw new Error('Sort not implemented for virtual column'); }, formatColor: () => { throw new Error('Color not implemented for virtual column');