ensure fetch and aws are always mocked
This commit is contained in:
parent
f7af8621d5
commit
f48ff01045
|
@ -0,0 +1,15 @@
|
|||
const mockS3 = {
|
||||
headBucket: jest.fn().mockReturnThis(),
|
||||
deleteObject: jest.fn().mockReturnThis(),
|
||||
deleteObjects: jest.fn().mockReturnThis(),
|
||||
createBucket: jest.fn().mockReturnThis(),
|
||||
listObjects: jest.fn().mockReturnThis(),
|
||||
promise: jest.fn().mockReturnThis(),
|
||||
catch: jest.fn(),
|
||||
}
|
||||
|
||||
const AWS = {
|
||||
S3: jest.fn(() => mockS3),
|
||||
}
|
||||
|
||||
export default AWS
|
|
@ -0,0 +1 @@
|
|||
jest.mock("node-fetch", () => jest.fn())
|
|
@ -1,7 +1,6 @@
|
|||
// Mock data
|
||||
|
||||
const mockFetch = require("node-fetch")
|
||||
const { data } = require("./utilities/mock-data")
|
||||
|
||||
const issuer = "mockIssuer"
|
||||
const sub = "mockSub"
|
||||
const profile = {
|
||||
|
@ -39,8 +38,6 @@ describe("oidc", () => {
|
|||
const mockStrategy = require("@techpass/passport-openidconnect").Strategy
|
||||
|
||||
// mock the request to retrieve the oidc configuration
|
||||
jest.mock("node-fetch")
|
||||
const mockFetch = require("node-fetch")
|
||||
mockFetch.mockReturnValue({
|
||||
ok: true,
|
||||
json: () => oidcConfigUrlResponse
|
||||
|
|
|
@ -10,6 +10,9 @@ env._set("SELF_HOSTED", "1")
|
|||
env._set("NODE_ENV", "jest")
|
||||
env._set("JWT_SECRET", "test-jwtsecret")
|
||||
env._set("LOG_LEVEL", "silent")
|
||||
env._set("MINIO_URL", "http://localhost")
|
||||
env._set("MINIO_ACCESS_KEY", "test")
|
||||
env._set("MINIO_SECRET_KEY", "test")
|
||||
|
||||
global.console.log = jest.fn() // console.log are ignored in tests
|
||||
|
||||
|
|
|
@ -8,6 +8,9 @@ env._set("CLIENT_ID", "test-client-id")
|
|||
env._set("BUDIBASE_DIR", tmpdir("budibase-unittests"))
|
||||
env._set("LOG_LEVEL", "silent")
|
||||
env._set("PORT", 0)
|
||||
env._set("MINIO_URL", "http://localhost")
|
||||
env._set("MINIO_ACCESS_KEY", "test")
|
||||
env._set("MINIO_SECRET_KEY", "test")
|
||||
|
||||
import { mocks } from "@budibase/backend-core/tests"
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
const mockS3 = {
|
||||
headBucket: jest.fn().mockReturnThis(),
|
||||
deleteObject: jest.fn().mockReturnThis(),
|
||||
deleteObjects: jest.fn().mockReturnThis(),
|
||||
createBucket: jest.fn().mockReturnThis(),
|
||||
listObjects: jest.fn().mockReturnThis(),
|
||||
promise: jest.fn().mockReturnThis(),
|
||||
catch: jest.fn(),
|
||||
}
|
||||
|
||||
const AWS = {
|
||||
S3: jest.fn(() => mockS3),
|
||||
}
|
||||
|
||||
export default AWS
|
|
@ -0,0 +1 @@
|
|||
jest.mock("node-fetch", () => jest.fn())
|
|
@ -5,6 +5,9 @@ env._set("NODE_ENV", "jest")
|
|||
env._set("JWT_SECRET", "test-jwtsecret")
|
||||
env._set("LOG_LEVEL", "silent")
|
||||
env._set("MULTI_TENANCY", true)
|
||||
env._set("MINIO_URL", "http://localhost")
|
||||
env._set("MINIO_ACCESS_KEY", "test")
|
||||
env._set("MINIO_SECRET_KEY", "test")
|
||||
|
||||
import { mocks } from "@budibase/backend-core/tests"
|
||||
|
||||
|
|
Loading…
Reference in New Issue