Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More โ†’
Socket
Sign inDemoInstall
Socket

@testing-library/user-event

Package Overview
Dependencies
Maintainers
12
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 8.0.3 to 8.0.4

26

__tests__/react/click.js

@@ -201,2 +201,28 @@ import React from "react";

it("does not lose focus when click updates focus", () => {
const FocusComponent = () => {
const inputRef = React.useRef();
const focusInput = () => inputRef.current.focus();
return (
<React.Fragment>
<input data-testid="input" ref={inputRef} />
<button onClick={focusInput}>Update Focus</button>
</React.Fragment>
);
};
const { getByTestId, getByText } = render(<FocusComponent />);
const input = getByTestId("input");
const button = getByText("Update Focus");
expect(input).not.toHaveFocus();
userEvent.click(button);
expect(input).toHaveFocus();
userEvent.click(button);
expect(input).toHaveFocus();
});
it.each(["input", "textarea"])(

@@ -203,0 +229,0 @@ "gives focus to <%s> when clicking a <label> with htmlFor",

12

dist/index.js

@@ -147,2 +147,8 @@ "use strict";

function blurFocusedElement(element, focusedElement, wasAnotherElementFocused) {
if (wasAnotherElementFocused && element.ownerDocument.activeElement === element) {
focusedElement.blur();
}
}
const userEvent = {

@@ -174,3 +180,3 @@ click(element) {

wasAnotherElementFocused && focusedElement.blur();
blurFocusedElement(element, focusedElement, wasAnotherElementFocused);
},

@@ -199,3 +205,3 @@

wasAnotherElementFocused && focusedElement.blur();
blurFocusedElement(element, focusedElement, wasAnotherElementFocused);
},

@@ -225,3 +231,3 @@

wasAnotherElementFocused && focusedElement.blur();
blurFocusedElement(element, focusedElement, wasAnotherElementFocused);
},

@@ -228,0 +234,0 @@

{
"name": "@testing-library/user-event",
"version": "8.0.3",
"version": "8.0.4",
"description": "Simulate user events for react-testing-library",

@@ -5,0 +5,0 @@ "keywords": [

@@ -257,2 +257,3 @@ <div align="center">

<td align="center"><a href="https://github.com/maheshjag"><img src="https://avatars0.githubusercontent.com/u/1705603?v=4" width="100px;" alt=""/><br /><sub><b>MJ</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=maheshjag" title="Documentation">๐Ÿ“–</a></td>
<td align="center"><a href="https://github.com/jmcriffey"><img src="https://avatars0.githubusercontent.com/u/2831294?v=4" width="100px;" alt=""/><br /><sub><b>Jeff McRiffey</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=jmcriffey" title="Code">๐Ÿ’ป</a> <a href="https://github.com/testing-library/user-event/commits?author=jmcriffey" title="Tests">โš ๏ธ</a></td>
</tr>

@@ -259,0 +260,0 @@ </table>

@@ -102,2 +102,11 @@ import { fireEvent } from "@testing-library/dom";

function blurFocusedElement(element, focusedElement, wasAnotherElementFocused) {
if (
wasAnotherElementFocused &&
element.ownerDocument.activeElement === element
) {
focusedElement.blur();
}
}
const userEvent = {

@@ -127,3 +136,3 @@ click(element) {

wasAnotherElementFocused && focusedElement.blur();
blurFocusedElement(element, focusedElement, wasAnotherElementFocused);
},

@@ -150,3 +159,3 @@

wasAnotherElementFocused && focusedElement.blur();
blurFocusedElement(element, focusedElement, wasAnotherElementFocused);
},

@@ -178,3 +187,3 @@

wasAnotherElementFocused && focusedElement.blur();
blurFocusedElement(element, focusedElement, wasAnotherElementFocused);
},

@@ -181,0 +190,0 @@

Sorry, the diff of this file is not supported yet

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