Skip to content

Commit

Permalink
fix(core): remove error handler when fetching results (#416)
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickcr committed Jan 28, 2021
1 parent e4cc372 commit eb98af6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
25 changes: 24 additions & 1 deletion packages/autocomplete-core/src/__tests__/getInputProps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,30 @@ describe('getInputProps', () => {
});
});

test.todo('catches errors and sets status to error');
/* eslint-disable-next-line jest/no-done-callback */
test('lets user handle the errors', (done) => {
const getSources = jest.fn((..._args: any[]) => {
return [
createSource({
getItems() {
return new Promise<any>((resolve, reject) => {
reject(new Error('Fetch error'));
}).catch((err) => {
expect(err).toEqual(expect.any(Error));
done();
return [];
});
},
}),
];
});

const { inputElement } = createPlayground(createAutocomplete, {
getSources,
});

userEvent.type(inputElement, 'a');
});

test('clears stalled timeout', async () => {
const environment = {
Expand Down
5 changes: 0 additions & 5 deletions packages/autocomplete-core/src/onInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,6 @@ export function onInput<TItem extends BaseItem>({
});
}
})
.catch((error) => {
setStatus('error');

throw error;
})
.finally(() => {
if (lastStalledId) {
props.environment.clearTimeout(lastStalledId);
Expand Down

0 comments on commit eb98af6

Please sign in to comment.