@dpkit/core
Version:
Fast TypeScript data management framework built on top of the Data Package standard and Polars DataFrames
34 lines (29 loc) • 855 B
text/typescript
import { join } from "node:path"
import { describe, expect, expectTypeOf, it } from "vitest"
import type { Schema } from "./Schema.ts"
import { loadSchema } from "./load.ts"
describe("loadSchema", () => {
const getFixturePath = (name: string) => join(__dirname, "fixtures", name)
const expectedSchema = {
fields: [
{
name: "id",
type: "integer",
},
{
name: "name",
type: "string",
},
],
}
it("loads a schema from a local file path", async () => {
const schema = await loadSchema(getFixturePath("schema.json"))
expectTypeOf(schema).toEqualTypeOf<Schema>()
expect(schema).toEqual(expectedSchema)
})
it("throws an error when schema is invalid", async () => {
await expect(
loadSchema(getFixturePath("schema-invalid.json")),
).rejects.toThrow()
})
})