Skip to content

Commit 56499f1

Browse files
committed
fix tests
1 parent d9375d4 commit 56499f1

3 files changed

Lines changed: 2 additions & 38 deletions

File tree

tests/cases.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
import { RECORD_SEP, UNIT_SEP } from '../src/options/constants.js'
22

3-
export const cases = [
4-
{
5-
description: 'One row',
6-
text: 'A,b,c',
7-
expected: {
8-
rows: [['A', 'b', 'c']],
9-
errors: [],
10-
meta: { delimiter: ',', renamedHeaders: null },
11-
},
12-
},
13-
]
14-
153
export const CORE_PARSER_TESTS = [
164
{
175
description: 'One row',
@@ -198,8 +186,6 @@ export const CORE_PARSER_TESTS = [
198186
type: 'Quotes',
199187
code: 'MissingQuotes',
200188
message: 'Quoted field unterminated',
201-
row: 0,
202-
index: 3,
203189
}],
204190
},
205191
},
@@ -213,8 +199,6 @@ export const CORE_PARSER_TESTS = [
213199
type: 'Quotes',
214200
code: 'InvalidQuotes',
215201
message: 'Trailing quote on quoted field is malformed',
216-
row: 0,
217-
index: 1,
218202
}],
219203
},
220204
},
@@ -228,15 +212,11 @@ export const CORE_PARSER_TESTS = [
228212
type: 'Quotes',
229213
code: 'InvalidQuotes',
230214
message: 'Trailing quote on quoted field is malformed',
231-
row: 0,
232-
index: 3,
233215
},
234216
{
235217
type: 'Quotes',
236218
code: 'MissingQuotes',
237219
message: 'Quoted field unterminated',
238-
row: 0,
239-
index: 3,
240220
}],
241221
},
242222
},
@@ -250,15 +230,11 @@ export const CORE_PARSER_TESTS = [
250230
type: 'Quotes',
251231
code: 'InvalidQuotes',
252232
message: 'Trailing quote on quoted field is malformed',
253-
row: 0,
254-
index: 3,
255233
},
256234
{
257235
type: 'Quotes',
258236
code: 'MissingQuotes',
259237
message: 'Quoted field unterminated',
260-
row: 0,
261-
index: 3,
262238
}],
263239
},
264240
},
@@ -272,15 +248,11 @@ export const CORE_PARSER_TESTS = [
272248
type: 'Quotes',
273249
code: 'InvalidQuotes',
274250
message: 'Trailing quote on quoted field is malformed',
275-
row: 0,
276-
index: 3,
277251
},
278252
{
279253
type: 'Quotes',
280254
code: 'MissingQuotes',
281255
message: 'Quoted field unterminated',
282-
row: 0,
283-
index: 3,
284256
}],
285257
},
286258
},
@@ -714,7 +686,6 @@ export const PARSE_TESTS = [
714686
// type: 'FieldMismatch',
715687
// code: 'TooFewFields',
716688
// message: 'Too few fields: expected 3 fields but parsed 2',
717-
// row: 0,
718689
// }],
719690
// },
720691
// },
@@ -728,7 +699,6 @@ export const PARSE_TESTS = [
728699
// type: 'FieldMismatch',
729700
// code: 'TooManyFields',
730701
// message: 'Too many fields: expected 3 fields but parsed 5',
731-
// row: 0,
732702
// }],
733703
// },
734704
// },

tests/parser.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe('Papaparse core parser tests', () => {
99
const config = test.config || {}
1010
const result = [...parse(test.text, config)]
1111
const data = result.map(({ row }) => row)
12-
const errors = result.flatMap(({ errors: rowErrors }, row) => rowErrors.map(error => ({ ...error, row })))
12+
const errors = result.flatMap(({ errors }) => errors)
1313
expect(data).toEqual(test.expected.data)
1414
expect(errors).toEqual(test.expected.errors)
1515
if (test.expected.meta?.charCount !== undefined) {

tests/text.test.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest'
22

33
import { parseText } from '../src/text'
44
import { testEmptyLine } from '../src/utils'
5-
import { cases, PARSE_TESTS } from './cases'
5+
import { PARSE_TESTS } from './cases'
66

77
describe('parseText', () => {
88
it('decodes a string', () => {
@@ -27,12 +27,6 @@ describe('parseText', () => {
2727
// For now: only one iteration per chunk
2828
expect(i).toBe(1)
2929
})
30-
it.for(cases)('$description', ({ text, expected }) => {
31-
const results = [...parseText(text)]
32-
33-
expect(results.map(({ row }) => row)).toEqual(expected.rows)
34-
// TODO(SL): check the metadata and the errors too
35-
})
3630

3731
it.for([
3832
{ description: '', text: 'a,b,c\n\nd,e,f', expected: [['a', 'b', 'c'], ['d', 'e', 'f']] },

0 commit comments

Comments
 (0)