From 5d92ff6635a6d01ff9730ab7ea861bad228daa76 Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Fri, 13 Sep 2024 17:23:50 +0200 Subject: [PATCH] chore(web): move kbdInterface tests to typescript --- web/src/engine/js-processor/build.sh | 7 +++- ...terface.tests.js => kbdInterface.tests.ts} | 33 ++++++++++--------- 2 files changed, 23 insertions(+), 17 deletions(-) rename web/src/test/auto/headless/engine/js-processor/{kbdInterface.tests.js => kbdInterface.tests.ts} (72%) diff --git a/web/src/engine/js-processor/build.sh b/web/src/engine/js-processor/build.sh index db00593166a..34546a913bd 100755 --- a/web/src/engine/js-processor/build.sh +++ b/web/src/engine/js-processor/build.sh @@ -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 diff --git a/web/src/test/auto/headless/engine/js-processor/kbdInterface.tests.js b/web/src/test/auto/headless/engine/js-processor/kbdInterface.tests.ts similarity index 72% rename from web/src/test/auto/headless/engine/js-processor/kbdInterface.tests.js rename to web/src/test/auto/headless/engine/js-processor/kbdInterface.tests.ts index 0d084964425..c58a7d91910 100644 --- a/web/src/test/auto/headless/engine/js-processor/kbdInterface.tests.js +++ b/web/src/test/auto/headless/engine/js-processor/kbdInterface.tests.ts @@ -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);