From b7b604ca0005c8467aaa5f1e4713e6eb85ab536f Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 23 May 2023 10:17:42 +0200 Subject: [PATCH] Improve test --- .../integrations/tests/googlesheets.spec.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/server/src/integrations/tests/googlesheets.spec.ts b/packages/server/src/integrations/tests/googlesheets.spec.ts index 7f6c641aa9..5aabb13afc 100644 --- a/packages/server/src/integrations/tests/googlesheets.spec.ts +++ b/packages/server/src/integrations/tests/googlesheets.spec.ts @@ -18,15 +18,14 @@ const { GoogleSpreadsheet } = require("google-spreadsheet") const sheetsByTitle: { [title: string]: GoogleSpreadsheetWorksheet } = {} const sheetsByIndex: GoogleSpreadsheetWorksheet[] = [] +const mockGoogleIntegration = { + useOAuth2Client: jest.fn(), + loadInfo: jest.fn(), + sheetsByTitle, + sheetsByIndex, +} -GoogleSpreadsheet.mockImplementation(() => { - return { - 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) }) })