getMockSenderEnhancer
Packageβ
Installationβ
- npm
- Yarn
- pnpm
npm install @rpldy/mock-sender
yarn add @rpldy/mock-sender
pnpm add @rpldy/mock-sender
Detailsβ
type getMockSenderEnhancer = (options: MockOptions) => UploaderEnhancer;
- See: MockOptions
- See: 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) | Type | Default | Description |
---|---|---|---|
delay | number | 500 | time in ms for mocked upload to take |
fileSize | number | 1e+6 | file size of the mocked upload, used for progress calculation |
progressIntervals | number[] | [10, 25, 50, 75, 100] | mock intervals (percentages) to emit progress events at |
response | any | {mock: true, success: true} | mock response for upload request |
responseStatus | number | 200 | upload 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>;