47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
import { describe, it, afterEach, expect, $, click, type, pressKey, sleep, closeAll } from './runner.js';
|
|
|
|
describe('Search', () => {
|
|
afterEach(() => closeAll());
|
|
|
|
it('opens with Ctrl+K', async () => {
|
|
pressKey('k', { ctrlKey: true });
|
|
await sleep(150);
|
|
expect($('#search')).toBeVisible();
|
|
});
|
|
|
|
it('opens with search button', async () => {
|
|
click('#search-btn');
|
|
await sleep(150);
|
|
expect($('#search')).toBeVisible();
|
|
});
|
|
|
|
it('input is focused on open', async () => {
|
|
click('#search-btn');
|
|
await sleep(150);
|
|
expect(document.activeElement).toBe($('#search-input'));
|
|
});
|
|
|
|
it('has input and results area', async () => {
|
|
click('#search-btn');
|
|
await sleep(100);
|
|
expect($('#search-input')).toExist();
|
|
expect($('#search-results')).toExist();
|
|
});
|
|
|
|
it('typing triggers results render', async () => {
|
|
click('#search-btn');
|
|
await sleep(100);
|
|
type('#search-input', 'a');
|
|
await sleep(250);
|
|
expect($('#search-results')).toExist();
|
|
});
|
|
|
|
it('closes with ESC', async () => {
|
|
click('#search-btn');
|
|
await sleep(100);
|
|
pressKey('Escape');
|
|
await sleep(150);
|
|
expect($('#search')).toBeHidden();
|
|
});
|
|
});
|