feat(developer): work on comments of PR review

This commit is contained in:
Sabine 2026-06-04 11:20:45 +02:00
parent 82c8af2034
commit 160f92a858
7 changed files with 117 additions and 124 deletions

View file

@ -20,7 +20,7 @@ export class ConverterMessages {
static ERROR_FileNotFound = SevError | 0x0003;
static Error_FileNotFound = (o: { inputFilename: string | null; }) => m(
this.ERROR_FileNotFound,
`Input filename '${def(o.inputFilename)}' does not exist or could not be loaded.`
`Input filename '${def(o?.inputFilename)}' does not exist or could not be loaded.`
);
static ERROR_InvalidFile = SevError | 0x0004;

View file

@ -18,9 +18,9 @@ export class KeylayoutFileReader {
constructor(private callbacks: CompilerCallbacks /*,private options: CompilerOptions*/) { };
/**
* @brief helper function to check if a specific keyMap index exists in a keyMapSet
* neccessary because the amount of <keyMap index> must correspond to
* the amount of <keyMapSelect mapIndex>
* @brief Helper function to check if a specific keyMap index exists in a keyMapSet.
* This is neccessary because the amount of <keyMap index> must correspond to
* the amount of <keyMapSelect mapIndex>.
* @param jsonObj the read keylayout data to be checked
* @param keyMapSelect the keyMapSelect element to find in keyMapSet
* @return true if the keyMapSet element is found, false if not
@ -37,9 +37,9 @@ export class KeylayoutFileReader {
}
/**
* @brief helper function to check if a specific keyMapSelect index exists in a modifierMap
* neccessary because the amount of <keyMap index> must correspond to
* the amount of <keyMapSelect mapIndex>
* @brief Helper function to check if a specific keyMapSelect index exists in a modifierMap.
* This is neccessary because the amount of <keyMap index> must correspond to
* the amount of <keyMapSelect mapIndex>.
* @param jsonObj the read keylayout data to be checked
* @param keyMap the keyMap element to find in modifierMap
* @return true if the keyMap element is found, false if not

View file

@ -52,7 +52,7 @@ export interface KeylayoutFileData {
key?: string;
behavior: string;
modifier?: string;
outchar?: string | undefined;
outchar?: string;
};
/**
@ -492,7 +492,7 @@ export class KeylayoutToKmnConverter {
} else {
this.callbacks.reportMessage(ConverterMessages.Error_UnsupportedCharactersDetected({
keymapIndex: jsonObj.keyboard.keyMapSet[0].keyMap[i]['index'],
output: jsonObj.keyboard.keyMapSet[0].keyMap[i].key[j]['output'] ?? '' as string,
output: jsonObj.keyboard.keyMapSet[0].keyMap[i].key[j]['output'] ?? '',
key: jsonObj.keyboard.keyMapSet[0].keyMap[i].key[j]['code'],
KeyName: this.mapUkeleleKeycodeToVK(Number(jsonObj.keyboard.keyMapSet[0].keyMap[i].key[j]['code']))
}));

View file

@ -149,7 +149,6 @@ export class KmnFileWriter {
// use of Unicode Character vs Unicode Codepoint;
// If it`s a ctrl character we print out the Unicode Codepoint else we print out the Unicode Character
let versionOutputCharacter;
const warnText = this.reviewRules(uniqueDataRules, k);
const outputCharacter = new TextDecoder().decode(uniqueDataRules[k].output);
@ -157,16 +156,9 @@ export class KmnFileWriter {
// const outputUnicodeCharacter = util.convertToUnicodeCharacter(outputCharacter);
// const outputUnicodeCodePoint = util.convertToUnicodeCodePoint(outputCharacter);
// in case writeCharacterOrUnicode() returns null, the fallback is empty strings for characterMessage.character
// and characterMessage.message. Then versionOutputCharacter could be "" and would be written into the kmn file
// as ... > '', producing an invalid kmn rule.
if ((outputCharacter !== undefined) && (outputCharacter !== "")) {
const characterMessage = this.writeCharacterOrUnicode(outputCharacter, warnText[2]);
versionOutputCharacter = characterMessage?.character ?? "";
warnText[2] = characterMessage?.message ?? "";
}
const characterMessage = this.writeCharacterOrUnicode(outputCharacter, warnText[2]);
const versionOutputCharacter = characterMessage.character;
warnText[2] = characterMessage.message;
// add a warning in front of rules in case unavailable modifiers or ambiguous rules are used
// if warning contains duplicate rules we do not write out the entire rule
@ -219,7 +211,6 @@ export class KmnFileWriter {
// use of Unicode Character vs Unicode Codepoint;
// If it`s a ctrl character we print out the Unicode Codepoint else we print out the Unicode Character
let versionOutputCharacter;
const warnText = this.reviewRules(uniqueDataRules, k);
const outputCharacter = new TextDecoder().decode(uniqueDataRules[k].output);
@ -227,14 +218,9 @@ export class KmnFileWriter {
// const outputUnicodeCharacter = util.convertToUnicodeCharacter(outputCharacter);
// const outputUnicodeCodePoint = util.convertToUnicodeCodePoint(outputCharacter);
// in case writeCharacterOrUnicode() returns null, the fallback is empty strings for characterMessage.character
// and characterMessage.message. Then versionOutputCharacter could be "" and would be written into the kmn file
// as ... > '', producing an invalid kmn rule.
if ((outputCharacter !== undefined) && (outputCharacter !== "")) {
const characterMessage = this.writeCharacterOrUnicode(outputCharacter, warnText[2]);
versionOutputCharacter = characterMessage?.character ?? "";
warnText[2] = characterMessage?.message ?? "";
}
const characterMessage = this.writeCharacterOrUnicode(outputCharacter, warnText[2]);
const versionOutputCharacter = characterMessage.character;
warnText[2] = characterMessage.message;
// add a warning in front of rules in case unavailable modifiers or ambiguous rules are used
// if warning contains duplicate rules we do not write out the entire rule
@ -309,20 +295,14 @@ export class KmnFileWriter {
// use of Unicode Character vs Unicode Codepoint;
// If it`s a ctrl character we print out the Unicode Codepoint else we print out the Unicode Character
let versionOutputCharacter;
const warnText = this.reviewRules(uniqueDataRules, k);
const outputCharacter = new TextDecoder().decode(uniqueDataRules[k].output);
// TODO-kmc-convert: after merge of PR 14569 use functions from util instead of the ones in this class
// in case writeCharacterOrUnicode() returns null, the fallback is empty strings for characterMessage.character
// and characterMessage.message. Then versionOutputCharacter could be "" and would be written into the kmn file
// as ... > '', producing an invalid kmn rule.
if ((outputCharacter !== undefined) && (outputCharacter !== "")) {
const characterMessage = this.writeCharacterOrUnicode(outputCharacter, warnText[2]);
versionOutputCharacter = characterMessage?.character ?? "";
warnText[2] = characterMessage?.message ?? "";
}
const characterMessage = this.writeCharacterOrUnicode(outputCharacter, warnText[2]);
const versionOutputCharacter = characterMessage.character;
warnText[2] = characterMessage.message;
// add a warning in front of rules in case unavailable modifiers or ambiguous rules are used
// if warning contains duplicate rules we do not write out the entire rule
@ -1636,10 +1616,10 @@ export class KmnFileWriter {
* a non-control character will be written as itself ( 'A', '1', '፩', '😎')
* null in case of an empty string or null or undefined input
*/
public writeCharacterOrUnicode(ctr: string, msg: string = ""): MessageCharacter | null {
public writeCharacterOrUnicode(ctr: string, msg: string = ""): MessageCharacter {
if ((ctr === null) || (ctr === undefined) || (ctr.length === 0)) {
return null;
return { character: '', message: '' };
}
let versionOutputCharacter;
@ -1653,8 +1633,14 @@ export class KmnFileWriter {
const m_dec = /^&#([0-9]{1,7});$/.exec(ctr);
// find the value of output character which may be specified in unicode, html hex or html dec format ( e.g. U+1234 -> 1234; &#x1234; -> 1234; &#4660; -> 1234)
const ctr_val = ((m_uni || m_hex || m_dec) ?
m_uni ? parseInt(m_uni[1], 16) : m_hex ? parseInt(m_hex[1], 16) : m_dec ? parseInt(m_dec[1], 10) : KeylayoutToKmnConverter.MAX_CTRL_CHARACTER : KeylayoutToKmnConverter.MAX_CTRL_CHARACTER
const ctr_val = (
m_uni
? parseInt(m_uni[1], 16)
: m_hex
? parseInt(m_hex[1], 16)
: m_dec
? parseInt(m_dec[1], 10)
: KeylayoutToKmnConverter.MAX_CTRL_CHARACTER
);
// for control characters in 'U+...', '&#x...' or '&#...' format as well as in "" format
@ -1693,8 +1679,7 @@ export class KmnFileWriter {
*/
public convertToUnicodeCharacter(inputString: string): string | undefined {
// null, undefined will later be refused for conversion
// null, undefined will later be treated as '' in conversion
if (inputString == null || inputString == undefined) {
return undefined;
}

View file

@ -157,7 +157,7 @@ describe('KeylayoutFileReader', function () {
it(("findMapIndexinKeymap(keyMapSelect.mapIndex = '" + values[0] + "')").padEnd(40, " ") + "should return " + "'" + values[1] + "'", async function () {
keyMapSelect.mapIndex = values[0] as string;
const result = sutR.findMapIndexinKeymap(jsonO as Keylayout.KeylayoutXMLSourceFile, keyMapSelect);
assert.isTrue(result === values[1]);
assert.equal(result, values[1]);
});
});
});
@ -187,7 +187,7 @@ describe('KeylayoutFileReader', function () {
it(("findIndexinKeymapSelect(keyMap.index = '" + values[0] + "')").padEnd(40, " ") + "should return " + "'" + values[1] + "'", async function () {
keyMap.index = values[0] as string;
const result = sutR.findIndexinKeymapSelect(jsonO as Keylayout.KeylayoutXMLSourceFile, keyMap);
assert.isTrue(result === values[1]);
assert.equal(result, values[1]);
});
});
});
@ -204,7 +204,7 @@ describe('KeylayoutFileReader', function () {
it(("checkForCorrespondingElements in " + values[0]).padEnd(40, " ") + "should return " + "'" + values[1] + "'", async function () {
const jsonO: Keylayout.KeylayoutXMLSourceFile | null = sutR.read(compilerTestCallbacks.loadFile(makePathToFixture(values[0] as string)));
const result = sutR.checkForCorrespondingElements(jsonO as Keylayout.KeylayoutXMLSourceFile);
assert.isTrue(result === values[1]);
assert.equal(result, values[1]);
});
});
});
@ -219,7 +219,7 @@ describe('KeylayoutFileReader', function () {
const result: Keylayout.KeylayoutXMLSourceFile = sutR.read(binaryData);
assert.isNotNull(result);
assert.isTrue(result.keyboard !== null);
assert.notEqual(result.keyboard, null);
for (let i = 0; i < result.keyboard.layouts.length; i++) {
assert.isTrue(result.keyboard.layouts[i].layout.length > 0);
@ -231,8 +231,8 @@ describe('KeylayoutFileReader', function () {
for (let j = 0; j < result.keyboard.keyMapSet[i].keyMap.length; j++) {
assert.isTrue(result.keyboard.keyMapSet[i].keyMap[j].key.length > 0);
for (let k = 0; k < result.keyboard.keyMapSet[i].keyMap[j].key.length; k++) {
assert.isTrue(result.keyboard.keyMapSet[i].keyMap[j].key[k]['action'] !== null
|| result.keyboard.keyMapSet[i].keyMap[j].key[k]['output'] !== null);
assert.isNotNull(result.keyboard.keyMapSet[i].keyMap[j].key[k]['action']);
assert.isNotNull(result.keyboard.keyMapSet[i].keyMap[j].key[k]['output']);
}
}
}
@ -247,8 +247,8 @@ describe('KeylayoutFileReader', function () {
for (let i = 0; i < result.keyboard.modifierMap.length; i++) {
assert.isTrue(result.keyboard.modifierMap[i].keyMapSelect.length > 0);
for (let j = 0; j < result.keyboard.keyMapSet.length; j++) {
assert.isTrue(result.keyboard.keyMapSet[j].keyMap.length
=== result.keyboard.modifierMap[i].keyMapSelect.length);
assert.equal(result.keyboard.keyMapSet[j].keyMap.length,
result.keyboard.modifierMap[i].keyMapSelect.length);
}
}
});

View file

@ -47,8 +47,8 @@ describe('KeylayoutToKmnConverter', function () {
['../data/Test_ExtraWarning.keylayout'],
].forEach(function (files) {
it(files + " should give no errors ", async function () {
sut.run(makePathToFixture(files[0]));
assert.isTrue(compilerTestCallbacks.messages.length === 0);
await sut.run(makePathToFixture(files[0]));
assert.equal(compilerTestCallbacks.messages.length, 0);
});
});
});
@ -70,7 +70,7 @@ describe('KeylayoutToKmnConverter', function () {
['../data/Test_characters.keylayout'],
].forEach(function (files) {
it(files + " should give an error ", async function () {
sut.run(makePathToFixture(files[0]));
await sut.run(makePathToFixture(files[0]));
assert.isTrue(compilerTestCallbacks.messages.length > 0);
});
});
@ -83,8 +83,8 @@ describe('KeylayoutToKmnConverter', function () {
['../data/Test_undefinedAction.keylayout'],
].forEach(function (files) {
it(files + " should give Error: undefined action detected", async function () {
sut.run(makePathToFixture(files[0]));
assert.isTrue(compilerTestCallbacks.messages.length === 1);
await sut.run(makePathToFixture(files[0]));
assert.equal(compilerTestCallbacks.messages.length, 1);
assert.equal(compilerTestCallbacks.messages[0].code, 5292040);
});
});
@ -95,10 +95,9 @@ describe('KeylayoutToKmnConverter', function () {
it('run() should throw on unavailable input file name and null output file name', async function () {
const inputFilename = makePathToFixture('../data/Unavailable.keylayout');
const result = sut.run(inputFilename, undefined);
assert.isNotNull(result);
const result = await sut.run(inputFilename, undefined);
assert.isNull(result);
assert.equal(compilerTestCallbacks.messages.length, 2);
//assert.deepEqual(compilerTestCallbacks.messages[0], ConverterMessages.Error_UnableToRead());
assert.isTrue(compilerTestCallbacks.hasMessage(ConverterMessages.ERROR_UnableToRead));
assert.equal(compilerTestCallbacks.messages[1].code, 5292037);
});
@ -115,43 +114,44 @@ describe('KeylayoutToKmnConverter', function () {
['../data/OutputXName.bb'],
].forEach(function (files) {
it(infile + " should run ", async function () {
await NodeAssert.doesNotReject(async () => sut.run(makePathToFixture(infile), makePathToFixture(files[0])?? undefined));
await NodeAssert.doesNotReject(async () => await sut.run(makePathToFixture(infile), makePathToFixture(files[0]) ?? undefined));
assert.equal(compilerTestCallbacks.messages.length, 0);
});
});
});
describe('convert() ', function () {
const sut = new KeylayoutToKmnConverter(compilerTestCallbacks, compilerTestOptions);
const sutR = new KeylayoutFileReader(compilerTestCallbacks);
// ProcessedData from usable file
const inputFilename = makePathToFixture('../data/Test.keylayout');
const read = sutR.read(compilerTestCallbacks.loadFile(inputFilename));
let sut: KeylayoutToKmnConverter;
let sutR: KeylayoutFileReader;
const converted = sut.unitTestEndpoints.convert(read as KeylayoutXMLSourceFile, inputFilename.replace(/\.keylayout$/, '.kmn'));
// ProcessedData from unavailable file
const inputFilenameUnavailable = makePathToFixture('../data/X.keylayout');
const readUnavailable = sutR.read(compilerTestCallbacks.loadFile(inputFilenameUnavailable));
const convertedUnavailable = sut.unitTestEndpoints.convert(readUnavailable as KeylayoutXMLSourceFile, inputFilenameUnavailable.replace(/\.keylayout$/, '.kmn'));
// ProcessedData from empty file
const inputFilenameEmpty = makePathToFixture('');
const readEmpty = sutR.read(compilerTestCallbacks.loadFile(inputFilenameEmpty));
const convertedEmpty = sut.unitTestEndpoints.convert(readEmpty as KeylayoutXMLSourceFile, inputFilenameEmpty);
it('should return converted array on correct input', async function () {
assert.isTrue(converted?.rules.length !== 0);
beforeEach(function () {
sut = new KeylayoutToKmnConverter(compilerTestCallbacks, compilerTestOptions);
sutR = new KeylayoutFileReader(compilerTestCallbacks);
});
// ProcessedData from usable file
it('should return converted array on correct input', async function () {
const inputFilename = makePathToFixture('../data/Test.keylayout');
const read = sutR.read(compilerTestCallbacks.loadFile(inputFilename));
const converted = sut.unitTestEndpoints.convert(read as KeylayoutXMLSourceFile, inputFilename.replace(/\.keylayout$/, '.kmn'));
assert.isNotNull(converted);
assert.notEqual(converted.rules.length, 0);
});
// ProcessedData from unavailable file
it('should return null on empty name as input', async function () {
const inputFilenameUnavailable = makePathToFixture('../data/X.keylayout');
const readUnavailable = sutR.read(compilerTestCallbacks.loadFile(inputFilenameUnavailable));
const convertedUnavailable = sut.unitTestEndpoints.convert(readUnavailable as KeylayoutXMLSourceFile, inputFilenameUnavailable.replace(/\.keylayout$/, '.kmn'));
assert.isNull(convertedUnavailable);
});
// ProcessedData from empty file
it('should return null on empty input', async function () {
const inputFilenameEmpty = makePathToFixture('');
const readEmpty = sutR.read(compilerTestCallbacks.loadFile(inputFilenameEmpty));
const convertedEmpty = sut.unitTestEndpoints.convert(readEmpty as KeylayoutXMLSourceFile, inputFilenameEmpty);
assert.isNull(convertedEmpty);
});
@ -281,7 +281,7 @@ describe('KeylayoutToKmnConverter', function () {
].forEach(function (values) {
it(("checkIfCapsIsUsed(" + values[0] + ")").padEnd(40, " ") + "should return " + "'" + values[1] + "'", async function () {
const result = sut.checkIfCapsIsUsed(values[0] as string[][]);
assert.isTrue(result === values[1]);
assert.equal(result, values[1]);
});
});
});
@ -308,7 +308,6 @@ describe('KeylayoutToKmnConverter', function () {
it((values[1] !== null) ?
("getModifierArrayFromKeyModifierArray('" + JSON.stringify(values[0]) + "')").padEnd(68, " ") + " should return '" + JSON.stringify(values[1]) + "'" :
("getModifierArrayFromKeyModifierArray('" + JSON.stringify(values[0]) + "')").padEnd(68, " ") + " should return '" + "null" + "'", async function () {
const result = sut.getModifierArrayFromKeyModifierArray(converted?.modifiers as string[][], values[0] as unknown as KeylayoutFileData[]);
assert.deepStrictEqual(JSON.stringify(result), JSON.stringify(values[1]));
});
@ -605,14 +604,13 @@ describe('KeylayoutToKmnConverter', function () {
['', 'a', false, []],
['', '', , []],
].forEach(function (values) {
if (converted) {
it((JSON.stringify(values[3]).length > 35) ?
("getActionOutputbehaviorKeyModiFromActionIDStateOutput('" + values[0] + "', '" + values[1] + "', " + values[2] + ")").padEnd(67, " ") + ' should return an array of objects' :
("getActionOutputbehaviorKeyModiFromActionIDStateOutput('" + values[0] + "', '" + values[1] + "', " + values[2] + ")").padEnd(67, " ") + ' should return ' + "'" + JSON.stringify(values[3]) + "'", async function () {
const result = sut.getActionOutputBehaviorKeyModiFromActionIDStateOutput(read as KeylayoutXMLSourceFile, converted.modifiers, String(values[0]), String(values[1]), Boolean(values[2]));
assert.equal(JSON.stringify(result), JSON.stringify(values[3]));
});
}
assert.isNotNull(read);
it((JSON.stringify(values[3]).length > 35) ?
("getActionOutputbehaviorKeyModiFromActionIDStateOutput('" + values[0] + "', '" + values[1] + "', " + values[2] + ")").padEnd(67, " ") + ' should return an array of objects' :
("getActionOutputbehaviorKeyModiFromActionIDStateOutput('" + values[0] + "', '" + values[1] + "', " + values[2] + ")").padEnd(67, " ") + ' should return ' + "'" + JSON.stringify(values[3]) + "'", async function () {
const result = sut.getActionOutputBehaviorKeyModiFromActionIDStateOutput(read as KeylayoutXMLSourceFile, converted.modifiers, String(values[0]), String(values[1]), Boolean(values[2]));
assert.equal(JSON.stringify(result), JSON.stringify(values[3]));
});
});
});
@ -775,8 +773,9 @@ describe('KeylayoutToKmnConverter', function () {
it('data of \'' + values[0] + "' passed into createRuleData() " + 'should create an array of rules', async function () {
const inputFilename = makePathToFixture(values[0][0]);
const read = sutR.read(compilerTestCallbacks.loadFile(inputFilename));
const processedData = sut.unitTestEndpoints.convert(read as KeylayoutXMLSourceFile, inputFilename.replace(/\.keylayout$/, '.kmn'));
assert.deepEqual(processedData?.rules[0], values[1][0]);
const processedData = sut.unitTestEndpoints.convert(read, inputFilename.replace(/\.keylayout$/, '.kmn'));
assert.isNotNull(processedData);
assert.deepEqual(processedData.rules[0], values[1][0]);
});
});
});

View file

@ -64,7 +64,8 @@ describe('KmnFileWriter', function () {
it(('writeKmnFileHeader should return store text with filename ').padEnd(62, " ") + 'on correct input', async function () {
const writtenCorrectName = sutW.writeKmnFileHeader(converted);
assert.equal(writtenCorrectName, (outExpectedFirst + (converted?.keylayoutFilename ?? "") + outExpectedLast));
assert.isNotNull(converted);
assert.equal(writtenCorrectName, (outExpectedFirst + (converted.keylayoutFilename ?? "") + outExpectedLast));
});
it(('writeKmnFileHeader should return no text with null filename ').padEnd(62, " ") + 'on correct input', async function () {
const writtenEmptytName = sutW.writeKmnFileHeader(null);
@ -120,34 +121,42 @@ describe('KmnFileWriter', function () {
});
});
describe('writeCharacterOrUnicode ', function () {
describe('writeCharacterOrUnicode and return values', function () {
const sutW = new KmnFileWriter(compilerTestCallbacks, compilerTestOptions);
[
["A", "Msg", "A", "Msg"],
["ሴ", "Msg", "ሴ", "Msg"],
["😀", "Msg", "😀", "Msg"],
["ẘ", "Msg", "ẘ", "Msg"],
["U+0001", "Msg", "U+0001", "Msg; Use of a control character "],
["U+0061", "Msg", "a", "Msg"],
["&#x0002;", "Msg", "U+0002", "Msg; Use of a control character "],
["&#x1234;", "Msg", 'ሴ', "Msg",],
["&#0003;", "Msg", "U+0003", "Msg; Use of a control character "],
["&#4666;", "Msg", "ሺ", "Msg",],
[null, "Msg", null, null],
[undefined, "Msg", null, null],
["", "Msg", null, null],
["", "Msg", "U+0006", "Msg; Use of a control character "],
["A", "A", "Msg"],
["ሴ", "ሴ", "Msg"],
["😀", "😀", "Msg"],
["ẘ", "ẘ", "Msg"],
["U+0001", "U+0001", "Msg; Use of a control character "],
["U+0061", "a", "Msg"],
["&#x0002;", "U+0002", "Msg; Use of a control character "],
["&#x1234;", 'ሴ', "Msg"],
["&#0003;", "U+0003", "Msg; Use of a control character "],
["&#4666;", "ሺ", "Msg"],
["", "U+0006", "Msg; Use of a control character "],
].forEach(function (values) {
it(('should convert "' + values[0] + '"').padEnd(25, " ") + 'to "' + values[2] + '"', async function () {
const result = sutW.writeCharacterOrUnicode(values[0] as string, values[1] as string);
if (result) {
assert.equal(result.character, values[2]);
assert.equal(result.message, values[3]);
}
else {
assert.isNull(values[2]);
assert.isNull(values[3]);
}
it(('should convert "' + values[0] + '"').padEnd(25, " ") + 'to "' + values[1] + '"', async function () {
const result = sutW.writeCharacterOrUnicode(values[0] as string, "Msg");
assert.isNotNull(result);
assert.equal(result.character, values[1]);
assert.equal(result.message, values[2]);
});
});
});
describe('writeCharacterOrUnicode and return empty string for result.message and result.character', function () {
const sutW = new KmnFileWriter(compilerTestCallbacks, compilerTestOptions);
[
[null, '', ''],
[undefined,'', ''],
['', '', ''],
].forEach(function (values) {
it(('should convert "' + values[0] + '"').padEnd(25, " ") + 'to "' + values[1] + '"', async function () {
const result = sutW.writeCharacterOrUnicode(values[0] as string, "Msg");
assert.isNotNull(result);
assert.equal(result.character, values[1]);
assert.equal(result.message, values[2]);
});
});
});
@ -488,14 +497,14 @@ describe('KmnFileWriter', function () {
rules: values[0] as Rule[]
};
const result1 = sutW.writeDataRules(data);
assert.isTrue(result1 === values[1][0]);
assert.equal(result1, values[1][0]);
});
});
it(('null should create empty string '), async function () {
const result1 = sutW.writeDataRules(null);
assert.isTrue(result1 === '');
});
const result1 = sutW.writeDataRules(null);
assert.equal(result1, '');
});
});
});