Add tests
This commit is contained in:
parent
c747881d73
commit
d12d6f5bef
|
@ -19,9 +19,14 @@ function priceTable(): Table {
|
||||||
name: "Price",
|
name: "Price",
|
||||||
constraints: {},
|
constraints: {},
|
||||||
},
|
},
|
||||||
Category: {
|
Currency: {
|
||||||
type: FieldType.STRING,
|
type: FieldType.STRING,
|
||||||
name: "Category",
|
name: "Currency",
|
||||||
|
constraints: {},
|
||||||
|
},
|
||||||
|
ItemId: {
|
||||||
|
type: FieldType.STRING,
|
||||||
|
name: "ItemId",
|
||||||
constraints: {
|
constraints: {
|
||||||
type: "string",
|
type: "string",
|
||||||
},
|
},
|
||||||
|
@ -117,25 +122,61 @@ describe("/v2/views", () => {
|
||||||
const result = await config.api.viewV2.getSchema(view.id)
|
const result = await config.api.viewV2.getSchema(view.id)
|
||||||
expect(result).toEqual({
|
expect(result).toEqual({
|
||||||
schema: {
|
schema: {
|
||||||
Price: { type: "number", name: "Price", constraints: {} },
|
Price: {
|
||||||
Category: {
|
type: "number",
|
||||||
|
name: "Price",
|
||||||
|
constraints: {},
|
||||||
|
},
|
||||||
|
Currency: {
|
||||||
type: "string",
|
type: "string",
|
||||||
name: "Category",
|
name: "Currency",
|
||||||
constraints: { type: "string" },
|
constraints: {},
|
||||||
|
},
|
||||||
|
ItemId: {
|
||||||
|
type: "string",
|
||||||
|
name: "ItemId",
|
||||||
|
constraints: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it("respects view column definition if exists", async () => {
|
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)
|
const result = await config.api.viewV2.getSchema(view.id)
|
||||||
expect(result).toEqual({
|
expect(result).toEqual({
|
||||||
schema: {
|
schema: {
|
||||||
Category: {
|
Price: {
|
||||||
|
type: "number",
|
||||||
|
name: "Price",
|
||||||
|
constraints: {},
|
||||||
|
},
|
||||||
|
ItemId: {
|
||||||
type: "string",
|
type: "string",
|
||||||
name: "Category",
|
name: "ItemId",
|
||||||
constraints: { type: "string" },
|
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: {},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue