From cbd3b79dee48ff1ee62a03969dd03a59fae57519 Mon Sep 17 00:00:00 2001 From: Wlad Meixner Date: Thu, 9 Apr 2020 21:56:01 +0200 Subject: [PATCH] add csv tests --- types/react-bootstrap-table-next/index.d.ts | 5 ++- .../react-bootstrap-table2-toolkit-tests.tsx | 34 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/types/react-bootstrap-table-next/index.d.ts b/types/react-bootstrap-table-next/index.d.ts index 08bcb8333f..0059a7037d 100644 --- a/types/react-bootstrap-table-next/index.d.ts +++ b/types/react-bootstrap-table-next/index.d.ts @@ -139,7 +139,10 @@ export interface ColumnDescription { /** * CSV Column options only used with the toolkit provider */ - csvType?: String | Number; + /** + * export csv cell type can be Number or String + */ + csvType?: object; csvFormatter?: ColumnFormatter; /** * csvText defaults to column.text diff --git a/types/react-bootstrap-table2-toolkit/react-bootstrap-table2-toolkit-tests.tsx b/types/react-bootstrap-table2-toolkit/react-bootstrap-table2-toolkit-tests.tsx index 633252185a..31dc0eb41d 100644 --- a/types/react-bootstrap-table2-toolkit/react-bootstrap-table2-toolkit-tests.tsx +++ b/types/react-bootstrap-table2-toolkit/react-bootstrap-table2-toolkit-tests.tsx @@ -107,6 +107,40 @@ render( * Toolkit CSV export test */ +const csvColumns: Array> = [ + { dataField: 'id', align: 'center', sort: true, text: 'Product ID' }, + { dataField: 'name', align: 'center', sort: true, text: 'Product Name' }, + { + isDummyField: true, + dataField: '', + sort: true, + text: 'Product Name', + }, + { + dataField: 'price', + sort: true, + formatter: priceFormatter, + text: 'Product Price', + headerFormatter: priceHeaderFormatter, + csvExport: false, + }, + /** + * test optional dataField for dummyFields + */ + { + isDummyField: true, + dataField: '', + sort: true, + formatter: priceFormatter, + text: 'Product Price', + headerFormatter: priceHeaderFormatter, + csvType: Number, + csvFormatter: value => value, + csvText: 'Price', + csvExport: true, + }, +]; + render(