Skip to content

Commit

Permalink
fix(grid-core): allow to place TableColumnVisibility after another ta…
Browse files Browse the repository at this point in the history
…ble plugins (#557)
  • Loading branch information
MaximKudriavtsev committed Dec 7, 2017
1 parent 06afae1 commit 6788ba6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
@@ -1,2 +1,5 @@
import { TABLE_DATA_TYPE } from './../table/constants';

export const visibleTableColumns = (tableColumns, hiddenColumns) =>
tableColumns.filter(tableColumn => hiddenColumns.indexOf(tableColumn.column.name) === -1);
tableColumns.filter(tableColumn =>
tableColumn.type !== TABLE_DATA_TYPE || hiddenColumns.indexOf(tableColumn.column.name) === -1);
@@ -1,18 +1,31 @@
import { visibleTableColumns } from './computeds';
import { TABLE_DATA_TYPE } from './../table/constants';

describe('TableColumnVisibility computeds', () => {
describe('#visibleTableColumns', () => {
it('should return a correct array of visible table columns', () => {
const tableColumns = [
{ column: { name: 'a' } },
{ column: { name: 'b' } },
{ column: { name: 'c' } },
{ column: { name: 'd' } },
{ type: TABLE_DATA_TYPE, column: { name: 'a' } },
{ type: TABLE_DATA_TYPE, column: { name: 'b' } },
{ type: TABLE_DATA_TYPE, column: { name: 'c' } },
{ type: TABLE_DATA_TYPE, column: { name: 'd' } },
];
const hiddenColumns = ['a', 'c', 'd'];

expect(visibleTableColumns(tableColumns, hiddenColumns))
.toEqual([{ column: { name: 'b' } }]);
.toEqual([{ type: TABLE_DATA_TYPE, column: { name: 'b' } }]);
});

it('should ignore non-data columns', () => {
const tableColumns = [
{ key: 'editCommand' },
{ type: TABLE_DATA_TYPE, column: { name: 'a' } },
{ type: TABLE_DATA_TYPE, column: { name: 'b' } },
];
const hiddenColumns = ['a'];

expect(visibleTableColumns(tableColumns, hiddenColumns))
.toEqual([{ key: 'editCommand' }, { type: TABLE_DATA_TYPE, column: { name: 'b' } }]);
});
});
});

0 comments on commit 6788ba6

Please sign in to comment.