@@ -11,6 +11,7 @@ import {
1111 processInstrumentCSV ,
1212 zodObjectInterpreter
1313} from './utils' ;
14+ import { unparse } from 'papaparse' ;
1415
1516describe ( 'getZodTypeName' , ( ) => {
1617 it ( 'should parse a z.string()' , ( ) => {
@@ -165,11 +166,11 @@ describe('applyLineTransformsSet', () => {
165166
166167describe ( 'applyLineTransformsArray' , ( ) => {
167168 it ( 'should parse a line with a single set' , ( ) => {
168- expect ( applyLineTransformsArray ( 'recordArray (test1:1,test2:2;)' ) ) . toBe ( 'recordArray (test1:1++test2:2;)' ) ;
169+ expect ( applyLineTransformsArray ( 'RECORD_ARRAY (test1:1,test2:2;)' ) ) . toBe ( 'RECORD_ARRAY (test1:1++test2:2;)' ) ;
169170 } ) ;
170171 it ( 'should parse a line with a several sets and a number' , ( ) => {
171- expect ( applyLineTransformsArray ( 'recordArray (test1:1,test2:2;), 3, recordArray (test3:3,test4:4;)' ) ) . toBe (
172- 'recordArray (test1:1++test2:2;), 3, recordArray (test3:3++test4:4;)'
172+ expect ( applyLineTransformsArray ( 'RECORD_ARRAY (test1:1,test2:2;), 3, RECORD_ARRAY (test3:3,test4:4;)' ) ) . toBe (
173+ 'RECORD_ARRAY (test1:1++test2:2;), 3, RECORD_ARRAY (test3:3++test4:4;)'
173174 ) ;
174175 } ) ;
175176 it ( 'should return the line unchanged, if the line does not contain a set' , ( ) => {
@@ -193,7 +194,7 @@ describe('processInstrumentCSV', () => {
193194 foo : z . array (
194195 z . object ( {
195196 bar : z . string ( ) ,
196- foo : z . string ( )
197+ foo2 : z . string ( )
197198 } )
198199 )
199200 } )
@@ -216,8 +217,12 @@ describe('processInstrumentCSV', () => {
216217 await expect ( processInstrumentCSV ( file , mockInstrument ) ) . resolves . toMatchObject ( { success : true } ) ;
217218 } ) ;
218219
219- it ( 'should process a valid csv with a set' , async ( ) => {
220- const file = new File ( [ 'subjectID,date,foo\n1,2024-01-01,recordArray(bar:test1,foo:test2;)' ] , 'data.csv' , {
220+ it ( 'should process a valid csv with a record array' , async ( ) => {
221+ const papaString = unparse ( [
222+ [ 'subjectID' , 'date' , 'foo' ] ,
223+ [ '1' , '2024-01-01' , 'RECORD_ARRAY(bar:test1,foo2:test2;)' ]
224+ ] ) ;
225+ const file = new File ( [ papaString ] , 'data.csv' , {
221226 type : 'text/csv'
222227 } ) ;
223228 console . log ( await processInstrumentCSV ( file , mockInstrumentArray ) ) ;
0 commit comments