Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/Async.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,10 @@ const Async = React.createClass({
let { isLoading, options } = this.state;
if (this.props.isLoading) isLoading = true;
let placeholder = isLoading ? this.props.loadingPlaceholder : this.props.placeholder;
if (!options.length) {
if (this._lastInput.length < this.props.minimumInput) noResultsText = this.props.searchPromptText;
if (isLoading) noResultsText = this.props.searchingText;
if (isLoading) {
noResultsText = this.props.searchingText;
} else if (!options.length && this._lastInput.length < this.props.minimumInput) {
noResultsText = this.props.searchPromptText;
}
return (
<Select
Expand Down
21 changes: 20 additions & 1 deletion test/Async-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ describe('Async', () => {
/>);
});


it('shows the returns options when the result returns', () => {

// Unexpected comes with promises built in - we'll use them
Expand All @@ -105,6 +104,26 @@ describe('Async', () => {
});
});

it('shows "Loading..." after typing if refined search matches none of the previous results', () => {

loadOptions.returns(expect.promise((resolve, reject) => {
resolve({ options: [{ value: 1, label: 'test' }] });
}));

typeSearchText('te');

return loadOptions.firstCall.returnValue.then(() => {

typeSearchText('ten');

return expect(renderer, 'to have rendered',
<Select
isLoading
placeholder="Loading..."
noResultsText="Searching..."
/>);
});
});

it('ignores the result of an earlier call, when the responses come in the wrong order', () => {

Expand Down