mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-24 08:37:42 +00:00
chore(developer): add ERROR_LicenseFileIsDamaged (null on decode) test
This commit is contained in:
parent
d790a2d5a5
commit
f9a2e92609
1 changed files with 29 additions and 1 deletions
|
|
@ -198,7 +198,35 @@ describe('keyboard-info-compiler', function () {
|
|||
`ERROR_ERROR_LicenseFileIsDamaged not generated, instead got: `+JSON.stringify(callbacks.messages,null,2));
|
||||
assert.isTrue(nodeCompilerMessage(callbacks, KeyboardInfoCompilerMessages.ERROR_LicenseFileIsDamaged).includes(licenseFilename),
|
||||
licenseFilename+' not found in the message');
|
||||
});
|
||||
});
|
||||
|
||||
// ERROR_LicenseFileIsDamaged (null on decode)
|
||||
|
||||
it('should generate ERROR_LicenseFileIsDamaged error if license file returns null on decode', async function() {
|
||||
const jsFilename = makePathToFixture('khmer_angkor', 'build', 'khmer_angkor.js');
|
||||
const kpsFilename = makePathToFixture('khmer_angkor', 'source', 'khmer_angkor.kps');
|
||||
const kmpFilename = makePathToFixture('khmer_angkor', 'build', 'khmer_angkor.kmp');
|
||||
|
||||
const sources = {
|
||||
kmpFilename,
|
||||
sourcePath: 'release/k/khmer_angkor',
|
||||
kpsFilename,
|
||||
jsFilename: jsFilename,
|
||||
forPublishing: true,
|
||||
};
|
||||
|
||||
const compiler = new KeyboardInfoCompiler();
|
||||
assert.isTrue(await compiler.init(callbacks, {sources}));
|
||||
const licenseFilename = makePathToFixture('khmer_angkor', 'LICENSE.md');
|
||||
TextDecoder.prototype.decode = () => { return null }
|
||||
const result = compiler['isLicenseMIT'](licenseFilename)
|
||||
assert.isFalse(result);
|
||||
|
||||
assert.isTrue(callbacks.hasMessage(KeyboardInfoCompilerMessages.ERROR_LicenseFileIsDamaged),
|
||||
`ERROR_ERROR_LicenseFileIsDamaged not generated, instead got: `+JSON.stringify(callbacks.messages,null,2));
|
||||
assert.isTrue(nodeCompilerMessage(callbacks, KeyboardInfoCompilerMessages.ERROR_LicenseFileIsDamaged).includes(licenseFilename),
|
||||
licenseFilename+' not found in the message');
|
||||
});
|
||||
});
|
||||
|
||||
function nodeCompilerMessage(ncb: TestCompilerCallbacks, code: number): string {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue