UNPKG

3.58 kBJavaScriptView Raw
1
2import { columnDefaultsMerge, columns } from './swu-columns';
3import { sample } from './swu-sample';
4
5it('should return the column defaults', () => {
6 expect(columnDefaultsMerge()).toEqual({
7 "height": 500,
8 "width": 150,
9 "offset": 50,
10 "pad": 20,
11 "margin": 5,
12 "dynamic": false,
13 "punctuation": {
14 "pad": 30,
15 "pull": true,
16 "spacing": true
17 },
18 "style": {
19 "detail": [
20 "black",
21 "white"
22 ],
23 "zoom": 1
24 }
25 })
26})
27
28it('should merge top level with the column defaults', () => {
29 expect(columnDefaultsMerge({width:200})).toEqual({
30 "height": 500,
31 "width": 200,
32 "offset": 50,
33 "pad": 20,
34 "margin": 5,
35 "dynamic": false,
36 "punctuation": {
37 "pad": 30,
38 "pull": true,
39 "spacing": true
40 },
41 "style": {
42 "detail": [
43 "black",
44 "white"
45 ],
46 "zoom": 1
47 }
48 })
49})
50
51it('should merge deep level with the column defaults', () => {
52 expect(columnDefaultsMerge({punctuation:{pad:20},width:200})).toEqual({
53 "height": 500,
54 "width": 200,
55 "offset": 50,
56 "pad": 20,
57 "margin": 5,
58 "dynamic": false,
59 "punctuation": {
60 "pad": 20,
61 "pull": true,
62 "spacing": true
63 },
64 "style": {
65 "detail": [
66 "black",
67 "white"
68 ],
69 "zoom": 1
70 }
71 })
72 expect(columnDefaultsMerge({style:{background:"555"},width:200})).toEqual({
73 "height": 500,
74 "width": 200,
75 "offset": 50,
76 "pad": 20,
77 "margin": 5,
78 "dynamic": false,
79 "punctuation": {
80 "pad": 30,
81 "pull": true,
82 "spacing": true
83 },
84 "style": {
85 "detail": [
86 "black",
87 "white"
88 ],
89 "zoom": 1,
90 "background": "555"
91 }
92 })
93})
94
95it('should return an array of columns', () => {
96 let helloWorld = sample.helloWorld;
97 expect(columns(helloWorld)).toEqual({
98 "options": {
99 "height": 500,
100 "width": 150,
101 "offset": 50,
102 "pad": 20,
103 "margin": 5,
104 "dynamic": false,
105 "punctuation": {
106 "pad": 30,
107 "pull": true,
108 "spacing": true
109 },
110 "style": {
111 "detail": [
112 "black",
113 "white"
114 ],
115 "zoom": 1
116 }
117 },
118 "widths": [150],
119 "columns": [
120 [
121 {
122 "x": 56,
123 "y": 20,
124 "minX": 481,
125 "minY": 471,
126 "width": 37,
127 "height": 58,
128 "lane": 0,
129 "padding": 0,
130 "segment": "sign",
131 "text": "𝠀ρ²‘ρˆ©§π ƒπ€˜π€£ρ²‘𝣳𝣩ρˆ©§π€‰π£»",
132 "zoom": 1
133 },
134 {
135 "x": 57,
136 "y": 118,
137 "minX": 482,
138 "minY": 468,
139 "width": 36,
140 "height": 65,
141 "lane": 0,
142 "padding": 0,
143 "segment": "sign",
144 "text": "𝠀ρƒŠ’ρƒŠ«ρ‹›•ρ†‡‘π ƒπ€˜π€§ρƒŠ«π£»π€•ρƒŠ’𝣴𝣼ρ†‡‘π€Žπ€‚ρ‹›•π€†π£¦",
145 "zoom": 1
146 },
147 {
148 "x": 39,
149 "y": 203,
150 "minX": 464,
151 "minY": 496,
152 "width": 72,
153 "height": 8,
154 "lane": 0,
155 "padding": 0,
156 "segment": "symbol",
157 "text": "ρŒπ£’𝀂",
158 "zoom": 1
159 }
160 ]
161 ]
162 })
163})
164
165it('should not break columns on bad swu input', () => {
166 expect(columns()).toEqual({})
167 expect(columns(5)).toEqual({})
168 expect(columns(['what'])).toEqual({})
169})