Implement a unit test for getCharUnicodeCategory
in src/core/unicode.js
(PR 14428 follow-up)
Given that the other functions in this file are already covered by unit tests, we should also cover this newly added function.
This commit is contained in:
parent
749a3fa699
commit
e08fd5e389
@ -14,16 +14,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getDingbatsGlyphsUnicode,
|
getCharUnicodeCategory,
|
||||||
getGlyphsUnicode,
|
|
||||||
} from "../../src/core/glyphlist.js";
|
|
||||||
import {
|
|
||||||
getNormalizedUnicodes,
|
getNormalizedUnicodes,
|
||||||
getUnicodeForGlyph,
|
getUnicodeForGlyph,
|
||||||
getUnicodeRangeFor,
|
getUnicodeRangeFor,
|
||||||
mapSpecialUnicodeValues,
|
mapSpecialUnicodeValues,
|
||||||
reverseIfRtl,
|
reverseIfRtl,
|
||||||
} from "../../src/core/unicode.js";
|
} from "../../src/core/unicode.js";
|
||||||
|
import {
|
||||||
|
getDingbatsGlyphsUnicode,
|
||||||
|
getGlyphsUnicode,
|
||||||
|
} from "../../src/core/glyphlist.js";
|
||||||
|
|
||||||
describe("unicode", function () {
|
describe("unicode", function () {
|
||||||
describe("mapSpecialUnicodeValues", function () {
|
describe("mapSpecialUnicodeValues", function () {
|
||||||
@ -42,6 +43,30 @@ describe("unicode", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("getCharUnicodeCategory", function () {
|
||||||
|
it("should correctly determine the character category", function () {
|
||||||
|
const tests = {
|
||||||
|
// Whitespace
|
||||||
|
" ": { isDiacritic: false, isWhitespace: true },
|
||||||
|
"\t": { isDiacritic: false, isWhitespace: true },
|
||||||
|
"\u2001": { isDiacritic: false, isWhitespace: true },
|
||||||
|
"\uFEFF": { isDiacritic: false, isWhitespace: true },
|
||||||
|
|
||||||
|
// Diacritic
|
||||||
|
"\u0302": { isDiacritic: true, isWhitespace: false },
|
||||||
|
"\u0344": { isDiacritic: true, isWhitespace: false },
|
||||||
|
"\u0361": { isDiacritic: true, isWhitespace: false },
|
||||||
|
|
||||||
|
// No whitespace or diacritic
|
||||||
|
a: { isDiacritic: false, isWhitespace: false },
|
||||||
|
1: { isDiacritic: false, isWhitespace: false },
|
||||||
|
};
|
||||||
|
for (const [character, expectation] of Object.entries(tests)) {
|
||||||
|
expect(getCharUnicodeCategory(character)).toEqual(expectation);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("getUnicodeForGlyph", function () {
|
describe("getUnicodeForGlyph", function () {
|
||||||
let standardMap, dingbatsMap;
|
let standardMap, dingbatsMap;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user