mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 11:41:44 +00:00
Clean up react-select tests
Address comments from https://github.com/DefinitelyTyped/DefinitelyTyped/pull/10109
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
/// <reference path="../lodash/lodash.d.ts" />
|
||||
/// <reference path="../react/react.d.ts" />
|
||||
/// <reference path="../react/react-dom.d.ts" />
|
||||
/// <reference path="./react-select.d.ts" />
|
||||
|
||||
import * as _ from "lodash";
|
||||
import * as React from "react";
|
||||
import * as ReactDOM from "react-dom";
|
||||
|
||||
@@ -65,19 +63,15 @@ const CustomValue = React.createClass({
|
||||
|
||||
const filterOptions = (options: Array<Option>, filter: string, values: Array<Option>) => {
|
||||
// Filter already selected values
|
||||
let filteredOptions = options.filter(option => {
|
||||
return !(_.includes(values, option));
|
||||
});
|
||||
let filteredOptions = options.filter(option => values.indexOf(option) < 0);
|
||||
|
||||
// Filter by label
|
||||
if (filter !== undefined && filter != null && filter.length > 0) {
|
||||
filteredOptions = filteredOptions.filter(option => {
|
||||
return RegExp(filter, 'ig').test(option.label);
|
||||
});
|
||||
if (filter != null && filter.length > 0) {
|
||||
filteredOptions = filteredOptions.filter(option => RegExp(filter, 'ig').test(option.label));
|
||||
}
|
||||
|
||||
// Append Addition option
|
||||
if (filteredOptions.length == 0) {
|
||||
if (filteredOptions.length === 0) {
|
||||
filteredOptions.push({
|
||||
label: `Create: ${filter}`,
|
||||
value: filter
|
||||
|
||||
Reference in New Issue
Block a user