UNPKG

2.82 kBJavaScriptView Raw
1
2import { compose } from './swu-compose';
3
4it('should compose a symbol', () => {
5 expect(compose.symbol({ symbol: 'ņ€€' })).toEqual('ņ€€')
6})
7
8it('should compose a symbol with coordinate', () => {
9 expect(compose.symbol({ symbol: 'ņ€€', coord: [500, 500] })).toEqual('ņ€€ðĪ†ðĪ†')
10})
11
12it('should compose a symbol with style', () => {
13 expect(compose.symbol({ symbol: 'ņ€€', style: '-C' })).toEqual('ņ€€-C')
14})
15
16it('should not break on invalid symbol key or input', () => {
17 expect(compose.symbol()).toEqual(undefined)
18 expect(compose.symbol('a')).toEqual(undefined)
19 expect(compose.symbol({ 'a': 5 })).toEqual(undefined)
20 expect(compose.symbol(['a'])).toEqual(undefined)
21})
22
23it('should compose an empty signbox', () => {
24 expect(compose.sign({
25 box: '𝠃',
26 max: [500, 500]
27 })).toEqual('𝠃ðĪ†ðĪ†')
28})
29
30it('should compose a plain signbox', () => {
31 expect(compose.sign({
32 box: '𝠃',
33 max: [525, 535],
34 spatials: [
35 {
36 symbol: 'ņ‹›Đ',
37 coord: [483, 510]
38 },
39
40 {
41 symbol: 'ņ€€’',
42 coord: [501, 466]
43 },
44
45 {
46 symbol: 'ņ‹šĨ',
47 coord: [510, 500]
48 },
49
50 {
51 symbol: 'ņ€€š',
52 coord: [476, 475]
53 }
54 ]
55 })).toEqual('𝠃ðĪŸðĪĐņ‹›ĐðĢĩðĪņ€€’ðĪ‡ðĢĪņ‹šĨðĪðĪ†ņ€€šðĢŪðĢ­')
56})
57
58
59it('should compose a prefixed signbox', () => {
60 expect(compose.sign({
61 sequence: ['ņ€€’', 'ņ€€š', 'ņ‹šĨ', 'ņ‹›Đ'],
62 box: '𝠃',
63 max: [525, 535],
64 spatials: [
65 {
66 symbol: 'ņ‹›Đ',
67 coord: [483, 510]
68 },
69
70 {
71 symbol: 'ņ€€’',
72 coord: [501, 466]
73 },
74
75 {
76 symbol: 'ņ‹šĨ',
77 coord: [510, 500]
78 },
79
80 {
81 symbol: 'ņ€€š',
82 coord: [476, 475]
83 }
84 ]
85 })).toEqual('𝠀ņ€€’ņ€€šņ‹šĨņ‹›Đ𝠃ðĪŸðĪĐņ‹›ĐðĢĩðĪņ€€’ðĪ‡ðĢĪņ‹šĨðĪðĪ†ņ€€šðĢŪðĢ­')
86})
87
88it('should compose a prefixed signbox with style', () => {
89 expect(compose.sign({
90 sequence: ['ņ€€’', 'ņ€€š', 'ņ‹šĨ', 'ņ‹›Đ'],
91 box: '𝠃',
92 max: [525, 535],
93 spatials: [
94 {
95 symbol: 'ņ‹›Đ',
96 coord: [483, 510]
97 },
98
99 {
100 symbol: 'ņ€€’',
101 coord: [501, 466]
102 },
103
104 {
105 symbol: 'ņ‹šĨ',
106 coord: [510, 500]
107 },
108
109 {
110 symbol: 'ņ€€š',
111 coord: [476, 475]
112 }
113 ],
114 style: '-C'
115 })).toEqual('𝠀ņ€€’ņ€€šņ‹šĨņ‹›Đ𝠃ðĪŸðĪĐņ‹›ĐðĢĩðĪņ€€’ðĪ‡ðĢĪņ‹šĨðĪðĪ†ņ€€šðĢŪðĢ­-C')
116})
117
118it('should not break on invalid sign or input', () => {
119 expect(compose.sign()).toEqual(undefined)
120 expect(compose.sign('a')).toEqual(undefined)
121 expect(compose.sign({ 'a': 5 })).toEqual(undefined)
122 expect(compose.sign(['a'])).toEqual(undefined)
123})