Fix tests

This commit is contained in:
Adria Navarro 2024-02-12 12:25:56 +01:00
parent 2c26b55a7c
commit ffdfb731fb
1 changed files with 8 additions and 7 deletions

View File

@ -348,6 +348,7 @@ describe("/tables", () => {
describe("fetch", () => { describe("fetch", () => {
let testTable: Table let testTable: Table
const enrichViewSchemasMock = jest.spyOn(sdk.tables, "enrichViewSchemas")
beforeEach(async () => { beforeEach(async () => {
testTable = await config.createTable(testTable) testTable = await config.createTable(testTable)
@ -357,6 +358,10 @@ describe("/tables", () => {
delete testTable._rev delete testTable._rev
}) })
afterAll(() => {
enrichViewSchemasMock.mockRestore()
})
it("returns all the tables for that instance in the response body", async () => { it("returns all the tables for that instance in the response body", async () => {
const res = await request const res = await request
.get(`/api/tables`) .get(`/api/tables`)
@ -405,7 +410,7 @@ describe("/tables", () => {
it("should enrich the view schemas for viewsV2", async () => { it("should enrich the view schemas for viewsV2", async () => {
const tableId = config.table!._id! const tableId = config.table!._id!
jest.spyOn(sdk.tables, "enrichViewSchemas").mockImplementation(t => ({ enrichViewSchemasMock.mockImplementation(t => ({
...t, ...t,
views: { views: {
view1: { view1: {
@ -413,7 +418,7 @@ describe("/tables", () => {
name: "view1", name: "view1",
schema: {}, schema: {},
id: "new_view_id", id: "new_view_id",
tableId, tableId: t._id!,
}, },
}, },
})) }))
@ -480,11 +485,7 @@ describe("/tables", () => {
let testTable: Table let testTable: Table
beforeEach(async () => { beforeEach(async () => {
testTable = await config.createTable(testTable) testTable = await config.createTable()
})
afterEach(() => {
delete testTable._rev
}) })
it("returns a success response when a table is deleted.", async () => { it("returns a success response when a table is deleted.", async () => {