mirror of
https://github.com/keymanapp/keyman.git
synced 2026-10-16 10:57:35 +00:00
chore(web): move kbdInterface tests to typescript
This commit is contained in:
parent
8e53666905
commit
5d92ff6635
2 changed files with 23 additions and 17 deletions
|
|
@ -36,7 +36,12 @@ do_build () {
|
|||
--format esm
|
||||
}
|
||||
|
||||
do_test() {
|
||||
test-headless "${SUBPROJECT_NAME}" ""
|
||||
test-headless-typescript "${SUBPROJECT_NAME}"
|
||||
}
|
||||
|
||||
builder_run_action configure verify_npm_setup
|
||||
builder_run_action clean rm -rf "${KEYMAN_ROOT}/web/build/${SUBPROJECT_NAME}"
|
||||
builder_run_action build do_build
|
||||
builder_run_action test test-headless "${SUBPROJECT_NAME}" ""
|
||||
builder_run_action test do_test
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { assert } from 'chai';
|
|||
import { createRequire } from 'module';
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
import { MinimalKeymanGlobal } from 'keyman/engine/keyboard';
|
||||
import { DeviceSpec, MinimalKeymanGlobal } from 'keyman/engine/keyboard';
|
||||
import { KeyboardInterface, Mock } from 'keyman/engine/js-processor';
|
||||
import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader';
|
||||
|
||||
|
|
@ -11,21 +11,22 @@ describe('Headless keyboard loading', function () {
|
|||
const laoPath = require.resolve('@keymanapp/common-test-resources/keyboards/lao_2008_basic.js');
|
||||
const khmerPath = require.resolve('@keymanapp/common-test-resources/keyboards/khmer_angkor.js');
|
||||
const nonKeyboardPath = require.resolve('@keymanapp/common-test-resources/index.mjs');
|
||||
const ipaPath = require.resolve('@keymanapp/common-test-resources/keyboards/sil_ipa.js');
|
||||
// const ipaPath = require.resolve('@keymanapp/common-test-resources/keyboards/sil_ipa.js');
|
||||
// Common test suite setup.
|
||||
|
||||
let device = {
|
||||
formFactor: 'desktop',
|
||||
OS: 'windows',
|
||||
browser: 'native'
|
||||
const device = {
|
||||
formFactor: DeviceSpec.FormFactor.Desktop,
|
||||
OS: DeviceSpec.OperatingSystem.Windows,
|
||||
browser: DeviceSpec.Browser.Native,
|
||||
touchable: false
|
||||
}
|
||||
|
||||
describe('Full harness loading', () => {
|
||||
it('successfully loads', async function () {
|
||||
// -- START: Standard Recorder-based unit test loading boilerplate --
|
||||
let harness = new KeyboardInterface({}, MinimalKeymanGlobal);
|
||||
let keyboardLoader = new NodeKeyboardLoader(harness);
|
||||
let keyboard = await keyboardLoader.loadKeyboardFromPath(laoPath);
|
||||
const harness = new KeyboardInterface({}, MinimalKeymanGlobal);
|
||||
const keyboardLoader = new NodeKeyboardLoader(harness);
|
||||
const keyboard = await keyboardLoader.loadKeyboardFromPath(laoPath);
|
||||
harness.activeKeyboard = keyboard;
|
||||
// -- END: Standard Recorder-based unit test loading boilerplate --
|
||||
|
||||
|
|
@ -35,9 +36,9 @@ describe('Headless keyboard loading', function () {
|
|||
|
||||
it('can evaluate rules', async function () {
|
||||
// -- START: Standard Recorder-based unit test loading boilerplate --
|
||||
let harness = new KeyboardInterface({}, MinimalKeymanGlobal);
|
||||
let keyboardLoader = new NodeKeyboardLoader(harness);
|
||||
let keyboard = await keyboardLoader.loadKeyboardFromPath(laoPath);
|
||||
const harness = new KeyboardInterface({}, MinimalKeymanGlobal);
|
||||
const keyboardLoader = new NodeKeyboardLoader(harness);
|
||||
const keyboard = await keyboardLoader.loadKeyboardFromPath(laoPath);
|
||||
harness.activeKeyboard = keyboard;
|
||||
// -- END: Standard Recorder-based unit test loading boilerplate --
|
||||
|
||||
|
|
@ -46,8 +47,8 @@ describe('Headless keyboard loading', function () {
|
|||
});
|
||||
|
||||
it('does not change the active kehboard', async function () {
|
||||
let harness = new KeyboardInterface({}, MinimalKeymanGlobal);
|
||||
let keyboardLoader = new NodeKeyboardLoader(harness);
|
||||
const harness = new KeyboardInterface({}, MinimalKeymanGlobal);
|
||||
const keyboardLoader = new NodeKeyboardLoader(harness);
|
||||
const lao_keyboard = await keyboardLoader.loadKeyboardFromPath(laoPath);
|
||||
assert.isNotOk(harness.activeKeyboard);
|
||||
assert.isOk(lao_keyboard);
|
||||
|
|
@ -66,8 +67,8 @@ describe('Headless keyboard loading', function () {
|
|||
it('throws distinct errors', async function () {
|
||||
const invalidPath = 'totally_invalid_path.js';
|
||||
|
||||
let harness = new KeyboardInterface({}, MinimalKeymanGlobal);
|
||||
let keyboardLoader = new NodeKeyboardLoader(harness);
|
||||
const harness = new KeyboardInterface({}, MinimalKeymanGlobal);
|
||||
const keyboardLoader = new NodeKeyboardLoader(harness);
|
||||
let missingError;
|
||||
try {
|
||||
await keyboardLoader.loadKeyboardFromPath(invalidPath);
|
||||
Loading…
Add table
Reference in a new issue