Fixing mocked test case.

This commit is contained in:
mike12345567 2024-12-19 14:02:24 +00:00
parent 49dca3b7c9
commit 0f659635c7
1 changed files with 10 additions and 9 deletions

View File

@ -1,12 +1,10 @@
// Directly mock the AWS SDK // Directly mock the AWS SDK
jest.mock("aws-sdk", () => ({ jest.mock("@aws-sdk/s3-request-presigner", () => ({
S3: jest.fn(() => ({ getSignedUrl: jest.fn(() => {
getSignedUrl: jest.fn( return `http://example.com`
(operation, params) => `http://example.com/${params.Bucket}/${params.Key}` }),
),
upload: jest.fn(() => ({ Contents: {} })),
})),
})) }))
jest.mock("@aws-sdk/client-s3")
import { Datasource, SourceName } from "@budibase/types" import { Datasource, SourceName } from "@budibase/types"
import { setEnv } from "../../../environment" import { setEnv } from "../../../environment"
@ -77,7 +75,10 @@ describe("/static", () => {
type: "datasource", type: "datasource",
name: "Test", name: "Test",
source: SourceName.S3, source: SourceName.S3,
config: {}, config: {
accessKeyId: "bb",
secretAccessKey: "bb",
},
}, },
}) })
}) })
@ -91,7 +92,7 @@ describe("/static", () => {
.set(config.defaultHeaders()) .set(config.defaultHeaders())
.expect("Content-Type", /json/) .expect("Content-Type", /json/)
.expect(200) .expect(200)
expect(res.body.signedUrl).toEqual("http://example.com/foo/bar") expect(res.body.signedUrl).toEqual("http://example.com")
expect(res.body.publicUrl).toEqual( expect(res.body.publicUrl).toEqual(
`https://${bucket}.s3.eu-west-1.amazonaws.com/${key}` `https://${bucket}.s3.eu-west-1.amazonaws.com/${key}`
) )