@@ -5,7 +5,7 @@ import { parseUrl } from '../src/url'
55import { toUrl } from '../src/utils'
66import { PARSE_TESTS } from './cases'
77
8- function * parseStringMock ( input : string ) : Generator < ParseResult , void , unknown > {
8+ function * parseMock ( input : string ) : Generator < ParseResult , void , unknown > {
99 const encoder = new TextEncoder ( )
1010 const bytes = encoder . encode ( input )
1111 yield {
@@ -29,7 +29,7 @@ describe('parseUrl, while mocking parseString, ', () => {
2929 let result = ''
3030 let bytes = 0
3131 // passing 'to: fileSize - 1' for Node.js bug: https://github.com/nodejs/node/issues/60382
32- for await ( const { row, meta : { offset, byteCount } } of parseUrl ( url , { chunkSize, lastByte : fileSize - 1 , parseString : parseStringMock } ) ) {
32+ for await ( const { row, meta : { offset, byteCount } } of parseUrl ( url , { chunkSize, lastByte : fileSize - 1 , parse : parseMock } ) ) {
3333 result += row
3434 expect ( offset ) . toBe ( bytes )
3535 bytes += byteCount
@@ -58,7 +58,7 @@ describe('parseUrl, while mocking parseString, ', () => {
5858 const { url, revoke } = toUrl ( text )
5959 let result = ''
6060 // implicit assertation in the loop: no exceptions thrown
61- for await ( const { row } of parseUrl ( url , { firstByte, lastByte, parseString : parseStringMock } ) ) {
61+ for await ( const { row } of parseUrl ( url , { firstByte, lastByte, parse : parseMock } ) ) {
6262 result += row [ 0 ]
6363 }
6464 revoke ( )
@@ -96,7 +96,7 @@ describe('parseUrl, while mocking parseString, ', () => {
9696 it ( 'keeps bytes between iterations, and might not consume all the bytes' , async ( ) => {
9797 const text = 'hello, csvremote!!!'
9898 const { url, fileSize, revoke } = toUrl ( text )
99- function * parseStringMock ( input : string ) {
99+ function * parseMock ( input : string ) {
100100 // only yield the first two bytes, decoded as text
101101 const encoder = new TextEncoder ( )
102102 const bytes = encoder . encode ( input )
@@ -122,7 +122,7 @@ describe('parseUrl, while mocking parseString, ', () => {
122122 for await ( const { row, meta : { offset, byteCount } } of parseUrl ( url , {
123123 chunkSize : 5 ,
124124 lastByte : fileSize - 1 ,
125- parseString : parseStringMock ,
125+ parse : parseMock ,
126126 } ) ) {
127127 i ++
128128 result += row [ 0 ]
@@ -137,7 +137,7 @@ describe('parseUrl, while mocking parseString, ', () => {
137137 it ( 'keeps bytes between iterations and might consume all the bytes' , async ( ) => {
138138 const text = 'hello, csvremote!!!'
139139 const { url, fileSize, revoke } = toUrl ( text )
140- function * parseStringMock ( text : string ) {
140+ function * parseMock ( text : string ) {
141141 // only process up to the first comma
142142 const splits = text . split ( ',' )
143143 const firstPart = splits [ 0 ] + ( splits . length > 1 ? ',' : '' )
@@ -163,7 +163,7 @@ describe('parseUrl, while mocking parseString, ', () => {
163163 for await ( const { row, meta : { offset, byteCount } } of parseUrl ( url , {
164164 chunkSize : 10 ,
165165 lastByte : fileSize - 1 ,
166- parseString : parseStringMock ,
166+ parse : parseMock ,
167167 } ) ) {
168168 expect ( offset ) . toBe ( bytes )
169169 if ( i === 0 ) {
@@ -184,7 +184,7 @@ describe('parseUrl, while mocking parseString, ', () => {
184184 it ( 'throws if parseString yields more bytes than provided' , async ( ) => {
185185 const text = 'hello, csvremote!!!'
186186 const { url, revoke } = toUrl ( text )
187- function * parseStringMock ( text : string ) {
187+ function * parseMock ( text : string ) {
188188 // yield more bytes than provided
189189 yield {
190190 row : [ ] ,
@@ -201,7 +201,7 @@ describe('parseUrl, while mocking parseString, ', () => {
201201 }
202202 const iterator = parseUrl ( url , {
203203 chunkSize : 5 ,
204- parseString : parseStringMock ,
204+ parse : parseMock ,
205205 } )
206206 await expect ( iterator . next ( ) ) . rejects . toThrow ( )
207207 revoke ( )
0 commit comments