Add tests

This commit is contained in:
Adria Navarro 2023-07-20 09:58:01 +02:00
parent c747881d73
commit d12d6f5bef
1 changed files with 51 additions and 10 deletions

View File

@ -19,9 +19,14 @@ function priceTable(): Table {
name: "Price",
constraints: {},
},
Category: {
Currency: {
type: FieldType.STRING,
name: "Category",
name: "Currency",
constraints: {},
},
ItemId: {
type: FieldType.STRING,
name: "ItemId",
constraints: {
type: "string",
},
@ -117,25 +122,61 @@ describe("/v2/views", () => {
const result = await config.api.viewV2.getSchema(view.id)
expect(result).toEqual({
schema: {
Price: { type: "number", name: "Price", constraints: {} },
Category: {
Price: {
type: "number",
name: "Price",
constraints: {},
},
Currency: {
type: "string",
name: "Category",
constraints: { type: "string" },
name: "Currency",
constraints: {},
},
ItemId: {
type: "string",
name: "ItemId",
constraints: {
type: "string",
},
},
},
})
})
it("respects view column definition if exists", async () => {
const view = await config.api.viewV2.create({ columns: ["Category"] })
const view = await config.api.viewV2.create({
columns: ["Price", "ItemId"],
})
const result = await config.api.viewV2.getSchema(view.id)
expect(result).toEqual({
schema: {
Category: {
Price: {
type: "number",
name: "Price",
constraints: {},
},
ItemId: {
type: "string",
name: "Category",
constraints: { type: "string" },
name: "ItemId",
constraints: {
type: "string",
},
},
},
})
})
it("respects view column definition if exists", async () => {
const view = await config.api.viewV2.create({
columns: ["Price", "innexistingColumn"],
})
const result = await config.api.viewV2.getSchema(view.id)
expect(result).toEqual({
schema: {
Price: {
type: "number",
name: "Price",
constraints: {},
},
},
})