mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-21 15:17:40 +00:00
feat(developer): unit tests for kmc-model-info
Establishes a baseline unit test for kmc-model-info, in preparation for integration into kmc build.
This commit is contained in:
parent
2775ea0f46
commit
0e5204b2fc
20 changed files with 2525 additions and 3 deletions
|
|
@ -2,9 +2,12 @@ module.exports = {
|
|||
parserOptions: {
|
||||
project: ["./tsconfig.json", "./test/tsconfig.json"],
|
||||
},
|
||||
ignorePatterns: [
|
||||
"test/fixtures/**/*",
|
||||
],
|
||||
overrides: [
|
||||
{
|
||||
files:"src/**/*.ts",
|
||||
files: "src/**/*.ts",
|
||||
// extends: ["../../../common/web/eslint/eslintNoNodeImports.js"],
|
||||
}
|
||||
],
|
||||
|
|
|
|||
|
|
@ -50,8 +50,9 @@ fi
|
|||
#-------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
if builder_start_action test; then
|
||||
npm test
|
||||
# TODO: no unit tests yet, later add: `&& cd test && tsc -b && cd .. && c8 --reporter=lcov --reporter=text mocha`
|
||||
eslint .
|
||||
tsc --build test
|
||||
c8 --reporter=lcov --reporter=text mocha
|
||||
builder_finish_action success test
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import { minKeymanVersion } from "./min-keyman-version.js";
|
|||
import { ModelInfoFile } from "./model-info-file.js";
|
||||
import { KmpJsonFile } from "@keymanapp/common-types";
|
||||
|
||||
/* c8 ignore start */
|
||||
export class ModelInfoOptions {
|
||||
/** The identifier for the model */
|
||||
model_id: string;
|
||||
|
|
@ -25,6 +26,7 @@ export class ModelInfoOptions {
|
|||
/** The compiled package filename and relative path (.kmp) */
|
||||
kmpFileName: string;
|
||||
};
|
||||
/* c8 ignore stop */
|
||||
|
||||
/**
|
||||
* Merges source .model_info file with metadata from the model and package source file.
|
||||
|
|
@ -68,6 +70,7 @@ export function writeMergedModelMetadataFile(
|
|||
//
|
||||
|
||||
function setModelMetadata(field: keyof ModelInfoFile, expected: unknown, warn: boolean = true) {
|
||||
/* c8 ignore next 4 */
|
||||
if (model_info[field] && model_info[field] !== expected) {
|
||||
if (warn || typeof warn === 'undefined')
|
||||
console.warn(`Warning: source ${sourceModelInfoFileName} field ${field} value "${model_info[field]}" does not match "${expected}" found in source file metadata.`);
|
||||
|
|
@ -92,6 +95,7 @@ export function writeMergedModelMetadataFile(
|
|||
if (author.url) {
|
||||
// we strip the mailto: from the .kps file for the .model_info
|
||||
let match = author.url.match(/^(mailto\:)?(.+)$/);
|
||||
/* c8 ignore next 3 */
|
||||
if (match === null) {
|
||||
throw new Error(`Invalid author email: ${author.url}`);
|
||||
}
|
||||
|
|
|
|||
11
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/HISTORY.md
vendored
Normal file
11
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/HISTORY.md
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
Bunong Wordlist Change History
|
||||
====================
|
||||
|
||||
1.1 (2022-02-10)
|
||||
----------------
|
||||
* Updated the wordlist
|
||||
|
||||
1.0 (2021-06-29)
|
||||
----------------
|
||||
* Bible wordlist
|
||||
* Created by SIL International
|
||||
21
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/LICENSE.md
vendored
Normal file
21
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/LICENSE.md
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
© 2021 - 2022 SIL International
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
21
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/README.md
vendored
Normal file
21
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/README.md
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
Bunong Wordlist lexical model
|
||||
===================
|
||||
|
||||
© 2021 - 2022 SIL International
|
||||
|
||||
Version 1.1
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
Bunong Wordlist is based on the Bible wordlist of 2,043 unique entries with their frequencies.
|
||||
|
||||
Supported Platforms
|
||||
-------------------
|
||||
* iPhone
|
||||
* iPad
|
||||
* Android phone
|
||||
* Android tablet
|
||||
* Mobile devices
|
||||
* Tablet devices
|
||||
|
||||
66
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/build/sil.cmo.bw.model.js
vendored
Normal file
66
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/build/sil.cmo.bw.model.js
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/build/sil.cmo.bw.model.kmp
vendored
Normal file
BIN
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/build/sil.cmo.bw.model.kmp
vendored
Normal file
Binary file not shown.
19
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/build/sil.cmo.bw.model_info
vendored
Normal file
19
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/build/sil.cmo.bw.model_info
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"license": "mit",
|
||||
"languages": [
|
||||
"cmo-Khmr"
|
||||
],
|
||||
"description": "Bunong Wordlist is based on the Bible wordlist of 1,157 unique entries with their frequencies.",
|
||||
"id": "sil.cmo.bw",
|
||||
"name": "Bunong Wordlist",
|
||||
"authorName": "",
|
||||
"lastModifiedDate": "2022-06-28T04:06:49.068Z",
|
||||
"packageFilename": "sil.cmo.bw.model.kmp",
|
||||
"packageFileSize": 107384,
|
||||
"jsFilename": "sil.cmo.bw.model.js",
|
||||
"jsFileSize": 286398,
|
||||
"packageIncludes": [],
|
||||
"version": "1.1",
|
||||
"minKeymanVersion": "12.0",
|
||||
"sourcePath": "release/sil/sil.cmo.bw"
|
||||
}
|
||||
91
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/sil.cmo.bw.kpj
vendored
Normal file
91
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/sil.cmo.bw.kpj
vendored
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<KeymanDeveloperProject>
|
||||
<Options>
|
||||
<BuildPath>$PROJECTPATH\build</BuildPath>
|
||||
<CompilerWarningsAsErrors>True</CompilerWarningsAsErrors>
|
||||
<WarnDeprecatedCode>True</WarnDeprecatedCode>
|
||||
<CheckFilenameConventions>True</CheckFilenameConventions>
|
||||
<ProjectType>lexicalmodel</ProjectType>
|
||||
</Options>
|
||||
<Files>
|
||||
<File>
|
||||
<ID>id_dfd4741bbe02549a14ec8bef4abe8086</ID>
|
||||
<Filename>sil.cmo.bw.model.ts</Filename>
|
||||
<Filepath>source\sil.cmo.bw.model.ts</Filepath>
|
||||
<FileVersion>1.0</FileVersion>
|
||||
<FileType>.ts</FileType>
|
||||
</File>
|
||||
<File>
|
||||
<ID>id_5e80cdf613c84a12d5993094b1118f82</ID>
|
||||
<Filename>sil.cmo.bw.model.kps</Filename>
|
||||
<Filepath>source\sil.cmo.bw.model.kps</Filepath>
|
||||
<FileVersion>1.1</FileVersion>
|
||||
<FileType>.kps</FileType>
|
||||
<Details>
|
||||
<Name>Bunong Wordlist</Name>
|
||||
<Copyright>© 2021 - 2022 SIL International</Copyright>
|
||||
<Version>1.1</Version>
|
||||
</Details>
|
||||
</File>
|
||||
<File>
|
||||
<ID>id_ede98e4633e239f933cbfd1f4e1b766c</ID>
|
||||
<Filename>HISTORY.md</Filename>
|
||||
<Filepath>HISTORY.md</Filepath>
|
||||
<FileVersion></FileVersion>
|
||||
<FileType>.md</FileType>
|
||||
</File>
|
||||
<File>
|
||||
<ID>id_53e892b8b41cc4caece1cfd5ef21d6e7</ID>
|
||||
<Filename>LICENSE.md</Filename>
|
||||
<Filepath>LICENSE.md</Filepath>
|
||||
<FileVersion></FileVersion>
|
||||
<FileType>.md</FileType>
|
||||
</File>
|
||||
<File>
|
||||
<ID>id_0730bb7c2e8f9ea2438b52e419dd86c9</ID>
|
||||
<Filename>README.md</Filename>
|
||||
<Filepath>README.md</Filepath>
|
||||
<FileVersion></FileVersion>
|
||||
<FileType>.md</FileType>
|
||||
</File>
|
||||
<File>
|
||||
<ID>id_8146e45ce008c5c83d5a824f2121c46c</ID>
|
||||
<Filename>sil.cmo.bw.model_info</Filename>
|
||||
<Filepath>sil.cmo.bw.model_info</Filepath>
|
||||
<FileVersion></FileVersion>
|
||||
<FileType>.model_info</FileType>
|
||||
</File>
|
||||
<File>
|
||||
<ID>id_46ebc8fccf1bc10c92484653167449df</ID>
|
||||
<Filename>sil.cmo.bw.model.js</Filename>
|
||||
<Filepath>source\..\build\sil.cmo.bw.model.js</Filepath>
|
||||
<FileVersion></FileVersion>
|
||||
<FileType>.js</FileType>
|
||||
<ParentFileID>id_5e80cdf613c84a12d5993094b1118f82</ParentFileID>
|
||||
</File>
|
||||
<File>
|
||||
<ID>id_356e5d149c1e539356d72698c1e401a6</ID>
|
||||
<Filename>welcome.htm</Filename>
|
||||
<Filepath>source\welcome.htm</Filepath>
|
||||
<FileVersion></FileVersion>
|
||||
<FileType>.htm</FileType>
|
||||
<ParentFileID>id_5e80cdf613c84a12d5993094b1118f82</ParentFileID>
|
||||
</File>
|
||||
<File>
|
||||
<ID>id_8da344c4cea6f467013357fe099006f5</ID>
|
||||
<Filename>readme.htm</Filename>
|
||||
<Filepath>source\readme.htm</Filepath>
|
||||
<FileVersion></FileVersion>
|
||||
<FileType>.htm</FileType>
|
||||
<ParentFileID>id_5e80cdf613c84a12d5993094b1118f82</ParentFileID>
|
||||
</File>
|
||||
<File>
|
||||
<ID>id_aaa55e5b6267484eea1c691a46cd4fd0</ID>
|
||||
<Filename>suggestion.png</Filename>
|
||||
<Filepath>source\suggestion.png</Filepath>
|
||||
<FileVersion></FileVersion>
|
||||
<FileType>.png</FileType>
|
||||
<ParentFileID>id_5e80cdf613c84a12d5993094b1118f82</ParentFileID>
|
||||
</File>
|
||||
</Files>
|
||||
</KeymanDeveloperProject>
|
||||
7
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/sil.cmo.bw.model_info
vendored
Normal file
7
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/sil.cmo.bw.model_info
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"license": "mit",
|
||||
"languages": [
|
||||
"cmo-Khmr"
|
||||
],
|
||||
"description": "Bunong Wordlist is based on the Bible wordlist of 1,157 unique entries with their frequencies."
|
||||
}
|
||||
24
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/source/readme.htm
vendored
Normal file
24
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/source/readme.htm
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>បញ្ជីពាក្យភាសាព្នង</title>
|
||||
<style type="text/css">
|
||||
p { font: 12pt Khmer Mondulkiri; }
|
||||
h1 { font: bold 16pt Khmer Mondulkiri; color: #4444cc; margin-bottom: 2px }
|
||||
h2 { font: bold 14pt Khmer Mondulkiri; color: #4444cc; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>បញ្ជីពាក្យភាសាព្នង</h1>
|
||||
|
||||
<p>
|
||||
បញ្ជីពាក្យភាសាព្នងនេះបានបង្កើតឡើងដោយផ្អែកលើបញ្ជីពាក្យព្រះគម្ពីរដែលមាន ២ ០៤៣ ពាក្យ។
|
||||
</p>
|
||||
|
||||
<p>© 2021 - 2022 SIL International</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
60
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/source/sil.cmo.bw.model.kps
vendored
Normal file
60
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/source/sil.cmo.bw.model.kps
vendored
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Package>
|
||||
<System>
|
||||
<KeymanDeveloperVersion>14.0.268.0</KeymanDeveloperVersion>
|
||||
<FileVersion>12.0</FileVersion>
|
||||
</System>
|
||||
<Options>
|
||||
<ExecuteProgram></ExecuteProgram>
|
||||
<ReadMeFile>readme.htm</ReadMeFile>
|
||||
<MSIFileName></MSIFileName>
|
||||
<MSIOptions></MSIOptions>
|
||||
</Options>
|
||||
<StartMenu>
|
||||
<Folder></Folder>
|
||||
<Items/>
|
||||
</StartMenu>
|
||||
<Info>
|
||||
<Name URL="">Bunong Wordlist</Name>
|
||||
<Copyright URL="">© 2021 - 2022 SIL International</Copyright>
|
||||
<Author URL=""></Author>
|
||||
<Version URL="">1.1</Version>
|
||||
</Info>
|
||||
<Files>
|
||||
<File>
|
||||
<Name>..\build\sil.cmo.bw.model.js</Name>
|
||||
<Description></Description>
|
||||
<CopyLocation>0</CopyLocation>
|
||||
<FileType>.js</FileType>
|
||||
</File>
|
||||
<File>
|
||||
<Name>welcome.htm</Name>
|
||||
<Description></Description>
|
||||
<CopyLocation>0</CopyLocation>
|
||||
<FileType>.htm</FileType>
|
||||
</File>
|
||||
<File>
|
||||
<Name>readme.htm</Name>
|
||||
<Description></Description>
|
||||
<CopyLocation>0</CopyLocation>
|
||||
<FileType>.htm</FileType>
|
||||
</File>
|
||||
<File>
|
||||
<Name>suggestion.png</Name>
|
||||
<Description>File suggestion.png</Description>
|
||||
<CopyLocation>0</CopyLocation>
|
||||
<FileType>.png</FileType>
|
||||
</File>
|
||||
</Files>
|
||||
<Keyboards/>
|
||||
<LexicalModels>
|
||||
<LexicalModel>
|
||||
<Name>Bunong Wordlist</Name>
|
||||
<ID>sil.cmo.bw</ID>
|
||||
<Languages>
|
||||
<Language ID="cmo-Khmr">Central Mnong (Khmer)</Language>
|
||||
</Languages>
|
||||
</LexicalModel>
|
||||
</LexicalModels>
|
||||
<Strings/>
|
||||
</Package>
|
||||
26
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/source/sil.cmo.bw.model.ts
vendored
Normal file
26
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/source/sil.cmo.bw.model.ts
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
This is a minimal lexical model source that uses a tab delimited wordlist.
|
||||
See documentation online at https://help.keyman.com/developer/ for
|
||||
additional parameters.
|
||||
*/
|
||||
|
||||
const source: LexicalModelSource = {
|
||||
format: 'trie-1.0',
|
||||
wordBreaker: 'default',
|
||||
sources: ['wordlist.tsv'],,
|
||||
wordBreaker: function(str: string) {
|
||||
return str.split(/\s|\u200b/).map(function(token) {
|
||||
return {
|
||||
left: str.indexOf(token),
|
||||
start: str.indexOf(token),
|
||||
right: str.indexOf(token) + token.length,
|
||||
end: str.indexOf(token) + token.length,
|
||||
text: token
|
||||
}
|
||||
});
|
||||
},
|
||||
punctuation: {
|
||||
insertAfterWord: "\u200B"
|
||||
}
|
||||
};
|
||||
export default source;
|
||||
BIN
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/source/suggestion.png
vendored
Normal file
BIN
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/source/suggestion.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 81 KiB |
30
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/source/welcome.htm
vendored
Normal file
30
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/source/welcome.htm
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>ចាប់ផ្ដើមប្រើបញ្ជីពាក្យភាសាព្នង</title>
|
||||
<style type="text/css">
|
||||
p { font: 12pt Khmer Mondulkiri; }
|
||||
h1 { font: bold 16pt Khmer Mondulkiri; color: #4444cc; margin-bottom: 2px }
|
||||
h2 { font: bold 14pt Khmer Mondulkiri; color: #4444cc; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>ចាប់ផ្ដើមប្រើបញ្ជីពាក្យភាសាព្នង</h1>
|
||||
|
||||
<p>
|
||||
បញ្ជីពាក្យភាសាព្នងនេះបានបង្កើតឡើងដោយផ្អែកលើបញ្ជីពាក្យព្រះគម្ពីរដែលមាន ២ ០៤៣ ពាក្យ។
|
||||
</p>
|
||||
|
||||
<p>ដំណកឃ្លាមើលមិនឃើញត្រូវបានបន្ថែមដោយស្វ័យប្រវត្តិបន្ទាប់ពីជ្រើសរើសពាក្យពីរបាណែនាំពាក្យ។ ពេលវាយបន្ត ពាក្យផ្សេងនឹងលេចឡើងឱ្យជ្រើសរើស។</p>
|
||||
|
||||
<img src='suggestion.png'>
|
||||
|
||||
<p>បើជួបបញ្ហាណាមួយ សូមរៀបរាប់ពីបញ្ហានោះដាក់ក្នុង <a href='https://community.software.sil.org/c/keyman/19'>គេហទំព័រសហគមន៍</a>របស់យើង។</p>
|
||||
|
||||
<p>© 2021 - 2022 SIL International</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
2047
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/source/wordlist.tsv
vendored
Normal file
2047
developer/src/kmc-model-info/test/fixtures/sil.cmo.bw/source/wordlist.tsv
vendored
Normal file
File diff suppressed because it is too large
Load diff
18
developer/src/kmc-model-info/test/helpers/index.ts
Normal file
18
developer/src/kmc-model-info/test/helpers/index.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
* Helpers and utilities for the Mocha tests.
|
||||
*/
|
||||
import * as path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
/**
|
||||
* Builds a path to the fixture with the given path components.
|
||||
*
|
||||
* e.g., makePathToFixture('example.qaa.trivial')
|
||||
* e.g., makePathToFixture('example.qaa.trivial', 'model.ts')
|
||||
*
|
||||
* @param components One or more path components.
|
||||
*/
|
||||
export function makePathToFixture(...components: string[]): string {
|
||||
return fileURLToPath(new URL(path.join('..', '..', '..', 'test', 'fixtures', ...components), import.meta.url));
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
import * as fs from 'fs';
|
||||
import { assert } from 'chai';
|
||||
import 'mocha';
|
||||
import { TestCompilerCallbacks } from '@keymanapp/developer-test-helpers';
|
||||
import { makePathToFixture } from './helpers/index.js';
|
||||
import { writeMergedModelMetadataFile } from '../src/model-info-compiler.js';
|
||||
import { KmpCompiler } from '@keymanapp/kmc-package';
|
||||
|
||||
const callbacks = new TestCompilerCallbacks();
|
||||
|
||||
beforeEach(function() {
|
||||
callbacks.clear();
|
||||
});
|
||||
|
||||
describe('model-info-compiler', function () {
|
||||
it('compile a .model_info file correctly', function() {
|
||||
const path = makePathToFixture('sil.cmo.bw', 'sil.cmo.bw.model_info');
|
||||
const kpsFileName = makePathToFixture('sil.cmo.bw', 'source', 'sil.cmo.bw.model.kps');
|
||||
const kmpFileName = makePathToFixture('sil.cmo.bw', 'build', 'sil.cmo.bw.model.kmp');
|
||||
const buildModelInfoFilename = makePathToFixture('sil.cmo.bw', 'build', 'sil.cmo.bw.model_info');
|
||||
|
||||
const kmpCompiler = new KmpCompiler(callbacks);
|
||||
const kmpJsonData = kmpCompiler.transformKpsToKmpObject(kpsFileName);
|
||||
const modelFileName = makePathToFixture('sil.cmo.bw', 'build', 'sil.cmo.bw.model.js');
|
||||
|
||||
writeMergedModelMetadataFile(path, path+'.out', {
|
||||
kmpFileName,
|
||||
kmpJsonData,
|
||||
model_id: 'sil.cmo.bw',
|
||||
modelFileName,
|
||||
sourcePath: 'release/sil/sil.cmo.bw'
|
||||
});
|
||||
|
||||
const actual = JSON.parse(fs.readFileSync(path+'.out', 'utf-8'));
|
||||
let expected = JSON.parse(fs.readFileSync(buildModelInfoFilename, 'utf-8'));
|
||||
|
||||
// `lastModifiedDate` is dependent on time of run (not worth mocking)
|
||||
delete actual['lastModifiedDate'];
|
||||
delete expected['lastModifiedDate'];
|
||||
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
it('compile a .model_info file correctly when no source .model_info exists', function() {
|
||||
this.skip(); // TODO: support model_info when no source file exists (determine license from LICENSE.md)
|
||||
});
|
||||
});
|
||||
26
developer/src/kmc-model-info/test/tsconfig.json
Normal file
26
developer/src/kmc-model-info/test/tsconfig.json
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"extends": "../../kmc/tsconfig.kmc-base.json",
|
||||
|
||||
"compilerOptions": {
|
||||
"rootDir": ".",
|
||||
"rootDirs": ["./", "../src/"],
|
||||
"outDir": "../build/test",
|
||||
"esModuleInterop": true,
|
||||
"moduleResolution": "node16",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@keymanapp/developer-test-helpers": ["../../common/web/test-helpers/index"],
|
||||
"@keymanapp/kmc-package": ["../../kmc-package/source"],
|
||||
},
|
||||
},
|
||||
"include": [
|
||||
"**/test-*.ts",
|
||||
"helpers/*.ts",
|
||||
],
|
||||
"references": [
|
||||
{ "path": "../" },
|
||||
{ "path": "../../common/web/test-helpers/" },
|
||||
{ "path": "../../kmc-package/" },
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue