Skip to main content

getMockSenderEnhancer

Package​

Installation​

npm install @rpldy/mock-sender

Details​

type getMockSenderEnhancer = (options: MockOptions) => UploaderEnhancer;

Creates an enhancer that when handed to the Uploady (using the enhancer prop), or to the uploader, will simulate file uploads without actually making requests.

Options​

Name (* = mandatory)TypeDefaultDescription
delaynumber500time in ms for mocked upload to take
fileSizenumber1e+6file size of the mocked upload, used for progress calculation
progressIntervalsnumber[][10, 25, 50, 75, 100]mock intervals (percentages) to emit progress events at
responseany{mock: true, success: true}mock response for upload request
responseStatusnumber200upload request status code

Example​

import Uploady from "@rpldy/uploady";
import UploadButton from "@rpldy/upload-button";
import { getMockSenderEnhancer } from "@rpldy/mock-sender";

const mockSenderEnhancer = getMockSenderEnhancer({
delay: 1500,
progressIntervals: [20, 40, 75, 80, 90, 99]
});

const App = () => <Uploady
destination={{ url: "mock-url"}}
enhancer={mockSenderEnhancer}
>
<UploadButton />
</Uploady>;