From 9371f19419ae109696b07e82d17860fadfa9ee2a Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 24 Jan 2023 17:48:49 +0000 Subject: [PATCH] Remove mocks --- packages/server/__mocks__/aws-sdk.ts | 80 ------------------- .../src/api/routes/tests/backup.spec.ts | 10 --- .../src/tests/utilities/TestConfiguration.ts | 15 +++- 3 files changed, 11 insertions(+), 94 deletions(-) delete mode 100644 packages/server/__mocks__/aws-sdk.ts diff --git a/packages/server/__mocks__/aws-sdk.ts b/packages/server/__mocks__/aws-sdk.ts deleted file mode 100644 index 2efbd303f2..0000000000 --- a/packages/server/__mocks__/aws-sdk.ts +++ /dev/null @@ -1,80 +0,0 @@ -module AwsMock { - const aws: any = {} - - const response = (body: any) => () => ({ promise: () => body }) - - function DocumentClient() { - // @ts-ignore - this.put = jest.fn(response({})) - // @ts-ignore - this.query = jest.fn( - response({ - Items: [], - }) - ) - // @ts-ignore - this.scan = jest.fn( - response({ - Items: [ - { - Name: "test", - }, - ], - }) - ) - // @ts-ignore - this.get = jest.fn(response({})) - // @ts-ignore - this.update = jest.fn(response({})) - // @ts-ignore - this.delete = jest.fn(response({})) - } - - function S3() { - // @ts-ignore - this.listObjects = jest.fn( - response({ - Contents: {}, - }) - ) - - // @ts-ignore - this.createBucket = jest.fn( - response({ - Contents: {}, - }) - ) - - // @ts-ignore - this.deleteObjects = jest.fn( - response({ - Contents: {}, - }) - ) - - // @ts-ignore - this.getSignedUrl = (operation, params) => { - return `http://test.com/${params.Bucket}/${params.Key}` - } - - // @ts-ignore - this.headBucket = jest.fn( - response({ - Contents: {}, - }) - ) - - // @ts-ignore - this.upload = jest.fn( - response({ - Contents: {}, - }) - ) - } - - aws.DynamoDB = { DocumentClient } - aws.S3 = S3 - aws.config = { update: jest.fn() } - - module.exports = aws -} diff --git a/packages/server/src/api/routes/tests/backup.spec.ts b/packages/server/src/api/routes/tests/backup.spec.ts index 72ccb41598..7ab4f2b531 100644 --- a/packages/server/src/api/routes/tests/backup.spec.ts +++ b/packages/server/src/api/routes/tests/backup.spec.ts @@ -1,13 +1,3 @@ -jest.mock("@budibase/backend-core", () => { - const core = jest.requireActual("@budibase/backend-core") - return { - ...core, - objectStore: { - budibaseTempDir: core.objectStore.budibaseTempDir, - }, - } -}) - import * as setup from "./utilities" import { events } from "@budibase/backend-core" import sdk from "../../../sdk" diff --git a/packages/server/src/tests/utilities/TestConfiguration.ts b/packages/server/src/tests/utilities/TestConfiguration.ts index 7ac20e14ef..35535d5aaa 100644 --- a/packages/server/src/tests/utilities/TestConfiguration.ts +++ b/packages/server/src/tests/utilities/TestConfiguration.ts @@ -137,15 +137,22 @@ class TestConfiguration { return this.createApp(appName) } - end() { + async end() { if (!this) { return } - if (this.server) { - this.server.close() - } if (this.allApps) { cleanup(this.allApps.map(app => app.appId)) + + await this._req( + null, + { appId: this.prodApp.appId }, + controllers.app.destroy + ) + } + + if (this.server) { + this.server.close() } }