mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-03-18 17:57:13 +01:00
115 lines
2.1 KiB
TypeScript
115 lines
2.1 KiB
TypeScript
|
import { init } from './context';
|
||
|
|
||
|
it('supports navigation via keyboard', async () => {
|
||
|
const ctx = await init();
|
||
|
|
||
|
await ctx.setInput('f');
|
||
|
|
||
|
await ctx.keyDown('ArrowDown');
|
||
|
|
||
|
ctx.expectUi().toMatchInlineSnapshot(`
|
||
|
{
|
||
|
"input": "forest<>",
|
||
|
"suggestions": [
|
||
|
"👉 forest 3",
|
||
|
"fog 1",
|
||
|
"force field 1",
|
||
|
"flower 1",
|
||
|
],
|
||
|
}
|
||
|
`);
|
||
|
|
||
|
await ctx.keyDown('ArrowDown');
|
||
|
|
||
|
ctx.expectUi().toMatchInlineSnapshot(`
|
||
|
{
|
||
|
"input": "fog<>",
|
||
|
"suggestions": [
|
||
|
"forest 3",
|
||
|
"👉 fog 1",
|
||
|
"force field 1",
|
||
|
"flower 1",
|
||
|
],
|
||
|
}
|
||
|
`);
|
||
|
|
||
|
await ctx.keyDown('ArrowDown', { ctrlKey: true });
|
||
|
|
||
|
ctx.expectUi().toMatchInlineSnapshot(`
|
||
|
{
|
||
|
"input": "flower<>",
|
||
|
"suggestions": [
|
||
|
"forest 3",
|
||
|
"fog 1",
|
||
|
"force field 1",
|
||
|
"👉 flower 1",
|
||
|
],
|
||
|
}
|
||
|
`);
|
||
|
|
||
|
await ctx.keyDown('ArrowUp', { ctrlKey: true });
|
||
|
|
||
|
ctx.expectUi().toMatchInlineSnapshot(`
|
||
|
{
|
||
|
"input": "forest<>",
|
||
|
"suggestions": [
|
||
|
"👉 forest 3",
|
||
|
"fog 1",
|
||
|
"force field 1",
|
||
|
"flower 1",
|
||
|
],
|
||
|
}
|
||
|
`);
|
||
|
|
||
|
await ctx.keyDown('Enter');
|
||
|
|
||
|
ctx.expectUi().toMatchInlineSnapshot(`
|
||
|
{
|
||
|
"input": "forest<>",
|
||
|
"suggestions": [],
|
||
|
}
|
||
|
`);
|
||
|
|
||
|
await ctx.setInput('forest, t<>, safe');
|
||
|
|
||
|
ctx.expectUi().toMatchInlineSnapshot(`
|
||
|
{
|
||
|
"input": "forest, t<>, safe",
|
||
|
"suggestions": [
|
||
|
"artist:test 1",
|
||
|
],
|
||
|
}
|
||
|
`);
|
||
|
|
||
|
await ctx.keyDown('ArrowDown');
|
||
|
|
||
|
ctx.expectUi().toMatchInlineSnapshot(`
|
||
|
{
|
||
|
"input": "forest, artist:test<>, safe",
|
||
|
"suggestions": [
|
||
|
"👉 artist:test 1",
|
||
|
],
|
||
|
}
|
||
|
`);
|
||
|
|
||
|
await ctx.keyDown('Escape');
|
||
|
|
||
|
ctx.expectUi().toMatchInlineSnapshot(`
|
||
|
{
|
||
|
"input": "forest, artist:test<>, safe",
|
||
|
"suggestions": [],
|
||
|
}
|
||
|
`);
|
||
|
|
||
|
await ctx.setInput('forest, t<>, safe');
|
||
|
await ctx.keyDown('ArrowDown');
|
||
|
await ctx.keyDown('Enter');
|
||
|
|
||
|
ctx.expectUi().toMatchInlineSnapshot(`
|
||
|
{
|
||
|
"input": "forest, artist:test<>, safe",
|
||
|
"suggestions": [],
|
||
|
}
|
||
|
`);
|
||
|
});
|