Socket
Socket
Sign inDemoInstall

@testing-library/user-event

Package Overview
Dependencies
Maintainers
16
Versions
199
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@testing-library/user-event - npm Package Compare versions

Comparing version 14.0.0-alpha.16 to 14.0.0-alpha.17

dist/utils/edit/setFiles.d.ts

3

dist/setup/directApi.d.ts
import type { PointerOptions } from '../utils';
import type { uploadInit } from '../utility';
import type { PointerInput } from '../pointer';

@@ -20,3 +19,3 @@ import type { UserEventApi } from '.';

export declare function unhover(element: Element, options?: PointerOptions): Promise<void>;
export declare function upload(element: HTMLElement, fileOrFiles: File | File[], init?: uploadInit, options?: Partial<Config>): Promise<void>;
export declare function upload(element: HTMLElement, fileOrFiles: File | File[], options?: Partial<Config>): Promise<void>;
export declare function tab(options?: Partial<Config> & Parameters<UserEventApi['tab']>[0]): Promise<void>;

@@ -89,4 +89,4 @@ "use strict";

function upload(element, fileOrFiles, init, options = {}) {
return (0, _setup.setupDirect)(options).upload(element, fileOrFiles, init);
function upload(element, fileOrFiles, options = {}) {
return (0, _setup.setupDirect)(options).upload(element, fileOrFiles);
}

@@ -93,0 +93,0 @@

@@ -5,2 +5,2 @@ import { UserEvent } from '../setup';

}
export declare function upload(this: UserEvent, element: HTMLElement, fileOrFiles: File | File[], init?: uploadInit): Promise<void>;
export declare function upload(this: UserEvent, element: HTMLElement, fileOrFiles: File | File[]): Promise<void>;

@@ -14,3 +14,5 @@ "use strict";

async function upload(element, fileOrFiles, init) {
var _setFiles = require("#src/utils/edit/setFiles");
async function upload(element, fileOrFiles) {
var _input$files;

@@ -40,37 +42,9 @@

return;
} // the event fired in the browser isn't actually an "input" or "change" event
// but a new Event with a type set to "input" and "change"
// Kinda odd...
}
(0, _setFiles.setFiles)(input, (0, _utils.createFileList)(files));
const inputFiles = { ...files,
length: files.length,
item: index => files[index],
_dom.fireEvent.input(input);
[Symbol.iterator]() {
let i = 0;
return {
next: () => ({
done: i >= files.length,
value: files[i++]
})
};
}
};
(0, _dom.fireEvent)(input, (0, _dom.createEvent)('input', input, {
target: {
files: inputFiles
},
bubbles: true,
cancelable: false,
composed: true
}));
_dom.fireEvent.change(input, {
target: {
files: inputFiles
},
...(init == null ? void 0 : init.changeInit)
});
_dom.fireEvent.change(input);
}

@@ -77,0 +51,0 @@

@@ -10,5 +10,15 @@ "use strict";

function createFileList(files) {
const f = [...files];
Object.setPrototypeOf(f, FileList.prototype);
return f;
const list = { ...files,
length: files.length,
item: index => list[index],
[Symbol.iterator]: function* nextFile() {
for (let i = 0; i < list.length; i++) {
yield list[i];
}
}
};
list.constructor = FileList;
Object.setPrototypeOf(list, FileList.prototype);
Object.freeze(list);
return list;
}
{
"name": "@testing-library/user-event",
"version": "14.0.0-alpha.16",
"version": "14.0.0-alpha.17",
"description": "Fire events the same way the user does",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc