diff --git a/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts b/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts index bdd21e9d79..1650ed0292 100644 --- a/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts +++ b/developer/src/kmc-keyboard-info/test/test-keyboard-info-compiler.ts @@ -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 {