Clean up react-select tests

Address comments from
https://github.com/DefinitelyTyped/DefinitelyTyped/pull/10109
This commit is contained in:
Vicky Lai
2016-07-19 21:26:47 -07:00
parent 5b816099c3
commit 23be9194eb
+4 -10
View File
@@ -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