Improve test

This commit is contained in:
Adria Navarro 2023-05-23 10:17:42 +02:00
parent 5ea19986b1
commit b7b604ca00
1 changed files with 11 additions and 8 deletions

View File

@ -18,15 +18,14 @@ const { GoogleSpreadsheet } = require("google-spreadsheet")
const sheetsByTitle: { [title: string]: GoogleSpreadsheetWorksheet } = {}
const sheetsByIndex: GoogleSpreadsheetWorksheet[] = []
GoogleSpreadsheet.mockImplementation(() => {
return {
const mockGoogleIntegration = {
useOAuth2Client: jest.fn(),
loadInfo: jest.fn(),
sheetsByTitle,
sheetsByIndex,
}
})
}
GoogleSpreadsheet.mockImplementation(() => mockGoogleIntegration)
import { structures } from "@budibase/backend-core/tests"
import TestConfiguration from "../../tests/utilities/TestConfiguration"
@ -55,6 +54,8 @@ describe("Google Sheets Integration", () => {
},
})
await config.init()
jest.clearAllMocks()
})
function createBasicTable(name: string, columns: string[]): Table {
@ -137,6 +138,8 @@ describe("Google Sheets Integration", () => {
}
const res = await integration.getTableNames()
expect(mockGoogleIntegration.loadInfo).toBeCalledTimes(1)
expect(res).toEqual(sheetNames)
})
})