test(csv-loader): add test for multiple comment lines at the beginning
with reverse references
This commit is contained in:
parent
9dd4f60c2d
commit
be8eb277d4
|
|
@ -1164,6 +1164,29 @@ describe("parseCsv - reverse reference resolution", () => {
|
|||
expect(result.reverseReferences).toHaveLength(1);
|
||||
expect(result.data[0]).toHaveProperty("orders");
|
||||
});
|
||||
|
||||
it("should handle multiple comment lines including plain comments and reverse references", () => {
|
||||
const csv = [
|
||||
"# id: id of user",
|
||||
"# orders: list of related orders",
|
||||
"# orders := ~order(user)",
|
||||
"id,name",
|
||||
"string,string",
|
||||
"u01,Alice",
|
||||
"u02,Bob",
|
||||
].join("\n");
|
||||
|
||||
const result = parseCsv(csv, {
|
||||
emitTypes: false,
|
||||
currentFilePath: path.join(fixturesDir, "test.csv"),
|
||||
});
|
||||
|
||||
expect(result.reverseReferences).toHaveLength(1);
|
||||
expect(result.reverseReferences[0].fieldName).toBe("orders");
|
||||
expect(result.data).toHaveLength(2);
|
||||
expect(result.data[0].id).toBe("u01");
|
||||
expect(result.data[1].id).toBe("u02");
|
||||
});
|
||||
});
|
||||
|
||||
describe("parseCsv - reverse reference with resolveReferences: false", () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue