mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-14 20:59:25 +00:00
[Developer] Add first test for kmp compiler
This commit is contained in:
parent
52ec17e0fc
commit
ff337f3464
3 changed files with 77 additions and 0 deletions
1
developer/js/tests/fixtures/example.qaa.sencoten/example.qaa.sencoten.model.kmp.json
vendored
Normal file
1
developer/js/tests/fixtures/example.qaa.sencoten/example.qaa.sencoten.model.kmp.json
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"system":{"keymanDeveloperVersion":"12.0.1500.0","fileVersion":"12.0"},"options":{"followKeyboardVersion":true},"info":{"author":{"description":"Eddie Antonio Santos","url":"mailto:Eddie.Santos@nrc-cnrc.gc.ca"},"copyright":{"description":"© 2019 National Research Council Canada"},"name":{"description":"SENĆOŦEN (Saanich Dialect) Lexical Model"},"version":{"description":"1.0.3"}},"files":[{"name":"..\\build\\example.qaa.sencoten.model.js","description":"Lexical model example.qaa.sencoten.model.js","copyLocation":"0","fileType":".model.js"}],"lexicalModels":[{"name":"SENĆOŦEN dictionary","id":"example.qaa.sencoten","version":"1.0.3","languages":[{"name":"North Straits Salish","id":"qaa"},{"name":"SENĆOŦEN","id":"qaa-Latn"}]}]}
|
||||
35
developer/js/tests/fixtures/example.qaa.sencoten/example.qaa.sencoten.model.kps
vendored
Normal file
35
developer/js/tests/fixtures/example.qaa.sencoten/example.qaa.sencoten.model.kps
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Package>
|
||||
<System>
|
||||
<KeymanDeveloperVersion>12.0.1500.0</KeymanDeveloperVersion>
|
||||
<FileVersion>12.0</FileVersion>
|
||||
</System>
|
||||
<Options>
|
||||
<FollowKeyboardVersion/>
|
||||
</Options>
|
||||
<Info>
|
||||
<Name URL="">SENĆOŦEN (Saanich Dialect) Lexical Model</Name>
|
||||
<Copyright URL="">© 2019 National Research Council Canada</Copyright>
|
||||
<Author URL="mailto:Eddie.Santos@nrc-cnrc.gc.ca">Eddie Antonio Santos</Author>
|
||||
<Version>1.0.3</Version>
|
||||
</Info>
|
||||
<Files>
|
||||
<File>
|
||||
<Name>..\build\example.qaa.sencoten.model.js</Name>
|
||||
<Description>Lexical model example.qaa.sencoten.model.js</Description>
|
||||
<CopyLocation>0</CopyLocation>
|
||||
<FileType>.model.js</FileType>
|
||||
</File>
|
||||
</Files>
|
||||
<LexicalModels>
|
||||
<LexicalModel>
|
||||
<Name>SENĆOŦEN dictionary</Name>
|
||||
<ID>example.qaa.sencoten</ID>
|
||||
<Version>1.0.3</Version>
|
||||
<Languages>
|
||||
<Language ID="qaa">North Straits Salish</Language>
|
||||
<Language ID="qaa-Latn">SENĆOŦEN</Language>
|
||||
</Languages>
|
||||
</LexicalModel>
|
||||
</LexicalModels>
|
||||
</Package>
|
||||
41
developer/js/tests/test-package-compiler.ts
Normal file
41
developer/js/tests/test-package-compiler.ts
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import 'mocha';
|
||||
import * as fs from 'fs';
|
||||
import {assert} from 'chai';
|
||||
|
||||
import KmpCompiler from '../dist/package-compiler/kmp-compiler';
|
||||
import {makePathToFixture} from './helpers';
|
||||
|
||||
describe('KmpCompiler', function () {
|
||||
const MODELS = [
|
||||
'example.qaa.sencoten',
|
||||
];
|
||||
|
||||
let kmpCompiler = new KmpCompiler();
|
||||
|
||||
for (let modelID of MODELS) {
|
||||
let kpsPath = makePathToFixture(modelID, `${modelID}.model.kps`);
|
||||
let kmpJsonPath = makePathToFixture(modelID, `${modelID}.model.kmp.json`);
|
||||
let kmpJsonFixture = JSON.parse(fs.readFileSync(kmpJsonPath, 'utf-8'));
|
||||
|
||||
//
|
||||
// Test just the transform from kps to kmp.json
|
||||
//
|
||||
it(`should transform ${modelID}.model.kps to kmp.json`, function () {
|
||||
let source = fs.readFileSync(kpsPath, 'utf-8');
|
||||
let kmpJson: KmpJsonFile;
|
||||
|
||||
assert.doesNotThrow(() => {
|
||||
kmpJson = kmpCompiler.transformKpsToKmpObject(source);
|
||||
});
|
||||
|
||||
// Test that the kmp.json data is identical
|
||||
assert.deepEqual(kmpJson, kmpJsonFixture);
|
||||
|
||||
// This was used when building initial test data
|
||||
//fs.writeFileSync(kmpJsonPath, JSON.stringify(kmpJson), 'utf-8');
|
||||
});
|
||||
|
||||
// TODO: end-to-end test to build .model.kmp file; however, this depends on building model and kmp.json first
|
||||
//let kmpPath = makePathToFixture(modelID, `${modelID}.model.kmp`);
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Reference in a new issue