Fixing mock to cover getReadStream in object store.

This commit is contained in:
mike12345567 2024-02-01 11:09:28 +00:00
parent e61d52ee8b
commit c4eae33b67
1 changed files with 19 additions and 4 deletions

View File

@ -1,7 +1,13 @@
import fs from "fs"
import { join } from "path"
module AwsMock { module AwsMock {
const aws: any = {} const aws: any = {}
const response = (body: any) => () => ({ promise: () => body }) const response = (body: any, extra?: any) => () => ({
promise: () => body,
...extra,
})
function DocumentClient() { function DocumentClient() {
// @ts-ignore // @ts-ignore
@ -73,9 +79,18 @@ module AwsMock {
// @ts-ignore // @ts-ignore
this.getObject = jest.fn( this.getObject = jest.fn(
response({ response(
{
Body: "", Body: "",
}) },
{
createReadStream: jest
.fn()
.mockReturnValue(
fs.createReadStream(join(__dirname, "aws-sdk.ts"))
),
}
)
) )
} }