Skip to content

Commit

Permalink
Added tests for #174 and #165
Browse files Browse the repository at this point in the history
  • Loading branch information
doug-martin committed Jul 10, 2019
1 parent 5274a96 commit ed0f862
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions test/issues/issue174.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { EOL } from 'os';
import * as assert from 'assert';
import { Parser } from '../../src/parser/parser';
import { ParserOptions, ParserOptionsArgs } from '../../src/parser';


describe('Issue #174 - https://github.com/C2FO/fast-csv/issues/174', () => {
const createParser = (parserOptions: ParserOptionsArgs = {}) => new Parser(new ParserOptions(parserOptions));
const runParser = (data: string, hasMoreData: boolean, parser: Parser) => parser.parse(data, hasMoreData);

const CSV_CONTENT = [
'f1,f2,f3',
'1,text, a1',
'2,text, a2 ',
].join(EOL);

it('skip trailing whitespace after a quoted field', () => {
const parser = createParser({ headers: true });
const parsedData = runParser(CSV_CONTENT, false, parser);
assert.deepStrictEqual(parsedData, {
line: '',
rows: [
[ 'f1', 'f2', 'f3' ],
[ '1', 'text', ' a1' ],
[ '2', 'text', ' a2 ' ],
],
});
});
});
2 changes: 1 addition & 1 deletion test/issues/issue214.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { EOL } from 'os';
import * as assert from 'assert';
import * as csv from '../../src';
import { RowMap } from '../../build/src/parser';
import { RowMap } from '../../src/parser';


describe('Issue #214 - https://github.com/C2FO/fast-csv/issues/214', () => {
Expand Down

0 comments on commit ed0f862

Please sign in to comment.