chore(developer): add ERROR_LicenseFileIsDamaged (null on decode) test

This commit is contained in:
Dr Mark C. Sinclair 2024-03-04 12:17:05 +00:00
parent d790a2d5a5
commit f9a2e92609

View file

@ -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 {