Skip to content

Latest commit

 

History

History

mock-sender

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
npm version Build Status codecov status bundlephobia badge rpldy storybook

Mock Sender

Provides a mock sender that can be used to replace a real sender for testing purposes.

It provides the same interface and events so the Uploader is unaware of its use.

On-progress events and abort functionality are supported

The best place to get started is at our: React-Uploady Documentation Website

Installation

#Yarn:
  $ yarn add @rpldy/mock-sender

#NPM:
  $ npm i @rpldy/mock-sender

Options

Name (* = mandatory) Type Default Description
delay number 500 time in ms for mocked upload to take
fileSize number undefined file size of the mocked upload, used for progress calculation, by default, the actual file size, if available, will be used
progressIntervals number[] [10, 25, 50, 75, 90] 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
isSuccessfulCall IsSuccessfulCall undefined callback to use to decide whether upload response is succssful or not

Usage

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
        enhancer={mockSenderEnhancer}
    >
        <UploadButton />
    </Uploady>
);