Skip to content

Commit

Permalink
Fix linter issues and tests for Async
Browse files Browse the repository at this point in the history
  • Loading branch information
JedWatson committed Sep 12, 2017
1 parent 9ed39d4 commit 7720dbb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
10 changes: 4 additions & 6 deletions src/Async.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ export default class Async extends Component {
}
}

componentWillUnmount () {
this._callback = null;
}

componentWillReceiveProps(nextProps) {
if (nextProps.options !== this.props.options) {
this.setState({
Expand All @@ -80,6 +76,10 @@ export default class Async extends Component {
}
}

componentWillUnmount () {
this._callback = null;
}

clearOptions() {
this.setState({ options: [] });
}
Expand All @@ -92,7 +92,6 @@ export default class Async extends Component {
cache &&
cache.hasOwnProperty(inputValue)
) {
console.log(`loadOptions returning with cache:`, cache[inputValue]);
this.setState({
options: cache[inputValue]
});
Expand Down Expand Up @@ -139,7 +138,6 @@ export default class Async extends Component {
}

onInputChange (inputValue) {

const { ignoreAccents, ignoreCase, onInputChange } = this.props;
let transformedInputValue = inputValue;

Expand Down
26 changes: 15 additions & 11 deletions test/Async-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,26 +386,30 @@ describe('Async', () => {
});

describe('if noResultsText has been provided', () => {
it('returns the noResultsText', () => {
asyncInstance.select = { state: { inputValue: 'asdf' } };
expect(asyncInstance.noResultsText(), 'to equal', 'noResultsText');
it('returns the noResultsText', (cb) => {
asyncInstance.setState({
inputValue: 'asfd',
}, () => {
expect(asyncInstance.noResultsText(), 'to equal', 'noResultsText');
cb();
});
});
});

describe('if noResultsText is empty', () => {
beforeEach((cb) => {
beforeEach(() => {
createControl({
searchPromptText: 'searchPromptText',
loadingPlaceholder: 'loadingPlaceholder'
});
asyncInstance.setState({
isLoading: false,
inputValue: 'asdfkljhadsf'
}, cb);
});
it('falls back to searchPromptText', () => {
asyncInstance.select = { state: { inputValue: 'asdf' } };
expect(asyncInstance.noResultsText(), 'to equal', 'searchPromptText');
it('falls back to searchPromptText', (cb) => {
asyncInstance.setState({
inputValue: 'asfd',
}, () => {
expect(asyncInstance.noResultsText(), 'to equal', 'searchPromptText');
cb();
});
});
});
});
Expand Down

0 comments on commit 7720dbb

Please sign in to comment.