UNPKG

@sutton-signwriting/core

Version:

a javascript package for node and browsers that supports general processing of the Sutton SignWriting script

73 lines (54 loc) â€Ē 2.51 kB
import { swu2num, num2swu, swu2coord, coord2swu, fsw2coord, coord2fsw, swu2code, code2swu, swu2id, id2swu, key2id, id2key, swu2key, key2swu, swu2fsw, fsw2swu } from './'; it('should convert swu to number', () => { expect(swu2num('ðĪ†')).toBe(500); }) it('should convert number to swu', () => { expect(num2swu(500)).toBe('ðĪ†'); }) it('should convert swu to coord', () => { expect(swu2coord('ðĪ†ðĪ†')).toEqual([500, 500]); }) it('should convert coord to swu', () => { expect(coord2swu([500, 500])).toBe('ðĪ†ðĪ†'); }) it('should convert fsw to coord', () => { expect(fsw2coord('500x500')).toEqual([500, 500]); }) it('should convert coord to fsw', () => { expect(coord2fsw([500, 500])).toBe('500x500'); }) it('should convert swu symbol to code point', () => { expect(swu2code('ņ€€')).toBe(0x40001); }) it('should convert code point to swu symbol', () => { expect(code2swu(0x40001)).toBe('ņ€€'); }) it('should convert swu symbol to 16-bit id', () => { expect(swu2id('ņ€€')).toBe(1); }) it('should convert 16-bit id to swu symbol', () => { expect(id2swu(1)).toBe('ņ€€'); }) it('should convert fsw symbol key to 16-bit id', () => { expect(key2id('S10000')).toBe(1); }) it('should convert 16-bit id to fsw symbol key', () => { expect(id2key(1)).toBe('S10000'); }) it('should convert swu symbol to fsw key', () => { expect(swu2key('ņ€€')).toBe('S10000'); }) it('should convert fsw key to swu symbol', () => { expect(key2swu('S10000')).toBe('ņ€€'); }) it('should convert an swu string into an fsw string', () => { expect(swu2fsw('ņ€€ðĪ†ðĪ†')).toBe('S10000500x500'); expect(swu2fsw('𝠀ņ€€’ņ€€šņ‹šĨņ‹›Đ𝠃ðĪŸðĪĐņ‹›ĐðĢĩðĪņ€€’ðĪ‡ðĢĪņ‹šĨðĪðĪ†ņ€€šðĢŪðĢ­')).toBe('AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475'); }) it('should convert an fsw string into an swu string', () => { expect(fsw2swu('S10000500x500')).toBe('ņ€€ðĪ†ðĪ†'); expect(fsw2swu('AS10011S10019S2e704S2e748M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475')).toBe('𝠀ņ€€’ņ€€šņ‹šĨņ‹›Đ𝠃ðĪŸðĪĐņ‹›ĐðĢĩðĪņ€€’ðĪ‡ðĢĪņ‹šĨðĪðĪ†ņ€€šðĢŪðĢ­'); }) it('should not corrupt styling string and other text', () => { 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!'); })