-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added test machinery and snapshots, build
- Loading branch information
Showing
7 changed files
with
2,644 additions
and
1,040 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
presets: ['@babel/preset-env', '@babel/preset-react'], | ||
}; | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Renders basic CSVReader 1`] = ` | ||
<div | ||
className="csv-reader-input" | ||
> | ||
<input | ||
accept=".csv, text/csv" | ||
className="csv-input" | ||
id={null} | ||
onChange={[Function]} | ||
style={Object {}} | ||
type="file" | ||
/> | ||
</div> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react' | ||
import renderer from 'react-test-renderer' | ||
import CSVReader from './index' | ||
|
||
test('Renders basic CSVReader', () => { | ||
const component = renderer.create(<CSVReader onFileLoaded={() => {}} />) | ||
|
||
let tree = component.toJSON() | ||
expect(tree).toMatchSnapshot() | ||
}) | ||
|
||
test('Renders CSVReader with all custom props', () => { | ||
const papaparseOptions = { | ||
header: true, | ||
dynamicTyping: true, | ||
skipEmptyLines: true, | ||
transformHeader: header => header.toLowerCase().replace(/\W/g, '_'), | ||
} | ||
|
||
const component = renderer.create( | ||
<CSVReader | ||
accept=".csv, text/csv, .tsv, test/tsv" | ||
cssClass="custom-csv-reader" | ||
cssInputClass="custom-csv-input" | ||
fileEncoding="iso-8859-1" | ||
inputId="react-csv-reader" | ||
inputStyle={{ color: 'red' }} | ||
label="Select CSV with secret Death Star statistics" | ||
onError={e => console.error(e)} | ||
onFileLoaded={(data, fileName) => console.log(data, fileName)} | ||
parserOptions={papaparseOptions} | ||
/>, | ||
) | ||
|
||
let tree = component.toJSON() | ||
expect(tree).toMatchSnapshot() | ||
}) |
Oops, something went wrong.