UNPKG

@poserjs/react-table-csv

Version:

React component for exploring CSV data with filers, grouping, sorting, and CSV export/import.

50 lines (46 loc) 1.4 kB
/* eslint-env jest */ import { buildSettings } from '../settingsUtils'; describe('buildSettings', () => { it('builds settings from state', () => { const state = { currentTheme: 'dark', columnStyles: { col1: { width: 100 } }, columnOrder: ['col1', 'col2'], hiddenColumns: new Set(['col2']), filters: { col1: 'foo' }, dropdownFilters: { col2: new Set(['a', 'b']) }, filterMode: { col1: 'contains' }, showFilterRow: true, pinnedAnchor: 'col1', showRowNumbers: true, showTableInfo: true, customize: true, tableMaxHeight: '500px', tableMaxWidth: '75%', fontSize: 14, }; expect(buildSettings(state)).toMatchSnapshot(); }); it('converts dropdown filters to arrays', () => { const state = { currentTheme: 'lite', columnStyles: {}, columnOrder: [], hiddenColumns: new Set(), filters: {}, dropdownFilters: { col1: new Set(['x']) }, filterMode: {}, showFilterRow: false, pinnedAnchor: null, showRowNumbers: false, showTableInfo: false, customize: false, tableMaxHeight: 'unlimited', tableMaxWidth: 'unlimited', fontSize: 13, }; const result = buildSettings(state); expect(Array.isArray(result.dropdownFilters.col1)).toBe(true); expect(result.dropdownFilters.col1).toEqual(['x']); }); });