Socket
Book a DemoInstallSign in
Socket

fill-in-file

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fill-in-file

A test util that helps to fill files in your file input element

latest
Source
npmnpm
Version
0.0.4
Version published
Maintainers
1
Created
Source

fill-in-file npm version

A test util that helps to fill files in your file input element

Usage

fillInFile('#input-element', { url: 'base64content', name: 'example.jpg' })

Install

npm install fill-in-file

How

Please check this article for implementation details.

Variants

Simple mock
fillInFile('#input-element')

It automatically adds the mock js-base64 image and triggers the onchange event.

String
fillInFile('#input-element', 'base64content')

 or

fillInFile('#input-element', 'https://some-public-file-url.jpg');
Single file object
fillInFile('#input-element', { url: 'base64content', name: 'logo.jpg' });

 or

fillInFile('#input-element', { url: 'https://some-public-file-url.jpg', name:  'profile.jpg' });

It adds the given file to the file input and triggers the onchange event.

Multiple files
let files = [
  { url: 'base64content', name: 'logo.jpg' },
  { url: 'https://some-public-file-url.jpg', name:  'profile.jpg' }
];

fillInFile('#input-element', files);

API

Method: fillInFile

params:

nametyperequireddescription
domSelectorstringyesdom query selector string for the input file element
filesundefined - string - file - [file]optionalfile contents to be added to the file element
optionsobjectoptionalsupports options like documentContext that lets you pass a custom document context, by default util uses global document

ember test helper

https://github.com/prakashchokalingam/ember-fill-in-file

Examples

Qunit: https://prakashchokalingam.github.io/fill-in-file/examples/qunit.html

Mocha: https://prakashchokalingam.github.io/fill-in-file/examples/mocha.html

npm version npm

Keywords

fileInputmock

FAQs

Package last updated on 21 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts