1+ import path from "path" ;
12import { convertCSV } from "../csv-to-client-input" ;
23
34const invalidCases = [
4- { type : "invalid headers" , path : "test-data/invalid-headers.csv" , msg : "CSV headers do not match expected." } ,
5- { type : "empty rows" , path : "test-data/empty-rows.csv" , msg : "No client data provided." } ,
6- { type : "missing data in row" , path : "test-data/missing-data.csv" , msg : "Missing data in row for client ID: client-id-1." }
5+ { type : "invalid headers" , relativePath : "test-data/invalid-headers.csv" , msg : "CSV headers do not match expected." } ,
6+ { type : "empty rows" , relativePath : "test-data/empty-rows.csv" , msg : "No client data provided." } ,
7+ { type : "missing data in row" , relativePath : "test-data/missing-data.csv" , msg : "Missing data in row for client ID: client-id-1." }
78]
89
910describe ( "test that csv inputs get parsed as expected" , ( ) => {
1011
1112 it ( "should successfully parse csv" , ( ) => {
12- const filePath = "test-data/valid.csv" ;
13+ const filePath = path . join ( __dirname , "test-data/valid.csv" ) ;
1314
1415 const result = convertCSV ( filePath ) ;
1516
@@ -19,8 +20,11 @@ describe("test that csv inputs get parsed as expected", () => {
1920 expect ( result . map ( item => item . clientId ) ) . toEqual ( ( [ "1" , "2" , "3" , "4" ] ) ) ;
2021 } ) ;
2122
22- it . each ( invalidCases ) ( 'should throw error: "%s" for case: %s:' , ( { msg, type, path } ) => {
23- expect ( ( ) => convertCSV ( path ) ) . toThrow ( msg ) ;
23+ it . each ( invalidCases ) ( 'should throw error: "%s" for case: %s:' , ( { msg, type, relativePath } ) => {
24+
25+ const filePath = path . join ( __dirname , relativePath ) ;
26+
27+ expect ( ( ) => convertCSV ( filePath ) ) . toThrow ( msg ) ;
2428 } ) ;
2529
2630} ) ;
0 commit comments