react-select-event
Advanced tools
Comparing version 5.3.0 to 5.4.0
@@ -32,3 +32,11 @@ 'use strict'; | ||
function getReactSelectContainerFromInput(input) { | ||
return input.parentNode.parentNode.parentNode.parentNode.parentNode; | ||
// i hate this so much but older versions insist on inserting a space before their generated class name | ||
let parent = input.closest('[class^="css-"][class$="-container"]') || input.closest('[class^=" css-"][class$="-container"]'); // for older versions of react-select fall back to old parent crawler | ||
// istanbul ignore if | ||
if (!parent) { | ||
parent = input.parentNode.parentNode.parentNode.parentNode.parentNode; | ||
} | ||
return parent; | ||
} | ||
@@ -175,4 +183,4 @@ /** | ||
exports.create = create; | ||
exports.default = selectEvent; | ||
exports['default'] = selectEvent; | ||
exports.openMenu = openMenu; | ||
exports.select = select; |
@@ -28,3 +28,11 @@ import { fireEvent, waitFor, findAllByText, findByText } from '@testing-library/dom'; | ||
function getReactSelectContainerFromInput(input) { | ||
return input.parentNode.parentNode.parentNode.parentNode.parentNode; | ||
// i hate this so much but older versions insist on inserting a space before their generated class name | ||
let parent = input.closest('[class^="css-"][class$="-container"]') || input.closest('[class^=" css-"][class$="-container"]'); // for older versions of react-select fall back to old parent crawler | ||
// istanbul ignore if | ||
if (!parent) { | ||
parent = input.parentNode.parentNode.parentNode.parentNode.parentNode; | ||
} | ||
return parent; | ||
} | ||
@@ -168,3 +176,2 @@ /** | ||
export default selectEvent; | ||
export { clearAll, clearFirst, create, openMenu, select }; | ||
export { clearAll, clearFirst, create, selectEvent as default, openMenu, select }; |
{ | ||
"name": "react-select-event", | ||
"version": "5.3.0", | ||
"version": "5.4.0", | ||
"description": "Simulate react-select events for react-testing-library", | ||
@@ -49,11 +49,11 @@ "main": "lib/react-select-event.cjs.js", | ||
"@testing-library/jest-dom": "^5.0.1", | ||
"@testing-library/react": "^11.0.2", | ||
"@types/jest": "^26.0.0", | ||
"@testing-library/react": "^12.0.0", | ||
"@types/jest": "^27.0.1", | ||
"@types/react": "^17.0.0", | ||
"@types/react-select": "^4.0.13", | ||
"jest": "^26.0.0", | ||
"jest": "^27.0.4", | ||
"prettier": "^2.0.2", | ||
"react": "^17.0.2", | ||
"react-dom": "^17.0.2", | ||
"react-select": "^4.0.2", | ||
"react-select": "^5.0.0", | ||
"rimraf": "^3.0.0", | ||
@@ -60,0 +60,0 @@ "rollup": "^2.0.3", |
@@ -15,3 +15,3 @@ <div align="center"> | ||
[![npm version](https://badge.fury.io/js/react-select-event.svg)](https://badge.fury.io/js/react-select-event) | ||
[![Build Status](https://travis-ci.org/romgain/react-select-event.svg?branch=master)](https://travis-ci.org/romgain/react-select-event) | ||
[![Build Status](https://github.com/romgain/react-select-event/actions/workflows/ci.yml/badge.svg)](https://github.com/romgain/jest-websocket-mock/actions) | ||
[![Coverage report](https://codecov.io/gh/romgain/react-select-event/branch/master/graph/badge.svg)](https://codecov.io/gh/romgain/react-select-event) | ||
@@ -18,0 +18,0 @@ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier) |
/** Simulate user events on react-select dropdowns */ | ||
import { | ||
Matcher, | ||
findAllByText, | ||
findByText, | ||
fireEvent, | ||
Matcher, | ||
waitFor, | ||
@@ -15,4 +15,15 @@ } from "@testing-library/dom"; | ||
function getReactSelectContainerFromInput(input: HTMLElement): HTMLElement { | ||
return input.parentNode!.parentNode!.parentNode!.parentNode! | ||
.parentNode as HTMLElement; | ||
// i hate this so much but older versions insist on inserting a space before their generated class name | ||
let parent = | ||
input.closest('[class^="css-"][class$="-container"]') || | ||
input.closest('[class^=" css-"][class$="-container"]'); | ||
// for older versions of react-select fall back to old parent crawler | ||
// istanbul ignore if | ||
if (!parent) { | ||
parent = input.parentNode!.parentNode!.parentNode!.parentNode! | ||
.parentNode as HTMLElement; | ||
} | ||
return parent as HTMLElement; | ||
} | ||
@@ -109,2 +120,3 @@ | ||
} | ||
/** | ||
@@ -111,0 +123,0 @@ * Utility for creating and selecting a value in a Creatable `react-select` dropdown. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52646
12
977