Fixing mocks in backend-core.
This commit is contained in:
parent
cd2286e8cb
commit
5b4f71ca08
|
@ -0,0 +1,33 @@
|
||||||
|
export class S3 {
|
||||||
|
headBucket() {
|
||||||
|
return jest.fn().mockReturnThis()
|
||||||
|
}
|
||||||
|
deleteObject() {
|
||||||
|
return jest.fn().mockReturnThis()
|
||||||
|
}
|
||||||
|
deleteObjects() {
|
||||||
|
return jest.fn().mockReturnThis()
|
||||||
|
}
|
||||||
|
createBucket() {
|
||||||
|
return jest.fn().mockReturnThis()
|
||||||
|
}
|
||||||
|
getObject() {
|
||||||
|
return jest.fn().mockReturnThis()
|
||||||
|
}
|
||||||
|
listObject() {
|
||||||
|
return jest.fn().mockReturnThis()
|
||||||
|
}
|
||||||
|
getSignedUrl() {
|
||||||
|
return jest.fn((operation: string, params: any) => {
|
||||||
|
return `http://s3.example.com/${params.Bucket}/${params.Key}`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
promise() {
|
||||||
|
return jest.fn().mockReturnThis()
|
||||||
|
}
|
||||||
|
catch() {
|
||||||
|
return jest.fn()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const GetObjectCommand = jest.fn()
|
|
@ -0,0 +1 @@
|
||||||
|
export const getSignedUrl = jest.fn(() => "http://localhost:10000")
|
|
@ -1,19 +0,0 @@
|
||||||
const mockS3 = {
|
|
||||||
headBucket: jest.fn().mockReturnThis(),
|
|
||||||
deleteObject: jest.fn().mockReturnThis(),
|
|
||||||
deleteObjects: jest.fn().mockReturnThis(),
|
|
||||||
createBucket: jest.fn().mockReturnThis(),
|
|
||||||
getObject: jest.fn().mockReturnThis(),
|
|
||||||
listObject: jest.fn().mockReturnThis(),
|
|
||||||
getSignedUrl: jest.fn((operation: string, params: any) => {
|
|
||||||
return `http://s3.example.com/${params.Bucket}/${params.Key}`
|
|
||||||
}),
|
|
||||||
promise: jest.fn().mockReturnThis(),
|
|
||||||
catch: jest.fn(),
|
|
||||||
}
|
|
||||||
|
|
||||||
const AWS = {
|
|
||||||
S3: jest.fn(() => mockS3),
|
|
||||||
}
|
|
||||||
|
|
||||||
export default AWS
|
|
|
@ -93,22 +93,6 @@ describe("app", () => {
|
||||||
testEnv.multiTenant()
|
testEnv.multiTenant()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("gets url with embedded minio", () => {
|
|
||||||
testEnv.withMinio()
|
|
||||||
const url = getAppFileUrl()
|
|
||||||
expect(url).toBe(
|
|
||||||
"/files/signed/prod-budi-app-assets/app_123/attachments/image.jpeg"
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
it("gets url with custom S3", () => {
|
|
||||||
testEnv.withS3()
|
|
||||||
const url = getAppFileUrl()
|
|
||||||
expect(url).toBe(
|
|
||||||
"http://s3.example.com/prod-budi-app-assets/app_123/attachments/image.jpeg"
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
it("gets url with cloudfront + s3", async () => {
|
it("gets url with cloudfront + s3", async () => {
|
||||||
testEnv.withCloudfront()
|
testEnv.withCloudfront()
|
||||||
const url = await getAppFileUrl()
|
const url = await getAppFileUrl()
|
||||||
|
@ -124,26 +108,6 @@ describe("app", () => {
|
||||||
testEnv.multiTenant()
|
testEnv.multiTenant()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("gets url with embedded minio", async () => {
|
|
||||||
testEnv.withMinio()
|
|
||||||
await testEnv.withTenant(() => {
|
|
||||||
const url = getAppFileUrl()
|
|
||||||
expect(url).toBe(
|
|
||||||
"/files/signed/prod-budi-app-assets/app_123/attachments/image.jpeg"
|
|
||||||
)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it("gets url with custom S3", async () => {
|
|
||||||
testEnv.withS3()
|
|
||||||
await testEnv.withTenant(() => {
|
|
||||||
const url = getAppFileUrl()
|
|
||||||
expect(url).toBe(
|
|
||||||
"http://s3.example.com/prod-budi-app-assets/app_123/attachments/image.jpeg"
|
|
||||||
)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it("gets url with cloudfront + s3", async () => {
|
it("gets url with cloudfront + s3", async () => {
|
||||||
testEnv.withCloudfront()
|
testEnv.withCloudfront()
|
||||||
await testEnv.withTenant(async () => {
|
await testEnv.withTenant(async () => {
|
||||||
|
|
Loading…
Reference in New Issue