1
0
Fork 0
mirror of synced 2024-10-04 03:54:37 +13:00

Add tests

This commit is contained in:
Adria Navarro 2023-07-21 12:38:02 +02:00
parent 3f2fa1a8dc
commit a65e69e614

View file

@ -271,6 +271,89 @@ describe("/tables", () => {
])
)
})
it("should fetch the default schema if not overriden", async () => {
const tableId = config.table!._id!
const views = [
await config.api.viewV2.create({ tableId }),
await config.api.viewV2.create({ tableId, columns: ["name"] }),
]
const res = await config.api.table.fetch()
expect(res).toEqual(
expect.arrayContaining([
expect.objectContaining({
_id: tableId,
views: {
[views[0].name]: {
...views[0],
schema: {
name: {
type: "string",
name: "name",
constraints: {
type: "string",
},
},
description: {
type: "string",
name: "description",
constraints: {
type: "string",
},
},
},
},
[views[1].name]: {
...views[1],
schema: {
name: {
type: "string",
name: "name",
constraints: {
type: "string",
},
},
},
},
},
}),
])
)
})
it("should fetch the default schema if not overriden", async () => {
const tableId = config.table!._id!
const view = await config.api.viewV2.create({
tableId,
columns: ["unnexisting", "name"],
})
const res = await config.api.table.fetch()
expect(res).toEqual(
expect.arrayContaining([
expect.objectContaining({
_id: tableId,
views: {
[view.name]: {
...view,
schema: {
name: {
type: "string",
name: "name",
constraints: {
type: "string",
},
},
},
},
},
}),
])
)
})
})
describe("indexing", () => {