Skip to content

Commit 5058c36

Browse files
committed
Add annotation tests
1 parent 0b7a78d commit 5058c36

File tree

4 files changed

+487
-0
lines changed

4 files changed

+487
-0
lines changed

lib/test/__snapshots__/browser.test.ts.snap

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,85 @@ exports[`extract annottations 2`] = `
109109
}
110110
`;
111111

112+
exports[`extract annottations from mdx 1`] = `
113+
{
114+
"annotations": [
115+
{
116+
"name": "foo",
117+
"query": "",
118+
"ranges": [
119+
{
120+
"fromColumn": 3,
121+
"lineNumber": 1,
122+
"toColumn": 5,
123+
},
124+
],
125+
},
126+
],
127+
"code": "{}
128+
# Hi there
129+
{/* bar */}",
130+
}
131+
`;
132+
133+
exports[`extract annottations from mdx 2`] = `
134+
{
135+
"lang": "mdx",
136+
"lines": [
137+
{
138+
"lineNumber": 1,
139+
"tokens": [
140+
{
141+
"content": "{}",
142+
"style": {
143+
"color": "#CE9178",
144+
},
145+
},
146+
],
147+
},
148+
{
149+
"lineNumber": 2,
150+
"tokens": [
151+
{
152+
"content": "# Hi there",
153+
"style": {
154+
"color": "#569CD6",
155+
"fontWeight": "bold",
156+
},
157+
},
158+
],
159+
},
160+
{
161+
"lineNumber": 3,
162+
"tokens": [
163+
{
164+
"content": "{",
165+
"style": {
166+
"color": "#CE9178",
167+
},
168+
},
169+
{
170+
"content": "/* bar */",
171+
"style": {
172+
"color": "#6A9955",
173+
},
174+
},
175+
{
176+
"content": "}",
177+
"style": {
178+
"color": "#CE9178",
179+
},
180+
},
181+
],
182+
},
183+
],
184+
"style": {
185+
"background": "#1E1E1E",
186+
"color": "#D4D4D4",
187+
},
188+
}
189+
`;
190+
112191
exports[`extract annottations from text 1`] = `
113192
{
114193
"annotations": [],
@@ -157,6 +236,80 @@ exports[`extract annottations from text 2`] = `
157236
}
158237
`;
159238

239+
exports[`extract annottations from txt 1`] = `
240+
{
241+
"annotations": [
242+
{
243+
"name": "foo",
244+
"query": "",
245+
"ranges": [
246+
{
247+
"fromColumn": 3,
248+
"lineNumber": 2,
249+
"toColumn": 5,
250+
},
251+
],
252+
},
253+
],
254+
"code": "const x = 1;
255+
const y = 2;",
256+
}
257+
`;
258+
259+
exports[`extract annottations from txt 2`] = `
260+
{
261+
"lang": "txt",
262+
"lines": [
263+
{
264+
"lineNumber": 1,
265+
"tokens": [
266+
{
267+
"content": "const x = 1;",
268+
"style": {
269+
"color": "#D4D4D4",
270+
},
271+
},
272+
],
273+
},
274+
{
275+
"lineNumber": 2,
276+
"tokens": [
277+
{
278+
"content": "co",
279+
"style": {
280+
"color": "#D4D4D4",
281+
},
282+
},
283+
{
284+
"annotationName": "foo",
285+
"annotationQuery": "",
286+
"fromColumn": 3,
287+
"toColumn": 5,
288+
"tokens": [
289+
{
290+
"content": "nst",
291+
"style": {
292+
"color": "#D4D4D4",
293+
},
294+
},
295+
],
296+
},
297+
{
298+
"content": " y = 2;",
299+
"style": {
300+
"color": "#D4D4D4",
301+
},
302+
},
303+
],
304+
},
305+
],
306+
"style": {
307+
"background": "#1E1E1E",
308+
"color": "#D4D4D4",
309+
},
310+
}
311+
`;
312+
160313
exports[`highlight html with theme 1`] = `
161314
{
162315
"lang": "html",

lib/test/__snapshots__/cjs.test.ts.snap

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,85 @@ exports[`extract annottations 2`] = `
109109
}
110110
`;
111111

112+
exports[`extract annottations from mdx 1`] = `
113+
{
114+
"annotations": [
115+
{
116+
"name": "foo",
117+
"query": "",
118+
"ranges": [
119+
{
120+
"fromColumn": 3,
121+
"lineNumber": 1,
122+
"toColumn": 5,
123+
},
124+
],
125+
},
126+
],
127+
"code": "{}
128+
# Hi there
129+
{/* bar */}",
130+
}
131+
`;
132+
133+
exports[`extract annottations from mdx 2`] = `
134+
{
135+
"lang": "mdx",
136+
"lines": [
137+
{
138+
"lineNumber": 1,
139+
"tokens": [
140+
{
141+
"content": "{}",
142+
"style": {
143+
"color": "#CE9178",
144+
},
145+
},
146+
],
147+
},
148+
{
149+
"lineNumber": 2,
150+
"tokens": [
151+
{
152+
"content": "# Hi there",
153+
"style": {
154+
"color": "#569CD6",
155+
"fontWeight": "bold",
156+
},
157+
},
158+
],
159+
},
160+
{
161+
"lineNumber": 3,
162+
"tokens": [
163+
{
164+
"content": "{",
165+
"style": {
166+
"color": "#CE9178",
167+
},
168+
},
169+
{
170+
"content": "/* bar */",
171+
"style": {
172+
"color": "#6A9955",
173+
},
174+
},
175+
{
176+
"content": "}",
177+
"style": {
178+
"color": "#CE9178",
179+
},
180+
},
181+
],
182+
},
183+
],
184+
"style": {
185+
"background": "#1E1E1E",
186+
"color": "#D4D4D4",
187+
},
188+
}
189+
`;
190+
112191
exports[`extract annottations from text 1`] = `
113192
{
114193
"annotations": [],
@@ -157,6 +236,80 @@ exports[`extract annottations from text 2`] = `
157236
}
158237
`;
159238

239+
exports[`extract annottations from txt 1`] = `
240+
{
241+
"annotations": [
242+
{
243+
"name": "foo",
244+
"query": "",
245+
"ranges": [
246+
{
247+
"fromColumn": 3,
248+
"lineNumber": 2,
249+
"toColumn": 5,
250+
},
251+
],
252+
},
253+
],
254+
"code": "const x = 1;
255+
const y = 2;",
256+
}
257+
`;
258+
259+
exports[`extract annottations from txt 2`] = `
260+
{
261+
"lang": "txt",
262+
"lines": [
263+
{
264+
"lineNumber": 1,
265+
"tokens": [
266+
{
267+
"content": "const x = 1;",
268+
"style": {
269+
"color": "#D4D4D4",
270+
},
271+
},
272+
],
273+
},
274+
{
275+
"lineNumber": 2,
276+
"tokens": [
277+
{
278+
"content": "co",
279+
"style": {
280+
"color": "#D4D4D4",
281+
},
282+
},
283+
{
284+
"annotationName": "foo",
285+
"annotationQuery": "",
286+
"fromColumn": 3,
287+
"toColumn": 5,
288+
"tokens": [
289+
{
290+
"content": "nst",
291+
"style": {
292+
"color": "#D4D4D4",
293+
},
294+
},
295+
],
296+
},
297+
{
298+
"content": " y = 2;",
299+
"style": {
300+
"color": "#D4D4D4",
301+
},
302+
},
303+
],
304+
},
305+
],
306+
"style": {
307+
"background": "#1E1E1E",
308+
"color": "#D4D4D4",
309+
},
310+
}
311+
`;
312+
160313
exports[`highlight html with theme 1`] = `
161314
{
162315
"lang": "html",

0 commit comments

Comments
 (0)