Skip to content

Commit

Permalink
Fixing mocked test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
mike12345567 committed Dec 19, 2024
1 parent 49dca3b commit 0f65963
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions packages/server/src/api/routes/tests/static.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// Directly mock the AWS SDK
jest.mock("aws-sdk", () => ({
S3: jest.fn(() => ({
getSignedUrl: jest.fn(
(operation, params) => `http://example.com/${params.Bucket}/${params.Key}`
),
upload: jest.fn(() => ({ Contents: {} })),
})),
jest.mock("@aws-sdk/s3-request-presigner", () => ({
getSignedUrl: jest.fn(() => {
return `http://example.com`
}),
}))
jest.mock("@aws-sdk/client-s3")

import { Datasource, SourceName } from "@budibase/types"
import { setEnv } from "../../../environment"
Expand Down Expand Up @@ -77,7 +75,10 @@ describe("/static", () => {
type: "datasource",
name: "Test",
source: SourceName.S3,
config: {},
config: {
accessKeyId: "bb",
secretAccessKey: "bb",
},
},
})
})
Expand All @@ -91,7 +92,7 @@ describe("/static", () => {
.set(config.defaultHeaders())
.expect("Content-Type", /json/)
.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(
`https://${bucket}.s3.eu-west-1.amazonaws.com/${key}`
)
Expand Down

0 comments on commit 0f65963

Please sign in to comment.