-
-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: lost headers after broken lines (#151)
* fix: strict false - broken header keys * fix: do not replace global headers * fix: if header exists object properties are set * fix: move added properties to end * fix: add missing informations
- Loading branch information
1 parent
dd5123b
commit a72f822
Showing
7 changed files
with
117 additions
and
6 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
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,4 @@ | ||
a,b,c | ||
1,2,3 | ||
4,5 | ||
6,7,8 |
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 @@ | ||
a,b,c | ||
1,2,3 | ||
4,5,6,7 | ||
8,9,10 |
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,57 @@ | ||
# Snapshot report for `test/strictNo.test.js` | ||
|
||
The actual snapshot is saved in `strictNo.test.js.snap`. | ||
|
||
Generated by [AVA](https://ava.li). | ||
|
||
## strict: false - less columns | ||
|
||
> first row | ||
{ | ||
a: '1', | ||
b: '2', | ||
c: '3', | ||
} | ||
|
||
> broken row | ||
{ | ||
a: '4', | ||
b: '5', | ||
} | ||
|
||
> last row | ||
{ | ||
a: '6', | ||
b: '7', | ||
c: '8', | ||
} | ||
|
||
## strict: false - more columns | ||
|
||
> first row | ||
{ | ||
a: '1', | ||
b: '2', | ||
c: '3', | ||
} | ||
|
||
> broken row | ||
{ | ||
_3: '7', | ||
a: '4', | ||
b: '5', | ||
c: '6', | ||
} | ||
|
||
> last row | ||
{ | ||
a: '8', | ||
b: '9', | ||
c: '10', | ||
} |
Binary file not shown.
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,41 @@ | ||
const test = require('ava') | ||
|
||
const { collect } = require('./helpers/helper') | ||
|
||
test.cb('strict: false - more columns', (t) => { | ||
const verify = (err, lines) => { | ||
const headersFirstLine = Object.keys(lines[0]) | ||
const headersBrokenLine = Object.keys(lines[1]) | ||
const headersLastLine = Object.keys(lines[2]) | ||
t.false(err, 'no err') | ||
t.deepEqual(headersFirstLine, headersLastLine) | ||
t.deepEqual(headersBrokenLine, ['a', 'b', 'c', '_3']) | ||
t.snapshot(lines[0], 'first row') | ||
t.snapshot(lines[1], 'broken row') | ||
t.snapshot(lines[2], 'last row') | ||
t.is(lines.length, 3, '3 rows') | ||
t.is(headersBrokenLine.length, 4, '4 columns') | ||
t.end() | ||
} | ||
|
||
collect('strict-false-more-columns', { strict: false }, verify) | ||
}) | ||
|
||
test.cb('strict: false - less columns', (t) => { | ||
const verify = (err, lines) => { | ||
const headersFirstLine = Object.keys(lines[0]) | ||
const headersBrokenLine = Object.keys(lines[1]) | ||
const headersLastLine = Object.keys(lines[2]) | ||
t.false(err, 'no err') | ||
t.deepEqual(headersFirstLine, headersLastLine) | ||
t.deepEqual(headersBrokenLine, ['a', 'b']) | ||
t.snapshot(lines[0], 'first row') | ||
t.snapshot(lines[1], 'broken row') | ||
t.snapshot(lines[2], 'last row') | ||
t.is(lines.length, 3, '3 rows') | ||
t.is(headersBrokenLine.length, 2, '2 columns') | ||
t.end() | ||
} | ||
|
||
collect('strict-false-less-columns', { strict: false }, verify) | ||
}) |