|
| 1 | +const test = require('ava') |
| 2 | + |
| 3 | +const { collect } = require('./helpers/helper') |
| 4 | + |
| 5 | +test.cb('custom quote character', (t) => { |
| 6 | + const verify = (err, lines) => { |
| 7 | + t.false(err, 'no err') |
| 8 | + t.snapshot(lines[0], 'first row') |
| 9 | + t.snapshot(lines[1], 'second row') |
| 10 | + t.is(lines.length, 2, '2 rows') |
| 11 | + t.end() |
| 12 | + } |
| 13 | + |
| 14 | + collect('custom_quote_character.csv', { quote: "'" }, verify) |
| 15 | +}) |
| 16 | + |
| 17 | +test.cb('custom quote and escape character', (t) => { |
| 18 | + const verify = (err, lines) => { |
| 19 | + t.false(err, 'no err') |
| 20 | + t.snapshot(lines[0], 'first row') |
| 21 | + t.snapshot(lines[1], 'second row') |
| 22 | + t.snapshot(lines[2], 'third row') |
| 23 | + t.is(lines.length, 3, '3 rows') |
| 24 | + t.end() |
| 25 | + } |
| 26 | + |
| 27 | + collect('custom_quote_and_escape_character.csv', { quote: "'", escape: '\\' }, verify) |
| 28 | +}) |
| 29 | + |
| 30 | +test.cb('custom quote character with default escaped value', (t) => { |
| 31 | + const verify = (err, lines) => { |
| 32 | + t.false(err, 'no err') |
| 33 | + t.snapshot(lines[0], 'first row') |
| 34 | + t.snapshot(lines[1], 'second row') |
| 35 | + t.snapshot(lines[2], 'third row') |
| 36 | + t.is(lines.length, 3, '3 rows') |
| 37 | + t.end() |
| 38 | + } |
| 39 | + |
| 40 | + collect('custom_quote_character_default_escape.csv', { quote: "'" }, verify) |
| 41 | +}) |
0 commit comments