Skip to content

Commit 3aa9db2

Browse files
committed
add test with fromAsync
1 parent 613dc75 commit 3aa9db2

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

tests/examples.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { describe, expect, it } from 'vitest'
22

33
import { parseURL } from '../src'
4+
import type { ParseResult } from '../src/types'
45

56
describe('README examples', () => {
67
it('parses a remote CSV file', async () => {
@@ -10,4 +11,12 @@ describe('README examples', () => {
1011
}
1112
expect(rows).toEqual([['A', 'B', 'C'], ['X', 'Y', 'Z']])
1213
})
14+
it('parses a remote CSV, and we can use Array.fromAsync for convenience', async () => {
15+
// @ts-expect-error ts(2345) - fromAsync is available now
16+
const rows = await Array.fromAsync(
17+
parseURL('https://data.source.coop/severo/csv-papaparse-test-files/sample.csv'),
18+
async (result: ParseResult) => result.row,
19+
)
20+
expect(rows).toEqual([['A', 'B', 'C'], ['X', 'Y', 'Z']])
21+
})
1322
})

0 commit comments

Comments
 (0)