Skip to content

Commit 0ad8896

Browse files
committed
message-compiler: update unit tests
1 parent db29fbd commit 0ad8896

File tree

2 files changed

+332
-47
lines changed

2 files changed

+332
-47
lines changed
Lines changed: 318 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,318 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`@.caml:{'no apples'} | {0} apple | {n} apples: ast 1`] = `
4+
Object {
5+
"body": Object {
6+
"cases": Array [
7+
Object {
8+
"end": 19,
9+
"items": Array [
10+
Object {
11+
"end": 20,
12+
"key": Object {
13+
"end": 20,
14+
"loc": Object {
15+
"end": Object {
16+
"column": 21,
17+
"line": 1,
18+
"offset": 20,
19+
},
20+
"start": Object {
21+
"column": 8,
22+
"line": 1,
23+
"offset": 7,
24+
},
25+
},
26+
"start": 7,
27+
"type": 9,
28+
"value": "no apples",
29+
},
30+
"loc": Object {
31+
"end": Object {
32+
"column": 21,
33+
"line": 1,
34+
"offset": 20,
35+
},
36+
"start": Object {
37+
"column": 1,
38+
"line": 1,
39+
"offset": 0,
40+
},
41+
},
42+
"modifier": Object {
43+
"end": 6,
44+
"loc": Object {
45+
"end": Object {
46+
"column": 7,
47+
"line": 1,
48+
"offset": 6,
49+
},
50+
"start": Object {
51+
"column": 2,
52+
"line": 1,
53+
"offset": 1,
54+
},
55+
},
56+
"start": 1,
57+
"type": 8,
58+
"value": "caml",
59+
},
60+
"start": 0,
61+
"type": 6,
62+
},
63+
],
64+
"loc": Object {
65+
"end": Object {
66+
"column": 21,
67+
"line": 1,
68+
"offset": 20,
69+
},
70+
"start": Object {
71+
"column": 1,
72+
"line": 1,
73+
"offset": 0,
74+
},
75+
},
76+
"start": 0,
77+
"type": 2,
78+
},
79+
Object {
80+
"end": 26,
81+
"items": Array [
82+
Object {
83+
"end": 26,
84+
"index": 0,
85+
"loc": Object {
86+
"end": Object {
87+
"column": 27,
88+
"line": 1,
89+
"offset": 26,
90+
},
91+
"start": Object {
92+
"column": 24,
93+
"line": 1,
94+
"offset": 23,
95+
},
96+
},
97+
"start": 23,
98+
"type": 5,
99+
},
100+
Object {
101+
"end": 32,
102+
"loc": Object {
103+
"end": Object {
104+
"column": 33,
105+
"line": 1,
106+
"offset": 32,
107+
},
108+
"start": Object {
109+
"column": 27,
110+
"line": 1,
111+
"offset": 26,
112+
},
113+
},
114+
"start": 26,
115+
"type": 3,
116+
"value": " apple",
117+
},
118+
],
119+
"loc": Object {
120+
"end": Object {
121+
"column": 33,
122+
"line": 1,
123+
"offset": 32,
124+
},
125+
"start": Object {
126+
"column": 24,
127+
"line": 1,
128+
"offset": 23,
129+
},
130+
},
131+
"start": 23,
132+
"type": 2,
133+
},
134+
Object {
135+
"end": 45,
136+
"items": Array [
137+
Object {
138+
"end": 38,
139+
"key": "n",
140+
"loc": Object {
141+
"end": Object {
142+
"column": 39,
143+
"line": 1,
144+
"offset": 38,
145+
},
146+
"start": Object {
147+
"column": 36,
148+
"line": 1,
149+
"offset": 35,
150+
},
151+
},
152+
"start": 35,
153+
"type": 4,
154+
},
155+
Object {
156+
"end": 45,
157+
"loc": Object {
158+
"end": Object {
159+
"column": 46,
160+
"line": 1,
161+
"offset": 45,
162+
},
163+
"start": Object {
164+
"column": 39,
165+
"line": 1,
166+
"offset": 38,
167+
},
168+
},
169+
"start": 38,
170+
"type": 3,
171+
"value": " apples",
172+
},
173+
],
174+
"loc": Object {
175+
"end": Object {
176+
"column": 46,
177+
"line": 1,
178+
"offset": 45,
179+
},
180+
"start": Object {
181+
"column": 36,
182+
"line": 1,
183+
"offset": 35,
184+
},
185+
},
186+
"start": 35,
187+
"type": 2,
188+
},
189+
],
190+
"end": 45,
191+
"loc": Object {
192+
"end": Object {
193+
"column": 46,
194+
"line": 1,
195+
"offset": 45,
196+
},
197+
"start": Object {
198+
"column": 1,
199+
"line": 1,
200+
"offset": 0,
201+
},
202+
},
203+
"start": 0,
204+
"type": 1,
205+
},
206+
"end": 45,
207+
"helpers": Array [
208+
"normalize",
209+
"linked",
210+
"interpolate",
211+
"list",
212+
"named",
213+
"plural",
214+
],
215+
"loc": Object {
216+
"end": Object {
217+
"column": 46,
218+
"line": 1,
219+
"offset": 45,
220+
},
221+
"source": "@.caml:{'no apples'} | {0} apple | {n} apples",
222+
"start": Object {
223+
"column": 1,
224+
"line": 1,
225+
"offset": 0,
226+
},
227+
},
228+
"start": 0,
229+
"type": 0,
230+
}
231+
`;
232+
233+
exports[`@.caml:{'no apples'} | {0} apple | {n} apples: code 1`] = `
234+
"function __msg__ (ctx) {
235+
const { normalize: _normalize, linked: _linked, interpolate: _interpolate, list: _list, named: _named, plural: _plural } = ctx
236+
return _plural([
237+
_normalize([
238+
_linked(\\"no apples\\", \\"caml\\")
239+
]), _normalize([
240+
_interpolate(_list(0)), \\" apple\\"
241+
]), _normalize([
242+
_interpolate(_named(\\"n\\")), \\" apples\\"
243+
])
244+
])
245+
}"
246+
`;
247+
248+
exports[`@.caml:{'no apples'} | {0} apple | {n} apples: map 1`] = `undefined`;
249+
250+
exports[`edge cases | | | : code 1`] = `
251+
"function __msg__ (ctx) {
252+
const { normalize: _normalize, plural: _plural } = ctx
253+
return _plural([
254+
_normalize([
255+
256+
]), _normalize([
257+
258+
]), _normalize([
259+
260+
]), _normalize([
261+
262+
])
263+
])
264+
}"
265+
`;
266+
267+
exports[`edge cases | | | : error 1`] = `
268+
Object {
269+
"code": 10,
270+
"domain": "parser",
271+
"location": Object {
272+
"end": Object {
273+
"column": 8,
274+
"line": 1,
275+
"offset": 7,
276+
},
277+
"start": Object {
278+
"column": 1,
279+
"line": 1,
280+
"offset": 0,
281+
},
282+
},
283+
"message": "Plural must have messages",
284+
}
285+
`;
286+
287+
exports[`edge cases %: code 1`] = `
288+
"function __msg__ (ctx) {
289+
const { normalize: _normalize } = ctx
290+
return _normalize([
291+
\\"%\\"
292+
])
293+
}"
294+
`;
295+
296+
exports[`edge cases hi %s !: code 1`] = `
297+
"function __msg__ (ctx) {
298+
const { normalize: _normalize } = ctx
299+
return _normalize([
300+
\\"hi %s !\\"
301+
])
302+
}"
303+
`;
304+
305+
exports[`edge cases no apples %| one apple % | too much apples : code 1`] = `
306+
"function __msg__ (ctx) {
307+
const { normalize: _normalize, plural: _plural } = ctx
308+
return _plural([
309+
_normalize([
310+
\\"no apples %\\"
311+
]), _normalize([
312+
\\"one apple %\\"
313+
]), _normalize([
314+
\\"too much apples \\"
315+
])
316+
])
317+
}"
318+
`;

0 commit comments

Comments
 (0)