SymphonyElectron/spectron/spell-checker.spec.ts

44 lines
1.1 KiB
TypeScript
Raw Normal View History

import test from 'ava';
import * as robot from 'robotjs';
import { Application } from 'spectron';
2021-01-29 00:25:40 -06:00
import {
getDemoFilePath,
loadURL,
startApplication,
stopApplication,
Timeouts,
} from './fixtures/spectron-setup';
let app;
test.before(async (t) => {
2021-01-29 00:25:40 -06:00
app = (await startApplication()) as Application;
t.true(app.isRunning());
});
test.after.always(async () => {
2021-01-29 00:25:40 -06:00
await stopApplication(app);
});
test('spell-checker: verify application spell checking feature', async (t) => {
2021-01-29 00:25:40 -06:00
robot.setKeyboardDelay(Timeouts.oneSec);
const missSpelledWord = 'teest ';
2021-01-29 00:25:40 -06:00
await loadURL(app, getDemoFilePath());
await app.client.waitUntilWindowLoaded(Timeouts.fiveSec);
await app.client.electron.remote.clipboard.writeText(missSpelledWord);
await app.client.click('#tag');
await app.client.webContents.paste();
await app.client.waitForValue('#tag', Timeouts.fiveSec);
2021-01-29 00:25:40 -06:00
t.is(await app.client.getValue('#tag'), missSpelledWord);
2021-01-29 00:25:40 -06:00
await app.client.rightClick('#tag', 10, 10);
robot.keyTap('down');
robot.keyTap('enter');
2021-01-29 00:25:40 -06:00
t.not(await app.client.getValue('#tag'), missSpelledWord);
});