mirror of
https://github.com/keymanapp/keyman.git
synced 2026-10-29 09:17:45 +00:00
58 lines
2.1 KiB
TypeScript
58 lines
2.1 KiB
TypeScript
/*
|
|
* Keyman is 2025 copyright (C) SIL International. MIT License.
|
|
*
|
|
* Tests for KeylayoutToKmnConverter, KeylayoutFileReader, KmnFileWriter
|
|
*
|
|
*/
|
|
|
|
import 'mocha';
|
|
import { assert } from 'chai';
|
|
import { compilerTestCallbacks, makePathToFixture } from './helpers/index.js';
|
|
import { KeylayoutFileReader } from '../src/keylayout-to-kmn/keylayout-file-reader.js';
|
|
import { KeylayoutToKmnConverter } from '../src/keylayout-to-kmn/keylayout-to-kmn-converter.js';
|
|
|
|
//-----------------------------------------------------------------------------------------------------------------------
|
|
|
|
describe('KeylayoutFileReader', function () {
|
|
|
|
before(function () {
|
|
compilerTestCallbacks.clear();
|
|
});
|
|
|
|
describe("read() ", function () {
|
|
|
|
const sut_r = new KeylayoutFileReader(compilerTestCallbacks);
|
|
|
|
it('read() should return filled array on correct input', async function () {
|
|
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Test.keylayout');
|
|
const result = sut_r.read(inputFilename);
|
|
assert.isNotEmpty(result);
|
|
});
|
|
|
|
it('read() should return empty array on null input', async function () {
|
|
const result = sut_r.read(null);
|
|
assert.isNull(result);
|
|
});
|
|
|
|
it('read() should return empty array on empty input', async function () {
|
|
const result = sut_r.read("");
|
|
assert.isNull(result);
|
|
});
|
|
|
|
it('read() should return empty array on space as input', async function () {
|
|
const result = sut_r.read(" ");
|
|
assert.isNull(result);
|
|
});
|
|
|
|
it('read() should return empty array on unavailable file name', async function () {
|
|
const inputFilename_unavailable = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/X.keylayout');
|
|
const result = sut_r.read(inputFilename_unavailable);
|
|
assert.isNull(result);
|
|
});
|
|
|
|
it('read() should return empty array on typo in path', async function () {
|
|
const result = sut_r.read(makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '|Test.keylayout'));
|
|
assert.isNull(result);
|
|
});
|
|
});
|
|
});
|