dom-testing-library
Advanced tools
Comparing version 3.3.0 to 3.4.0
@@ -343,3 +343,4 @@ 'use strict'; | ||
var value = _eventInit$target.value, | ||
targetProperties = _objectWithoutProperties(_eventInit$target, ['value']); | ||
files = _eventInit$target.files, | ||
targetProperties = _objectWithoutProperties(_eventInit$target, ['value', 'files']); | ||
@@ -350,2 +351,10 @@ Object.assign(node, targetProperties); | ||
} | ||
if (files !== undefined) { | ||
// input.files is a read-only property so this is not allowed: | ||
// input.files = [file] | ||
// so we have to use this workaround to set the property | ||
Object.defineProperty(node, 'files', { | ||
value: files | ||
}); | ||
} | ||
var event = new EventType(eventName, eventInit); | ||
@@ -352,0 +361,0 @@ return fireEvent(node, event); |
{ | ||
"name": "dom-testing-library", | ||
"version": "3.3.0", | ||
"version": "3.4.0", | ||
"description": "Simple and complete DOM testing utilities that encourage good testing practices.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -528,2 +528,11 @@ <div align="center"> | ||
fireEvent.change(getByLabelText(/username/i), {target: {value: 'a'}}) | ||
// note: attempting to manually set the files property of an HTMLInputElement | ||
// results in an error as the files property is read-only. | ||
// this feature works around that by using Object.defineProperty. | ||
fireEvent.change(getByLabelText(/picture/i), { | ||
target: { | ||
files: [new File(['(⌐□_□)'], 'chucknorris.png', {type: 'image/png'})], | ||
}, | ||
}) | ||
``` | ||
@@ -558,3 +567,3 @@ | ||
make it easier to check several aspects of the state of a DOM element. For | ||
exmaple, you can use the ones provided by | ||
example, you can use the ones provided by | ||
[jest-dom](https://github.com/gnapse/jest-dom): | ||
@@ -561,0 +570,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
418370
4210
976