UNPKG

2.51 kBJavaScriptView Raw
1
2import { swu2num, num2swu, swu2coord, coord2swu, fsw2coord, coord2fsw, swu2code, code2swu, swu2id, id2swu, key2id, id2key, swu2key, key2swu, swu2fsw, fsw2swu } from './';
3
4it('should convert swu to number', () => {
5 expect(swu2num('ðĪ†')).toBe(500);
6})
7
8it('should convert number to swu', () => {
9 expect(num2swu(500)).toBe('ðĪ†');
10})
11
12it('should convert swu to coord', () => {
13 expect(swu2coord('ðĪ†ðĪ†')).toEqual([500, 500]);
14})
15
16it('should convert coord to swu', () => {
17 expect(coord2swu([500, 500])).toBe('ðĪ†ðĪ†');
18})
19
20it('should convert fsw to coord', () => {
21 expect(fsw2coord('500x500')).toEqual([500, 500]);
22})
23
24it('should convert coord to fsw', () => {
25 expect(coord2fsw([500, 500])).toBe('500x500');
26})
27
28it('should convert swu symbol to code point', () => {
29 expect(swu2code('ņ€€')).toBe(0x40001);
30})
31
32it('should convert code point to swu symbol', () => {
33 expect(code2swu(0x40001)).toBe('ņ€€');
34})
35
36it('should convert swu symbol to 16-bit id', () => {
37 expect(swu2id('ņ€€')).toBe(1);
38})
39
40it('should convert 16-bit id to swu symbol', () => {
41 expect(id2swu(1)).toBe('ņ€€');
42})
43
44it('should convert fsw symbol key to 16-bit id', () => {
45 expect(key2id('S10000')).toBe(1);
46})
47
48it('should convert 16-bit id to fsw symbol key', () => {
49 expect(id2key(1)).toBe('S10000');
50})
51
52it('should convert swu symbol to fsw key', () => {
53 expect(swu2key('ņ€€')).toBe('S10000');
54})
55
56it('should convert fsw key to swu symbol', () => {
57 expect(key2swu('S10000')).toBe('ņ€€');
58})
59
60it('should convert an swu string into an fsw string', () => {
61 expect(swu2fsw('ņ€€ðĪ†ðĪ†')).toBe('S10000500x500');
62 expect(swu2fsw('𝠀ņ€€’ņ€€šņ‹šĨņ‹›Đ𝠃ðĪŸðĪĐņ‹›ĐðĢĩðĪņ€€’ðĪ‡ðĢĪņ‹šĨðĪðĪ†ņ€€šðĢŪðĢ­')).toBe('AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475');
63})
64
65it('should convert an fsw string into an swu string', () => {
66 expect(fsw2swu('S10000500x500')).toBe('ņ€€ðĪ†ðĪ†');
67 expect(fsw2swu('AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475')).toBe('𝠀ņ€€’ņ€€šņ‹šĨņ‹›Đ𝠃ðĪŸðĪĐņ‹›ĐðĢĩðĪņ€€’ðĪ‡ðĢĪņ‹šĨðĪðĪ†ņ€€šðĢŪðĢ­');
68})
69
70it('should not corrupt styling string and other text', () => {
71 expect(fsw2swu('-CP10G_blue_D_red,Cyan_Z1.1-D01_blue_D02_yellow,green_Z01,10,500x500Z02,5.5-primary blinking!cursor!')).toBe('-CP10G_blue_D_red,Cyan_Z1.1-D01_blue_D02_yellow,green_Z01,10,500x500Z02,5.5-primary blinking!cursor!');
72})