Release query Tools v0.1.0
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { parseData } from "../../src/core/data";
|
||||
describe("data parser", () => {
|
||||
it("parses CSV inference and NDJSON", () => {
|
||||
expect(parseData("name,n\nAda,3", "csv").rows[0]).toEqual({
|
||||
name: "Ada",
|
||||
n: 3,
|
||||
});
|
||||
expect(parseData('{"a":1}\n{"a":2}', "ndjson").rows).toHaveLength(2);
|
||||
});
|
||||
it("converts static XML and rejects entities", () => {
|
||||
expect(
|
||||
parseData(
|
||||
"<items><item id='1'>A</item><item id='2'>B</item></items>",
|
||||
"xml",
|
||||
).root,
|
||||
).toEqual({
|
||||
items: {
|
||||
item: [
|
||||
{ "@id": "1", "#text": "A" },
|
||||
{ "@id": "2", "#text": "B" },
|
||||
],
|
||||
},
|
||||
});
|
||||
expect(() =>
|
||||
parseData('<!DOCTYPE x [<!ENTITY y "z">]><x>&y;</x>', "xml"),
|
||||
).toThrow(/entity/iu);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user