Git Product home page Git Product logo

fill-in-file's Introduction

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:

name type required description
domSelector string yes dom query selector string for the input file element
files undefined - string - file - [file] optional file contents to be added to the file element
options object optional supports 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

fill-in-file's People

Contributors

prakashchokalingam avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.