1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | 'use strict';
|
23 |
|
24 | var _glyphlist = require('../../core/glyphlist');
|
25 |
|
26 | var _unicode = require('../../core/unicode');
|
27 |
|
28 | describe('unicode', function () {
|
29 | describe('mapSpecialUnicodeValues', function () {
|
30 | it('should not re-map normal Unicode values', function () {
|
31 | expect((0, _unicode.mapSpecialUnicodeValues)(0x0041)).toEqual(0x0041);
|
32 | expect((0, _unicode.mapSpecialUnicodeValues)(0xFB01)).toEqual(0xFB01);
|
33 | });
|
34 | it('should re-map special Unicode values', function () {
|
35 | expect((0, _unicode.mapSpecialUnicodeValues)(0xF8E9)).toEqual(0x00A9);
|
36 | expect((0, _unicode.mapSpecialUnicodeValues)(0xFFFF)).toEqual(0);
|
37 | });
|
38 | });
|
39 | describe('getUnicodeForGlyph', function () {
|
40 | var standardMap, dingbatsMap;
|
41 | beforeAll(function (done) {
|
42 | standardMap = (0, _glyphlist.getGlyphsUnicode)();
|
43 | dingbatsMap = (0, _glyphlist.getDingbatsGlyphsUnicode)();
|
44 | done();
|
45 | });
|
46 | afterAll(function () {
|
47 | standardMap = dingbatsMap = null;
|
48 | });
|
49 | it('should get Unicode values for valid glyph names', function () {
|
50 | expect((0, _unicode.getUnicodeForGlyph)('A', standardMap)).toEqual(0x0041);
|
51 | expect((0, _unicode.getUnicodeForGlyph)('a1', dingbatsMap)).toEqual(0x2701);
|
52 | });
|
53 | it('should recover Unicode values from uniXXXX/uXXXX{XX} glyph names', function () {
|
54 | expect((0, _unicode.getUnicodeForGlyph)('uni0041', standardMap)).toEqual(0x0041);
|
55 | expect((0, _unicode.getUnicodeForGlyph)('u0041', standardMap)).toEqual(0x0041);
|
56 | expect((0, _unicode.getUnicodeForGlyph)('uni2701', dingbatsMap)).toEqual(0x2701);
|
57 | expect((0, _unicode.getUnicodeForGlyph)('u2701', dingbatsMap)).toEqual(0x2701);
|
58 | });
|
59 | it('should not get Unicode values for invalid glyph names', function () {
|
60 | expect((0, _unicode.getUnicodeForGlyph)('Qwerty', standardMap)).toEqual(-1);
|
61 | expect((0, _unicode.getUnicodeForGlyph)('Qwerty', dingbatsMap)).toEqual(-1);
|
62 | });
|
63 | });
|
64 | describe('getUnicodeRangeFor', function () {
|
65 | it('should get correct Unicode range', function () {
|
66 | expect((0, _unicode.getUnicodeRangeFor)(0x0041)).toEqual(0);
|
67 | expect((0, _unicode.getUnicodeRangeFor)(0xFB01)).toEqual(62);
|
68 | });
|
69 | it('should not get a Unicode range', function () {
|
70 | expect((0, _unicode.getUnicodeRangeFor)(0x05FF)).toEqual(-1);
|
71 | });
|
72 | });
|
73 | describe('getNormalizedUnicodes', function () {
|
74 | var NormalizedUnicodes;
|
75 | beforeAll(function (done) {
|
76 | NormalizedUnicodes = (0, _unicode.getNormalizedUnicodes)();
|
77 | done();
|
78 | });
|
79 | afterAll(function () {
|
80 | NormalizedUnicodes = null;
|
81 | });
|
82 | it('should get normalized Unicode values for ligatures', function () {
|
83 | expect(NormalizedUnicodes['\uFB01']).toEqual('fi');
|
84 | expect(NormalizedUnicodes['\u0675']).toEqual('\u0627\u0674');
|
85 | });
|
86 | it('should not normalize standard characters', function () {
|
87 | expect(NormalizedUnicodes['A']).toEqual(undefined);
|
88 | });
|
89 | });
|
90 | describe('reverseIfRtl', function () {
|
91 | var NormalizedUnicodes;
|
92 | function getGlyphUnicode(char) {
|
93 | if (NormalizedUnicodes[char] !== undefined) {
|
94 | return NormalizedUnicodes[char];
|
95 | }
|
96 | return char;
|
97 | }
|
98 | beforeAll(function (done) {
|
99 | NormalizedUnicodes = (0, _unicode.getNormalizedUnicodes)();
|
100 | done();
|
101 | });
|
102 | afterAll(function () {
|
103 | NormalizedUnicodes = null;
|
104 | });
|
105 | it('should not reverse LTR characters', function () {
|
106 | var A = getGlyphUnicode('A');
|
107 | expect((0, _unicode.reverseIfRtl)(A)).toEqual('A');
|
108 | var fi = getGlyphUnicode('\uFB01');
|
109 | expect((0, _unicode.reverseIfRtl)(fi)).toEqual('fi');
|
110 | });
|
111 | it('should reverse RTL characters', function () {
|
112 | var heAlef = getGlyphUnicode('\u05D0');
|
113 | expect((0, _unicode.reverseIfRtl)(heAlef)).toEqual('\u05D0');
|
114 | var arAlef = getGlyphUnicode('\u0675');
|
115 | expect((0, _unicode.reverseIfRtl)(arAlef)).toEqual('\u0674\u0627');
|
116 | });
|
117 | });
|
118 | }); |
\ | No newline at end of file |