Skip to content

Commit 4cd4600

Browse files
committed
build(csv-parse): build and write test after info ts definition
1 parent 2dd2a92 commit 4cd4600

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

packages/csv-parse/dist/cjs/index.d.cts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ export interface Info {
234234
* Number of non uniform records when `relax_column_count` is true.
235235
*/
236236
readonly invalid_field_length: number;
237+
/**
238+
* Normalized verion of `options.columns` when `options.columns` is true, boolean otherwise.
239+
*/
240+
readonly columns: boolean | { name: string }[] | { disabled: true }[];
237241
}
238242

239243
export type CsvErrorCode =

packages/csv-parse/dist/esm/index.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ export interface Info {
234234
* Number of non uniform records when `relax_column_count` is true.
235235
*/
236236
readonly invalid_field_length: number;
237+
/**
238+
* Normalized verion of `options.columns` when `options.columns` is true, boolean otherwise.
239+
*/
240+
readonly columns: boolean | { name: string }[] | { disabled: true }[];
237241
}
238242

239243
export type CsvErrorCode =

packages/csv-parse/test/api.types.sync.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,13 @@ describe('API Types', () => {
7979

8080
it('Info', () => {
8181
const info: Info = {
82+
bytes: 1,
83+
columns: true,
8284
comment_lines: 1,
8385
empty_lines: 1,
86+
invalid_field_length: 1,
8487
lines: 1,
8588
records: 1,
86-
bytes: 1,
87-
invalid_field_length: 1,
8889
};
8990
return info;
9091
})

packages/csv-parse/test/api.types.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ describe('API Types', () => {
8888
describe('Info', () => {
8989

9090
const fakeinfo = {
91-
bytes: 1,
91+
bytes: 1, columns: true,
9292
comment_lines: 1, empty_lines: 1,
9393
invalid_field_length: 1, lines: 1, records: 1
9494
}
@@ -128,6 +128,27 @@ describe('API Types', () => {
128128
const invalid_field_length: number = info.invalid_field_length
129129
invalid_field_length
130130
})
131+
132+
it('columns may be a boolean or an array', () => {
133+
// Boolean
134+
const infoBoolean: Info = {
135+
bytes: 1, columns: true,
136+
comment_lines: 1, empty_lines: 1,
137+
invalid_field_length: 1, lines: 1, records: 1
138+
}
139+
// Array with name = <string>
140+
const infoName: Info = {
141+
bytes: 1, columns: [{name: 'a column'}],
142+
comment_lines: 1, empty_lines: 1,
143+
invalid_field_length: 1, lines: 1, records: 1
144+
}
145+
// Array with disabled = true
146+
const infoDisabled: Info = {
147+
bytes: 1, columns: [{disabled: true}],
148+
comment_lines: 1, empty_lines: 1,
149+
invalid_field_length: 1, lines: 1, records: 1
150+
}
151+
})
131152

132153
})
133154

0 commit comments

Comments
 (0)