Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,42 @@ describe('Bugs', () => {
});
});
});

describe('ColumnChooserController', () => {
beforeEach(() => {
beforeTest();
jest.spyOn(errors, 'log').mockImplementation(jest.fn());
jest.spyOn(errors, 'Error').mockImplementation(() => ({}) as ReturnType<typeof errors.Error>);
});
afterEach(afterTest);

describe('getPosition', () => {
it('should return the default position when columnChooser.position is not set', async () => {
const { instance } = await createDataGrid({
dataSource: [],
columns: ['id'],
columnChooser: { enabled: true },
});

expect(instance.getController('columnChooser').getPosition()).toEqual({
my: 'right bottom',
at: 'right bottom',
of: instance.getView('rowsView').element(),
collision: 'fit',
offset: '-2 -2',
boundaryOffset: '2 2',
});
});

it('should return columnChooser.position when it is set', async () => {
const position = { my: 'left top', at: 'left top', of: '#gridContainer' } as const;
const { instance } = await createDataGrid({
dataSource: [],
columns: ['id'],
columnChooser: { enabled: true, position },
});

expect(instance.getController('columnChooser').getPosition()).toEqual(position);
});
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
import type { ColumnChooser } from '@js/common/grids';
import messageLocalization from '@js/localization/message';

export const CLASSES = {
columnChooser: 'column-chooser',
columnChooserButton: 'column-chooser-button',
columnChooserList: 'column-chooser-list',
columnChooserPlain: 'column-chooser-plain',
columnChooserModeDrag: 'column-chooser-mode-drag',
columnChooserModeSelect: 'column-chooser-mode-select',
columnChooserItem: 'dx-column-chooser-item',
};

export const ICONS = {
columnChooser: 'column-chooser',
};

export const defaultOptions = {
columnChooser: {
enabled: false,
Expand Down
Loading
Loading