mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-03-23 20:27:14 +01:00
Add an integration test for aborting the completions on Escape
This commit is contained in:
parent
dd7ee44e36
commit
96d32d863d
2 changed files with 34 additions and 0 deletions
|
@ -0,0 +1,34 @@
|
|||
import { init } from './context';
|
||||
|
||||
it('ignores the autocompletion results if Escape was pressed', async () => {
|
||||
const ctx = await init();
|
||||
|
||||
await Promise.all([ctx.setInput('mar'), ctx.keyDown('Escape')]);
|
||||
|
||||
// The input must be empty because the user typed `mar` and pressed `Escape` right after that
|
||||
ctx.expectUi().toMatchInlineSnapshot(`
|
||||
{
|
||||
"input": "mar<>",
|
||||
"suggestions": [],
|
||||
}
|
||||
`);
|
||||
|
||||
// First request for the local autocomplete index.
|
||||
expect(fetch).toHaveBeenCalledTimes(1);
|
||||
|
||||
await ctx.setInput('mar');
|
||||
|
||||
ctx.expectUi().toMatchInlineSnapshot(`
|
||||
{
|
||||
"input": "mar<>",
|
||||
"suggestions": [
|
||||
"marvelous → beautiful 30",
|
||||
"mare 20",
|
||||
"market 10",
|
||||
],
|
||||
}
|
||||
`);
|
||||
|
||||
// Second request for the server-side suggestions.
|
||||
expect(fetch).toHaveBeenCalledTimes(2);
|
||||
});
|
Loading…
Add table
Reference in a new issue