-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(formatter,#503): Do not ignore rows when headers is false
* Fixes issue where row contents were ignored if the first row is empty and headers is false
- Loading branch information
1 parent
e3165c7
commit 1560564
Showing
4 changed files
with
55 additions
and
7 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,34 @@ | ||
import { RecordingStream } from '../__fixtures__'; | ||
import { RowArray, write } from '../../src'; | ||
|
||
describe('Issue #503 - https://github.com/C2FO/fast-csv/issues/503', () => { | ||
it('should emit all columns after an empty row', () => { | ||
return new Promise((res, rej) => { | ||
const rs = new RecordingStream(); | ||
const data: RowArray[] = [[], ['something']]; | ||
|
||
write(data, { quote: false, headers: false, writeHeaders: false }) | ||
.pipe(rs) | ||
.on('error', rej) | ||
.on('finish', () => { | ||
expect(rs.data).toEqual(['\nsomething']); | ||
res(); | ||
}); | ||
}); | ||
}); | ||
|
||
it('should not assume first row is a header if header = false', () => { | ||
return new Promise((res, rej) => { | ||
const rs = new RecordingStream(); | ||
const data: RowArray[] = [['1'], [], ['1', '2', '3']]; | ||
|
||
write(data, { quote: false, headers: false, writeHeaders: false }) | ||
.pipe(rs) | ||
.on('error', rej) | ||
.on('finish', () => { | ||
expect(rs.data).toEqual(['1', '\n', '\n1,2,3']); | ||
res(); | ||
}); | ||
}); | ||
}); | ||
}); |
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